public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] tlb_uv: handle large snprintf() returns
@ 2010-08-16 10:55 Dan Carpenter
  2010-09-27 23:12 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2010-08-16 10:55 UTC (permalink / raw)
  To: Thomas Gleixner
  Cc: Ingo Molnar, H. Peter Anvin, x86, Cliff Wickman, Jack Steiner,
	Robin Holt, linux-kernel, kernel-janitors

snprintf() returns the number of bytes that *would* have been copied if
the buffer was large enough, so it can be larger than the size of the
buffer.  In this case it's ok, but let's put a cap on it anyway so it's
easier to audit.

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c
index 312ef02..5e88b3a 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/kernel/tlb_uv.c
@@ -1012,6 +1012,9 @@ static ssize_t tunables_read(struct file *file, char __user *userbuf,
 		timeoutsb4reset, ipi_reset_limit, complete_threshold,
 		congested_response_us, congested_reps, congested_period);
 
+	if (ret > 300)
+		ret = 300;
+
 	return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
 }
 

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

end of thread, other threads:[~2010-10-04 20:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-16 10:55 [patch] tlb_uv: handle large snprintf() returns Dan Carpenter
2010-09-27 23:12 ` Andrew Morton
2010-09-29  8:41   ` [patch v2] tlb_uv: use allocated buffer in tunables_read() Dan Carpenter
2010-10-04 20:24     ` [tip:x86/uv] x86, UV: Use allocated buffer in tlb_uv.c:tunables_read() tip-bot for Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox