From: Dan Carpenter <error27@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Cliff Wickman <cpw@sgi.com>,
Jack Steiner <steiner@sgi.com>, Robin Holt <holt@sgi.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] tlb_uv: handle large snprintf() returns
Date: Mon, 16 Aug 2010 10:55:02 +0000 [thread overview]
Message-ID: <20100816105502.GC645@bicker> (raw)
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);
}
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>,
x86@kernel.org, Cliff Wickman <cpw@sgi.com>,
Jack Steiner <steiner@sgi.com>, Robin Holt <holt@sgi.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] tlb_uv: handle large snprintf() returns
Date: Mon, 16 Aug 2010 12:55:02 +0200 [thread overview]
Message-ID: <20100816105502.GC645@bicker> (raw)
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);
}
next reply other threads:[~2010-08-16 10:55 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-16 10:55 Dan Carpenter [this message]
2010-08-16 10:55 ` [patch] tlb_uv: handle large snprintf() returns Dan Carpenter
2010-09-27 23:12 ` Andrew Morton
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-09-29 8:41 ` 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20100816105502.GC645@bicker \
--to=error27@gmail.com \
--cc=cpw@sgi.com \
--cc=holt@sgi.com \
--cc=hpa@zytor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=steiner@sgi.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.