lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <tip-b365a85c68161ea5db5476eb8845a91ceb1777ea@git.kernel.org>
Date:	Mon, 4 Oct 2010 20:24:16 GMT
From:	tip-bot for Dan Carpenter <error27@...il.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	linux-kernel@...r.kernel.org, hpa@...or.com, mingo@...hat.com,
	holt@....com, cpw@....com, error27@...il.com,
	akpm@...ux-foundation.org, steiner@....com, tglx@...utronix.de,
	mingo@...e.hu
Subject: [tip:x86/uv] x86, UV: Use allocated buffer in tlb_uv.c:tunables_read()

Commit-ID:  b365a85c68161ea5db5476eb8845a91ceb1777ea
Gitweb:     http://git.kernel.org/tip/b365a85c68161ea5db5476eb8845a91ceb1777ea
Author:     Dan Carpenter <error27@...il.com>
AuthorDate: Wed, 29 Sep 2010 10:41:05 +0200
Committer:  Ingo Molnar <mingo@...e.hu>
CommitDate: Thu, 30 Sep 2010 09:11:27 +0200

x86, UV: Use allocated buffer in tlb_uv.c:tunables_read()

The original code didn't check that the value returned from
snprintf() was less than the size of the buffer.  Although it
didn't cause a runtime bug in this case, it makes the static
checkers complain.

Andrew Morton suggested a dynamically sized buffer would be
cleaner.

Suggested-by: Andrew Morton <akpm@...ux-foundation.org>
Signed-off-by: Dan Carpenter <error27@...il.com>
Cc: Cliff Wickman <cpw@....com>
Cc: Jack Steiner <steiner@....com>
Cc: Robin Holt <holt@....com>
LKML-Reference: <20100929083118.GA6376@...ker>
Signed-off-by: Ingo Molnar <mingo@...e.hu>
---
 arch/x86/kernel/tlb_uv.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/tlb_uv.c b/arch/x86/kernel/tlb_uv.c
index 312ef02..33e77e4 100644
--- a/arch/x86/kernel/tlb_uv.c
+++ b/arch/x86/kernel/tlb_uv.c
@@ -1001,10 +1001,10 @@ static int uv_ptc_seq_show(struct seq_file *file, void *data)
 static ssize_t tunables_read(struct file *file, char __user *userbuf,
 						size_t count, loff_t *ppos)
 {
-	char buf[300];
+	char *buf;
 	int ret;
 
-	ret = snprintf(buf, 300, "%s %s %s\n%d %d %d %d %d %d %d %d %d\n",
+	buf = kasprintf(GFP_KERNEL, "%s %s %s\n%d %d %d %d %d %d %d %d %d\n",
 		"max_bau_concurrent plugged_delay plugsb4reset",
 		"timeoutsb4reset ipi_reset_limit complete_threshold",
 		"congested_response_us congested_reps congested_period",
@@ -1012,7 +1012,12 @@ static ssize_t tunables_read(struct file *file, char __user *userbuf,
 		timeoutsb4reset, ipi_reset_limit, complete_threshold,
 		congested_response_us, congested_reps, congested_period);
 
-	return simple_read_from_buffer(userbuf, count, ppos, buf, ret);
+	if (!buf)
+		return -ENOMEM;
+
+	ret = simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf));
+	kfree(buf);
+	return ret;
 }
 
 /*
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ