* [PATCH -next] exec: Fix mem leak in kernel_read_file
@ 2019-02-19 2:10 YueHaibing
2019-02-19 2:25 ` Al Viro
0 siblings, 1 reply; 7+ messages in thread
From: YueHaibing @ 2019-02-19 2:10 UTC (permalink / raw)
To: viro; +Cc: linux-kernel, linux-fsdevel, dmitry.kasatkin, keescook, YueHaibing
syzkaller report this:
BUG: memory leak
unreferenced object 0xffffc9000488d000 (size 9195520):
comm "syz-executor.0", pid 2752, jiffies 4294787496 (age 18.757s)
hex dump (first 32 bytes):
ff ff ff ff ff ff ff ff a8 00 00 00 01 00 00 00 ................
02 00 00 00 00 00 00 00 80 a1 7a c1 ff ff ff ff ..........z.....
backtrace:
[<000000000863775c>] __vmalloc_node mm/vmalloc.c:1795 [inline]
[<000000000863775c>] __vmalloc_node_flags mm/vmalloc.c:1809 [inline]
[<000000000863775c>] vmalloc+0x8c/0xb0 mm/vmalloc.c:1831
[<000000003f668111>] kernel_read_file+0x58f/0x7d0 fs/exec.c:924
[<000000002385813f>] kernel_read_file_from_fd+0x49/0x80 fs/exec.c:993
[<0000000011953ff1>] __do_sys_finit_module+0x13b/0x2a0 kernel/module.c:3895
[<000000006f58491f>] do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
[<00000000ee78baf4>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
[<00000000241f889b>] 0xffffffffffffffff
It should goto 'out_free' lable to free allocated buf while kernel_read
fails.
Fixes: 39d637af5aa7 ("vfs: forbid write access when reading a file into memory")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
fs/exec.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/exec.c b/fs/exec.c
index 7a4b5ef..2e00333 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -932,7 +932,7 @@ int kernel_read_file(struct file *file, void **buf, loff_t *size,
bytes = kernel_read(file, *buf + pos, i_size - pos, &pos);
if (bytes < 0) {
ret = bytes;
- goto out;
+ goto out_free;
}
if (bytes == 0)
--
2.7.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
2019-02-19 2:10 [PATCH -next] exec: Fix mem leak in kernel_read_file YueHaibing
@ 2019-02-19 2:25 ` Al Viro
2019-03-11 16:59 ` Dmitry Kasatkin
0 siblings, 1 reply; 7+ messages in thread
From: Al Viro @ 2019-02-19 2:25 UTC (permalink / raw)
To: YueHaibing; +Cc: linux-kernel, linux-fsdevel, dmitry.kasatkin, keescook
On Tue, Feb 19, 2019 at 10:10:38AM +0800, YueHaibing wrote:
> syzkaller report this:
> BUG: memory leak
> unreferenced object 0xffffc9000488d000 (size 9195520):
> comm "syz-executor.0", pid 2752, jiffies 4294787496 (age 18.757s)
> hex dump (first 32 bytes):
> ff ff ff ff ff ff ff ff a8 00 00 00 01 00 00 00 ................
> 02 00 00 00 00 00 00 00 80 a1 7a c1 ff ff ff ff ..........z.....
> backtrace:
> [<000000000863775c>] __vmalloc_node mm/vmalloc.c:1795 [inline]
> [<000000000863775c>] __vmalloc_node_flags mm/vmalloc.c:1809 [inline]
> [<000000000863775c>] vmalloc+0x8c/0xb0 mm/vmalloc.c:1831
> [<000000003f668111>] kernel_read_file+0x58f/0x7d0 fs/exec.c:924
> [<000000002385813f>] kernel_read_file_from_fd+0x49/0x80 fs/exec.c:993
> [<0000000011953ff1>] __do_sys_finit_module+0x13b/0x2a0 kernel/module.c:3895
> [<000000006f58491f>] do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
> [<00000000ee78baf4>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
> [<00000000241f889b>] 0xffffffffffffffff
>
> It should goto 'out_free' lable to free allocated buf while kernel_read
> fails.
Applied.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
2019-02-19 2:25 ` Al Viro
@ 2019-03-11 16:59 ` Dmitry Kasatkin
2019-03-11 23:16 ` Sasha Levin
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Kasatkin @ 2019-03-11 16:59 UTC (permalink / raw)
To: Al Viro, yuehaibing; +Cc: linux-kernel, linux-fsdevel, keescook, stable, gregkh
From: Al Viro <viro@ftp.linux.org.uk> on behalf of Al Viro <viro@zeniv.linux.org.uk>
Sent: Tuesday, February 19, 2019 4:25 AM
To: yuehaibing
Cc: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; Dmitry Kasatkin; keescook@chromium.org
Subject: Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
On Tue, Feb 19, 2019 at 10:10:38AM +0800, YueHaibing wrote:
> syzkaller report this:
> BUG: memory leak
> unreferenced object 0xffffc9000488d000 (size 9195520):
> comm "syz-executor.0", pid 2752, jiffies 4294787496 (age 18.757s)
> hex dump (first 32 bytes):
> ff ff ff ff ff ff ff ff a8 00 00 00 01 00 00 00 ................
> 02 00 00 00 00 00 00 00 80 a1 7a c1 ff ff ff ff ..........z.....
> backtrace:
> [<000000000863775c>] __vmalloc_node mm/vmalloc.c:1795 [inline]
> [<000000000863775c>] __vmalloc_node_flags mm/vmalloc.c:1809 [inline]
> [<000000000863775c>] vmalloc+0x8c/0xb0 mm/vmalloc.c:1831
> [<000000003f668111>] kernel_read_file+0x58f/0x7d0 fs/exec.c:924
> [<000000002385813f>] kernel_read_file_from_fd+0x49/0x80 fs/exec.c:993
> [<0000000011953ff1>] __do_sys_finit_module+0x13b/0x2a0 kernel/module.c:3895
> [<000000006f58491f>] do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
> [<00000000ee78baf4>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
> [<00000000241f889b>] 0xffffffffffffffff
>
> It should goto 'out_free' lable to free allocated buf while kernel_read
> fails.
Applied.
This must be applied to stables as well...
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
2019-03-11 16:59 ` Dmitry Kasatkin
@ 2019-03-11 23:16 ` Sasha Levin
2019-03-13 14:12 ` Dmitry Kasatkin
0 siblings, 1 reply; 7+ messages in thread
From: Sasha Levin @ 2019-03-11 23:16 UTC (permalink / raw)
To: Dmitry Kasatkin
Cc: Al Viro, yuehaibing, linux-kernel, linux-fsdevel, keescook,
stable, gregkh
On Mon, Mar 11, 2019 at 04:59:14PM +0000, Dmitry Kasatkin wrote:
>
>From: Al Viro <viro@ftp.linux.org.uk> on behalf of Al Viro <viro@zeniv.linux.org.uk>
>Sent: Tuesday, February 19, 2019 4:25 AM
>To: yuehaibing
>Cc: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; Dmitry Kasatkin; keescook@chromium.org
>Subject: Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
>
>On Tue, Feb 19, 2019 at 10:10:38AM +0800, YueHaibing wrote:
>> syzkaller report this:
>> BUG: memory leak
>> unreferenced object 0xffffc9000488d000 (size 9195520):
>> comm "syz-executor.0", pid 2752, jiffies 4294787496 (age 18.757s)
>> hex dump (first 32 bytes):
>> ff ff ff ff ff ff ff ff a8 00 00 00 01 00 00 00 ................
>> 02 00 00 00 00 00 00 00 80 a1 7a c1 ff ff ff ff ..........z.....
>> backtrace:
>> [<000000000863775c>] __vmalloc_node mm/vmalloc.c:1795 [inline]
>> [<000000000863775c>] __vmalloc_node_flags mm/vmalloc.c:1809 [inline]
>> [<000000000863775c>] vmalloc+0x8c/0xb0 mm/vmalloc.c:1831
>> [<000000003f668111>] kernel_read_file+0x58f/0x7d0 fs/exec.c:924
>> [<000000002385813f>] kernel_read_file_from_fd+0x49/0x80 fs/exec.c:993
>> [<0000000011953ff1>] __do_sys_finit_module+0x13b/0x2a0 kernel/module.c:3895
>> [<000000006f58491f>] do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
>> [<00000000ee78baf4>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
>> [<00000000241f889b>] 0xffffffffffffffff
>>
>> It should goto 'out_free' lable to free allocated buf while kernel_read
>> fails.
>
>Applied.
>
>
>This must be applied to stables as well...
It's already in all relevant stable trees...
--
Thanks,
Sasha
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
2019-03-11 23:16 ` Sasha Levin
@ 2019-03-13 14:12 ` Dmitry Kasatkin
2019-03-13 14:38 ` gregkh
0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Kasatkin @ 2019-03-13 14:12 UTC (permalink / raw)
To: Sasha Levin
Cc: Al Viro, yuehaibing, linux-kernel, linux-fsdevel, keescook,
stable, gregkh
From: Sasha Levin <sashal@kernel.org>
Sent: Tuesday, March 12, 2019 1:16 AM
To: Dmitry Kasatkin
Cc: Al Viro; yuehaibing; linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; keescook@chromium.org; stable@vger.kernel.org; gregkh@google.com
Subject: Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
On Mon, Mar 11, 2019 at 04:59:14PM +0000, Dmitry Kasatkin wrote:
>
>From: Al Viro <viro@ftp.linux.org.uk> on behalf of Al Viro <viro@zeniv.linux.org.uk>
>Sent: Tuesday, February 19, 2019 4:25 AM
>To: yuehaibing
>Cc: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; Dmitry Kasatkin; keescook@chromium.org
>Subject: Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
>
>On Tue, Feb 19, 2019 at 10:10:38AM +0800, YueHaibing wrote:
>> syzkaller report this:
>> BUG: memory leak
>> unreferenced object 0xffffc9000488d000 (size 9195520):
>> comm "syz-executor.0", pid 2752, jiffies 4294787496 (age 18.757s)
>> hex dump (first 32 bytes):
>> ff ff ff ff ff ff ff ff a8 00 00 00 01 00 00 00 ................
>> 02 00 00 00 00 00 00 00 80 a1 7a c1 ff ff ff ff ..........z.....
>> backtrace:
>> [<000000000863775c>] __vmalloc_node mm/vmalloc.c:1795 [inline]
>> [<000000000863775c>] __vmalloc_node_flags mm/vmalloc.c:1809 [inline]
>> [<000000000863775c>] vmalloc+0x8c/0xb0 mm/vmalloc.c:1831
>> [<000000003f668111>] kernel_read_file+0x58f/0x7d0 fs/exec.c:924
>> [<000000002385813f>] kernel_read_file_from_fd+0x49/0x80 fs/exec.c:993
>> [<0000000011953ff1>] __do_sys_finit_module+0x13b/0x2a0 kernel/module.c:3895
>> [<000000006f58491f>] do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
>> [<00000000ee78baf4>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
>> [<00000000241f889b>] 0xffffffffffffffff
>>
>> It should goto 'out_free' lable to free allocated buf while kernel_read
>> fails.
>
>Applied.
>
>
>This must be applied to stables as well...
> It's already in all relevant stable trees...
I only can see in longterm 4.19.
What about 4.9 and 4.14?
Thanks,
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
2019-03-13 14:12 ` Dmitry Kasatkin
@ 2019-03-13 14:38 ` gregkh
2019-03-13 15:00 ` Dmitry Kasatkin
0 siblings, 1 reply; 7+ messages in thread
From: gregkh @ 2019-03-13 14:38 UTC (permalink / raw)
To: Dmitry Kasatkin
Cc: Sasha Levin, Al Viro, yuehaibing, linux-kernel, linux-fsdevel,
keescook, stable
On Wed, Mar 13, 2019 at 02:12:30PM +0000, Dmitry Kasatkin wrote:
>
>
>
>
>
>
> From: Sasha Levin <sashal@kernel.org>
> Sent: Tuesday, March 12, 2019 1:16 AM
> To: Dmitry Kasatkin
> Cc: Al Viro; yuehaibing; linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; keescook@chromium.org; stable@vger.kernel.org; gregkh@google.com
> Subject: Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
>
> On Mon, Mar 11, 2019 at 04:59:14PM +0000, Dmitry Kasatkin wrote:
> >
> >From: Al Viro <viro@ftp.linux.org.uk> on behalf of Al Viro <viro@zeniv.linux.org.uk>
> >Sent: Tuesday, February 19, 2019 4:25 AM
> >To: yuehaibing
> >Cc: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; Dmitry Kasatkin; keescook@chromium.org
> >Subject: Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
> >
> >On Tue, Feb 19, 2019 at 10:10:38AM +0800, YueHaibing wrote:
> >> syzkaller report this:
> >> BUG: memory leak
> >> unreferenced object 0xffffc9000488d000 (size 9195520):
> >> comm "syz-executor.0", pid 2752, jiffies 4294787496 (age 18.757s)
> >> hex dump (first 32 bytes):
> >> ff ff ff ff ff ff ff ff a8 00 00 00 01 00 00 00 ................
> >> 02 00 00 00 00 00 00 00 80 a1 7a c1 ff ff ff ff ..........z.....
> >> backtrace:
> >> [<000000000863775c>] __vmalloc_node mm/vmalloc.c:1795 [inline]
> >> [<000000000863775c>] __vmalloc_node_flags mm/vmalloc.c:1809 [inline]
> >> [<000000000863775c>] vmalloc+0x8c/0xb0 mm/vmalloc.c:1831
> >> [<000000003f668111>] kernel_read_file+0x58f/0x7d0 fs/exec.c:924
> >> [<000000002385813f>] kernel_read_file_from_fd+0x49/0x80 fs/exec.c:993
> >> [<0000000011953ff1>] __do_sys_finit_module+0x13b/0x2a0 kernel/module.c:3895
> >> [<000000006f58491f>] do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
> >> [<00000000ee78baf4>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
> >> [<00000000241f889b>] 0xffffffffffffffff
> >>
> >> It should goto 'out_free' lable to free allocated buf while kernel_read
> >> fails.
> >
> >Applied.
> >
> >
> >This must be applied to stables as well...
>
> > It's already in all relevant stable trees...
>
> I only can see in longterm 4.19.
>
> What about 4.9 and 4.14?
It was in the queue already for that (you can see it on git.kernel.org),
and they are now part of the -rc releases that are currently out for
review.
thanks,
greg k-h
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
2019-03-13 14:38 ` gregkh
@ 2019-03-13 15:00 ` Dmitry Kasatkin
0 siblings, 0 replies; 7+ messages in thread
From: Dmitry Kasatkin @ 2019-03-13 15:00 UTC (permalink / raw)
To: gregkh
Cc: Sasha Levin, Al Viro, yuehaibing, linux-kernel, linux-fsdevel,
keescook, stable
On 13/03/2019 16:38, gregkh@linuxfoundation.org wrote:
> On Wed, Mar 13, 2019 at 02:12:30PM +0000, Dmitry Kasatkin wrote:
>>
>>
>>
>>
>>
>>
>> From: Sasha Levin <sashal@kernel.org>
>> Sent: Tuesday, March 12, 2019 1:16 AM
>> To: Dmitry Kasatkin
>> Cc: Al Viro; yuehaibing; linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; keescook@chromium.org; stable@vger.kernel.org; gregkh@google.com
>> Subject: Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
>>
>> On Mon, Mar 11, 2019 at 04:59:14PM +0000, Dmitry Kasatkin wrote:
>>>
>>> From: Al Viro <viro@ftp.linux.org.uk> on behalf of Al Viro <viro@zeniv.linux.org.uk>
>>> Sent: Tuesday, February 19, 2019 4:25 AM
>>> To: yuehaibing
>>> Cc: linux-kernel@vger.kernel.org; linux-fsdevel@vger.kernel.org; Dmitry Kasatkin; keescook@chromium.org
>>> Subject: Re: [PATCH -next] exec: Fix mem leak in kernel_read_file
>>>
>>> On Tue, Feb 19, 2019 at 10:10:38AM +0800, YueHaibing wrote:
>>>> syzkaller report this:
>>>> BUG: memory leak
>>>> unreferenced object 0xffffc9000488d000 (size 9195520):
>>>> comm "syz-executor.0", pid 2752, jiffies 4294787496 (age 18.757s)
>>>> hex dump (first 32 bytes):
>>>> ff ff ff ff ff ff ff ff a8 00 00 00 01 00 00 00 ................
>>>> 02 00 00 00 00 00 00 00 80 a1 7a c1 ff ff ff ff ..........z.....
>>>> backtrace:
>>>> [<000000000863775c>] __vmalloc_node mm/vmalloc.c:1795 [inline]
>>>> [<000000000863775c>] __vmalloc_node_flags mm/vmalloc.c:1809 [inline]
>>>> [<000000000863775c>] vmalloc+0x8c/0xb0 mm/vmalloc.c:1831
>>>> [<000000003f668111>] kernel_read_file+0x58f/0x7d0 fs/exec.c:924
>>>> [<000000002385813f>] kernel_read_file_from_fd+0x49/0x80 fs/exec.c:993
>>>> [<0000000011953ff1>] __do_sys_finit_module+0x13b/0x2a0 kernel/module.c:3895
>>>> [<000000006f58491f>] do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
>>>> [<00000000ee78baf4>] entry_SYSCALL_64_after_hwframe+0x49/0xbe
>>>> [<00000000241f889b>] 0xffffffffffffffff
>>>>
>>>> It should goto 'out_free' lable to free allocated buf while kernel_read
>>>> fails.
>>>
>>> Applied.
>>>
>>>
>>> This must be applied to stables as well...
>>
>>> It's already in all relevant stable trees...
>>
>> I only can see in longterm 4.19.
>>
>> What about 4.9 and 4.14?
>
> It was in the queue already for that (you can see it on git.kernel.org),
> and they are now part of the -rc releases that are currently out for
> review.
>
> thanks,
>
> greg k-h
>
Thanks!
Dmitry
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-03-13 14:56 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-19 2:10 [PATCH -next] exec: Fix mem leak in kernel_read_file YueHaibing
2019-02-19 2:25 ` Al Viro
2019-03-11 16:59 ` Dmitry Kasatkin
2019-03-11 23:16 ` Sasha Levin
2019-03-13 14:12 ` Dmitry Kasatkin
2019-03-13 14:38 ` gregkh
2019-03-13 15:00 ` Dmitry Kasatkin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).