netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush
@ 2012-07-16 22:01 Sasha Levin
  2012-07-18 17:39 ` J. Bruce Fields
  0 siblings, 1 reply; 12+ messages in thread
From: Sasha Levin @ 2012-07-16 22:01 UTC (permalink / raw)
  To: Trond.Myklebust, bfields, davem
  Cc: davej, linux-nfs, netdev, linux-kernel, Sasha Levin

The buffer size in read_flush() is too small for the longest possible values
for it. This can lead to a kernel stack corruption:

[   43.047329] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffff833e64b4
[   43.047329]
[   43.049030] Pid: 6015, comm: trinity-child18 Tainted: G        W    3.5.0-rc7-next-20120716-sasha #221
[   43.050038] Call Trace:
[   43.050435]  [<ffffffff836c60c2>] panic+0xcd/0x1f4
[   43.050931]  [<ffffffff833e64b4>] ? read_flush.isra.7+0xe4/0x100
[   43.051602]  [<ffffffff810e94e6>] __stack_chk_fail+0x16/0x20
[   43.052206]  [<ffffffff833e64b4>] read_flush.isra.7+0xe4/0x100
[   43.052951]  [<ffffffff833e6500>] ? read_flush_pipefs+0x30/0x30
[   43.053594]  [<ffffffff833e652c>] read_flush_procfs+0x2c/0x30
[   43.053596]  [<ffffffff812b9a8c>] proc_reg_read+0x9c/0xd0
[   43.053596]  [<ffffffff812b99f0>] ? proc_reg_write+0xd0/0xd0
[   43.053596]  [<ffffffff81250d5b>] do_loop_readv_writev+0x4b/0x90
[   43.053596]  [<ffffffff81250fd6>] do_readv_writev+0xf6/0x1d0
[   43.053596]  [<ffffffff812510ee>] vfs_readv+0x3e/0x60
[   43.053596]  [<ffffffff812511b8>] sys_readv+0x48/0xb0
[   43.053596]  [<ffffffff8378167d>] system_call_fastpath+0x1a/0x1f

Signed-off-by: Sasha Levin <levinsasha928@gmail.com>
---
 net/sunrpc/cache.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c
index 2afd2a8..f86d95e 100644
--- a/net/sunrpc/cache.c
+++ b/net/sunrpc/cache.c
@@ -1409,11 +1409,11 @@ static ssize_t read_flush(struct file *file, char __user *buf,
 			  size_t count, loff_t *ppos,
 			  struct cache_detail *cd)
 {
-	char tbuf[20];
+	char tbuf[22];
 	unsigned long p = *ppos;
 	size_t len;
 
-	sprintf(tbuf, "%lu\n", convert_to_wallclock(cd->flush_time));
+	snprintf(tbuf, sizeof(tbuf), "%lu\n", convert_to_wallclock(cd->flush_time));
 	len = strlen(tbuf);
 	if (p >= len)
 		return 0;
-- 
1.7.8.6

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-10-18  8:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-16 22:01 [PATCH] SUNRPC: Prevent kernel stack corruption on long values of flush Sasha Levin
2012-07-18 17:39 ` J. Bruce Fields
2012-07-18 20:00   ` Jim Rees
     [not found]     ` <20120718200049.GA17964-63aXycvo3TyHXe+LvDLADg@public.gmane.org>
2012-07-18 20:33       ` Dave Jones
     [not found]         ` <20120718203304.GA18540-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2012-07-18 20:55           ` Jim Rees
     [not found]             ` <20120718205510.GA18374-63aXycvo3TyHXe+LvDLADg@public.gmane.org>
2012-10-17 18:29               ` Boaz Harrosh
     [not found]                 ` <507EF918.5030004-C4P08NqkoRlBDgjK7y7TUQ@public.gmane.org>
2012-10-18  8:34                   ` David Laight
2012-07-18 21:08       ` J. Bruce Fields
     [not found]         ` <50072BA7.6070205@gmail.com>
     [not found]           ` <50072BA7.6070205-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-07-18 21:43             ` Sasha Levin
     [not found]               ` <50072DEE.2000205-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2012-07-18 23:04                 ` Jim Rees
     [not found]   ` <20120718173913.GA1298-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>
2012-10-17 17:59     ` Sasha Levin
     [not found]       ` <CA+1xoqcgWTP8pAY3Ok2R0JM-ZXSkGroEvAFcqP0KaK=dABiTXA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-10-17 19:02         ` J. Bruce Fields

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).