]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/3.0.49/sunrpc-prevent-kernel-stack-corruption-on-long-values-of-flush.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 3.0.49 / sunrpc-prevent-kernel-stack-corruption-on-long-values-of-flush.patch
1 From 212ba90696ab4884e2025b0b13726d67aadc2cd4 Mon Sep 17 00:00:00 2001
2 From: Sasha Levin <levinsasha928@gmail.com>
3 Date: Tue, 17 Jul 2012 00:01:26 +0200
4 Subject: SUNRPC: Prevent kernel stack corruption on long values of flush
5
6 From: Sasha Levin <levinsasha928@gmail.com>
7
8 commit 212ba90696ab4884e2025b0b13726d67aadc2cd4 upstream.
9
10 The buffer size in read_flush() is too small for the longest possible values
11 for it. This can lead to a kernel stack corruption:
12
13 [ 43.047329] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffff833e64b4
14 [ 43.047329]
15 [ 43.049030] Pid: 6015, comm: trinity-child18 Tainted: G W 3.5.0-rc7-next-20120716-sasha #221
16 [ 43.050038] Call Trace:
17 [ 43.050435] [<ffffffff836c60c2>] panic+0xcd/0x1f4
18 [ 43.050931] [<ffffffff833e64b4>] ? read_flush.isra.7+0xe4/0x100
19 [ 43.051602] [<ffffffff810e94e6>] __stack_chk_fail+0x16/0x20
20 [ 43.052206] [<ffffffff833e64b4>] read_flush.isra.7+0xe4/0x100
21 [ 43.052951] [<ffffffff833e6500>] ? read_flush_pipefs+0x30/0x30
22 [ 43.053594] [<ffffffff833e652c>] read_flush_procfs+0x2c/0x30
23 [ 43.053596] [<ffffffff812b9a8c>] proc_reg_read+0x9c/0xd0
24 [ 43.053596] [<ffffffff812b99f0>] ? proc_reg_write+0xd0/0xd0
25 [ 43.053596] [<ffffffff81250d5b>] do_loop_readv_writev+0x4b/0x90
26 [ 43.053596] [<ffffffff81250fd6>] do_readv_writev+0xf6/0x1d0
27 [ 43.053596] [<ffffffff812510ee>] vfs_readv+0x3e/0x60
28 [ 43.053596] [<ffffffff812511b8>] sys_readv+0x48/0xb0
29 [ 43.053596] [<ffffffff8378167d>] system_call_fastpath+0x1a/0x1f
30
31 Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
32 Signed-off-by: J. Bruce Fields <bfields@redhat.com>
33 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
34
35 ---
36 net/sunrpc/cache.c | 4 ++--
37 1 file changed, 2 insertions(+), 2 deletions(-)
38
39 --- a/net/sunrpc/cache.c
40 +++ b/net/sunrpc/cache.c
41 @@ -1404,11 +1404,11 @@ static ssize_t read_flush(struct file *f
42 size_t count, loff_t *ppos,
43 struct cache_detail *cd)
44 {
45 - char tbuf[20];
46 + char tbuf[22];
47 unsigned long p = *ppos;
48 size_t len;
49
50 - sprintf(tbuf, "%lu\n", convert_to_wallclock(cd->flush_time));
51 + snprintf(tbuf, sizeof(tbuf), "%lu\n", convert_to_wallclock(cd->flush_time));
52 len = strlen(tbuf);
53 if (p >= len)
54 return 0;