Masami Ichikawa
93518dd2eb
sysfs: Fix memory leak in sysfs_sd_setsecdata().
This patch fixies follwing two memory leak patterns that reported by kmemleak.
sysfs_sd_setsecdata() is called during sys_lsetxattr() operation.
It checks sd->s_iattr is NULL or not. Then if it is NULL, it calls
sysfs_init_inode_attrs() to allocate memory.
That code is this.
iattrs = sd->s_iattr;
if (!iattrs)
iattrs = sysfs_init_inode_attrs(sd);
The iattrs recieves sysfs_init_inode_attrs()'s result, but sd->s_iattr
doesn't know the address. so it needs to set correct address to
sd->s_iattr to free memory in other function.
unreferenced object 0xffff880250b73e60 (size 32):
comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
hex dump (first 32 bytes):
73 79 73 74 65 6d 5f 75 3a 6f 62 6a 65 63 74 5f system_u:object_
72 3a 73 79 73 66 73 5f 74 3a 73 30 00 00 00 00 r:sysfs_t:s0....
backtrace:
[<ffffffff814cb1d0>] kmemleak_alloc+0x73/0x98
[<ffffffff811270ab>] __kmalloc+0x100/0x12c
[<ffffffff8120775a>] context_struct_to_string+0x106/0x210
[<ffffffff81207cc1>] security_sid_to_context_core+0x10b/0x129
[<ffffffff812090ef>] security_sid_to_context+0x10/0x12
[<ffffffff811fb0da>] selinux_inode_getsecurity+0x7d/0xa8
[<ffffffff811fb127>] selinux_inode_getsecctx+0x22/0x2e
[<ffffffff811f4d62>] security_inode_getsecctx+0x16/0x18
[<ffffffff81191dad>] sysfs_setxattr+0x96/0x117
[<ffffffff811542f0>] __vfs_setxattr_noperm+0x73/0xd9
[<ffffffff811543d9>] vfs_setxattr+0x83/0xa1
[<ffffffff811544c6>] setxattr+0xcf/0x101
[<ffffffff81154745>] sys_lsetxattr+0x6a/0x8f
[<ffffffff814efda9>] system_call_fastpath+0x16/0x1b
[<ffffffffffffffff>] 0xffffffffffffffff
unreferenced object 0xffff88024163c5a0 (size 96):
comm "systemd", pid 1, jiffies 4294683888 (age 94.553s)
hex dump (first 32 bytes):
00 00 00 00 ed 41 00 00 00 00 00 00 00 00 00 00 .....A..........
00 00 00 00 00 00 00 00 0c 64 42 4f 00 00 00 00 .........dBO....
backtrace:
[<ffffffff814cb1d0>] kmemleak_alloc+0x73/0x98
[<ffffffff81127402>] kmem_cache_alloc_trace+0xc4/0xee
[<ffffffff81191cbe>] sysfs_init_inode_attrs+0x2a/0x83
[<ffffffff81191dd6>] sysfs_setxattr+0xbf/0x117
[<ffffffff811542f0>] __vfs_setxattr_noperm+0x73/0xd9
[<ffffffff811543d9>] vfs_setxattr+0x83/0xa1
[<ffffffff811544c6>] setxattr+0xcf/0x101
[<ffffffff81154745>] sys_lsetxattr+0x6a/0x8f
[<ffffffff814efda9>] system_call_fastpath+0x16/0x1b
[<ffffffffffffffff>] 0xffffffffffffffff
`
Signed-off-by: Masami Ichikawa <masami256@gmail.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-02-24 14:25:49 -08:00
..
2012-01-10 15:09:01 -08:00
2012-01-06 23:19:54 -05:00
2012-01-03 22:55:04 -05:00
2012-01-03 22:54:53 -05:00
2012-01-13 08:30:49 -08:00
2012-01-03 22:52:40 -05:00
2012-01-03 22:54:53 -05:00
2012-01-28 17:00:19 -08:00
2012-01-03 22:54:07 -05:00
2012-01-13 10:29:21 -08:00
2012-01-18 22:32:33 -06:00
2012-01-10 11:13:16 -05:00
2012-01-03 22:54:57 -05:00
2012-01-06 23:15:54 -05:00
2012-02-02 11:24:44 -08:00
2012-01-08 20:19:03 -05:00
2012-01-10 14:55:55 -08:00
2012-01-25 15:10:53 -08:00
2012-01-03 22:52:40 -05:00
2012-01-09 12:51:01 -08:00
2011-03-15 02:21:44 -04:00
2012-01-11 13:39:02 +01:00
2012-01-09 12:51:21 -08:00
2012-01-10 11:54:07 -05:00
2012-01-09 12:09:47 -08:00
2012-01-03 22:55:10 -05:00
2011-07-21 10:59:16 -07:00
2012-01-12 12:39:21 -08:00
2012-01-11 12:35:05 +00:00
2012-01-06 23:19:54 -05:00
2012-01-10 17:48:52 -05:00
2012-01-06 23:19:54 -05:00
2012-01-03 22:54:54 -05:00
2012-01-03 22:52:41 -05:00
2012-01-12 20:13:09 -08:00
2012-01-09 10:48:11 -05:00
2012-01-11 13:36:57 +01:00
2012-01-10 11:54:07 -05:00
2012-01-10 13:45:22 -08:00
2012-01-08 13:10:57 -08:00
2012-01-13 09:32:20 +10:30
2012-01-31 09:23:59 -08:00
2012-01-08 12:19:57 -08:00
2012-01-06 23:19:54 -05:00
2012-01-16 15:08:13 -08:00
2011-03-31 11:26:23 -03:00
2012-01-14 12:26:41 -08:00
2012-01-08 13:10:57 -08:00
2011-11-26 19:58:47 -08:00
2012-01-14 18:01:42 -08:00
2012-01-13 09:32:17 +10:30
2012-01-10 14:55:55 -08:00
2012-01-03 22:55:01 -05:00
2012-01-03 22:52:40 -05:00
2012-01-23 08:38:48 -08:00
2011-11-18 13:49:00 -08:00
2012-01-19 13:54:36 -05:00
2012-01-12 13:09:09 +01:00
2012-01-03 22:55:07 -05:00
2012-01-10 16:30:54 -08:00
2012-01-10 13:45:22 -08:00
2012-01-13 10:34:57 -08:00
2012-02-24 14:25:49 -08:00
2012-01-06 23:16:53 -05:00
2012-01-15 13:46:02 +02:00
2012-01-09 12:51:21 -08:00
2012-01-06 23:19:54 -05:00
2012-01-25 11:01:31 -06:00
2012-01-13 20:39:44 -08:00
2011-07-26 12:57:09 -04:00
2012-01-03 22:55:11 -05:00
2012-01-03 22:54:54 -05:00
2010-10-14 10:57:40 -07:00
2011-07-20 01:43:10 -04:00
2012-01-10 16:30:51 -08:00
2011-05-03 10:10:51 +10:00
2012-01-06 23:16:53 -05:00
2011-10-31 19:30:31 -04:00
2011-11-16 09:21:50 +01:00
2012-01-12 20:13:12 -08:00
2012-01-03 22:54:07 -05:00
2011-12-13 11:18:17 -08:00
2012-01-15 12:49:56 -08:00
2012-01-03 22:55:19 -05:00
2012-01-13 10:29:21 -08:00
2011-05-31 16:33:35 +02:00
2012-01-12 20:13:12 -08:00
2011-05-25 08:39:26 -07:00
2011-02-21 15:07:04 -08:00
2012-01-12 20:13:04 -08:00
2012-01-10 16:30:44 -08:00
2011-03-23 19:47:13 -07:00
2012-01-06 23:16:53 -05:00
2011-03-21 00:16:09 -04:00
2012-01-06 23:20:13 -05:00
2011-04-28 11:28:20 -07:00
2012-01-03 22:52:39 -05:00
2011-01-16 13:47:07 -05:00
2012-01-10 16:59:59 -08:00
2011-08-01 02:10:06 -04:00
2012-01-17 16:39:47 -05:00
2012-01-06 23:20:12 -05:00
2012-01-05 15:40:12 -08:00
2011-12-14 00:33:39 +01:00
2012-01-09 12:51:01 -08:00
2012-01-10 16:30:51 -08:00
2012-01-03 22:54:07 -05:00
2011-12-26 10:25:26 -08:00
2012-01-06 23:15:54 -05:00
2011-05-25 08:39:26 -07:00
2012-01-06 23:20:12 -05:00
2012-01-12 09:19:54 +01:00
2012-01-17 16:17:01 -05:00
2012-01-08 13:21:22 -08:00
2010-10-15 15:53:27 +02:00
2012-01-06 23:16:53 -05:00
2012-01-12 20:13:04 -08:00
2012-01-03 22:57:11 -05:00
2012-01-03 22:57:11 -05:00
2011-10-28 14:58:54 +02:00
2012-01-06 23:19:54 -05:00
2011-10-31 17:30:44 -07:00
2011-03-21 00:16:08 -04:00
2012-01-03 22:52:40 -05:00
2010-10-26 10:13:10 -07:00
2012-01-03 22:54:07 -05:00
2011-11-02 12:53:43 +01:00
2011-11-02 12:53:42 +01:00
2012-01-03 22:53:07 -05:00
2012-01-17 16:38:47 -05:00
2012-01-03 22:54:07 -05:00
2011-06-14 11:46:14 +02:00
2011-03-23 19:47:13 -07:00
2012-01-03 22:52:40 -05:00