mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Wright <chrisw@sous-sol.org>
To: linux-kernel@vger.kernel.org, stable@kernel.org, torvalds@osdl.org
Cc: Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Dave Jones <davej@redhat.com>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	akpm@osdl.org, alan@lxorguk.ukuu.org.uk, dhowells@redhat.com,
	davi.arnaut@gmail.com
Subject: [PATCH 13/23] Fix keyctl usage of strnlen_user()
Date: Tue, 07 Feb 2006 22:45:16 -0800	[thread overview]
Message-ID: <20060208064905.310066000@sorel.sous-sol.org> (raw)
In-Reply-To: <20060208064503.924238000@sorel.sous-sol.org>

[-- Attachment #1: fix-keyctl-usage-of-strnlen_user.patch --]
[-- Type: text/plain, Size: 2527 bytes --]

-stable review patch.  If anyone has any objections, please let us know.
------------------

In the small window between strnlen_user() and copy_from_user() userspace
could alter the terminating `\0' character.

Signed-off-by: Davi Arnaut <davi.arnaut@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
---

 security/keys/keyctl.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

Index: linux-2.6.15.3/security/keys/keyctl.c
===================================================================
--- linux-2.6.15.3.orig/security/keys/keyctl.c
+++ linux-2.6.15.3/security/keys/keyctl.c
@@ -66,9 +66,10 @@ asmlinkage long sys_add_key(const char _
 	description = kmalloc(dlen + 1, GFP_KERNEL);
 	if (!description)
 		goto error;
+	description[dlen] = '\0';
 
 	ret = -EFAULT;
-	if (copy_from_user(description, _description, dlen + 1) != 0)
+	if (copy_from_user(description, _description, dlen) != 0)
 		goto error2;
 
 	/* pull the payload in if one was supplied */
@@ -160,9 +161,10 @@ asmlinkage long sys_request_key(const ch
 	description = kmalloc(dlen + 1, GFP_KERNEL);
 	if (!description)
 		goto error;
+	description[dlen] = '\0';
 
 	ret = -EFAULT;
-	if (copy_from_user(description, _description, dlen + 1) != 0)
+	if (copy_from_user(description, _description, dlen) != 0)
 		goto error2;
 
 	/* pull the callout info into kernel space */
@@ -181,9 +183,10 @@ asmlinkage long sys_request_key(const ch
 		callout_info = kmalloc(dlen + 1, GFP_KERNEL);
 		if (!callout_info)
 			goto error2;
+		callout_info[dlen] = '\0';
 
 		ret = -EFAULT;
-		if (copy_from_user(callout_info, _callout_info, dlen + 1) != 0)
+		if (copy_from_user(callout_info, _callout_info, dlen) != 0)
 			goto error3;
 	}
 
@@ -278,9 +281,10 @@ long keyctl_join_session_keyring(const c
 		name = kmalloc(nlen + 1, GFP_KERNEL);
 		if (!name)
 			goto error;
+		name[nlen] = '\0';
 
 		ret = -EFAULT;
-		if (copy_from_user(name, _name, nlen + 1) != 0)
+		if (copy_from_user(name, _name, nlen) != 0)
 			goto error2;
 	}
 
@@ -582,9 +586,10 @@ long keyctl_keyring_search(key_serial_t 
 	description = kmalloc(dlen + 1, GFP_KERNEL);
 	if (!description)
 		goto error;
+	description[dlen] = '\0';
 
 	ret = -EFAULT;
-	if (copy_from_user(description, _description, dlen + 1) != 0)
+	if (copy_from_user(description, _description, dlen) != 0)
 		goto error2;
 
 	/* get the keyring at which to begin the search */

--

  parent reply	other threads:[~2006-02-08  6:50 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-02-08  6:45 [PATCH 00/23] -stable review Chris Wright
2006-02-08  6:45 ` [PATCH 01/23] SCSI: turn off ordered flush barriers Chris Wright
2006-02-08  6:45 ` [PATCH 02/23] [PATCH] dm-crypt: zero key before freeing it Chris Wright
2006-02-08  6:45 ` [PATCH 03/23] [PATCH] d_instantiate_unique / NFS inode leakage Chris Wright
2006-02-08  6:45 ` [PATCH 04/23] seclvl settime fix Chris Wright
2006-02-08  6:45 ` [PATCH 05/23] [XFS] fix regression in xfs_buf_rele Chris Wright
2006-02-08  6:45 ` [PATCH 06/23] Input: mousedev - fix memory leak Chris Wright
2006-02-08  6:45 ` [PATCH 07/23] Input: grip - fix crash when accessing device Chris Wright
2006-02-08  6:45 ` [PATCH 08/23] Input: db9 - fix possible crash with Saturn gamepads Chris Wright
2006-02-08  6:45 ` [PATCH 09/23] Input: sidewinder - fix an oops Chris Wright
2006-02-08  6:45 ` [PATCH 10/23] Input: iforce - do not return ENOMEM upon successful allocation Chris Wright
2006-02-08  6:45 ` [PATCH 11/23] Input: iforce - fix detection of USB devices Chris Wright
2006-02-08  6:45 ` [PATCH 12/23] [SPARC64]: Kill compat_sys_clock_settime sign extension stub Chris Wright
2006-02-08  6:45 ` Chris Wright [this message]
2006-02-08  6:45 ` [PATCH 14/23] [PATCH] PCMCIA=m, HOSTAP_CS=y is not a legal configuration Chris Wright
2006-02-08  6:45 ` [PATCH 15/23] [PATCH] SELinux: fix size-128 slab leak Chris Wright
2006-02-08  6:45 ` [PATCH 16/23] [PPP]: Fixed hardware RX checksum handling Chris Wright
2006-02-08  6:45 ` [PATCH 17/23] [PATCH] x86_64: Let impossible CPUs point to reference per cpu data Chris Wright
2006-02-08  6:45 ` [PATCH 18/23] [PATCH] x86_64: Clear more state when ignoring empty node in SRAT parsing Chris Wright
2006-02-08  6:45 ` [PATCH 19/23] [PATCH] bridge: netfilter races on device removal Chris Wright
2006-02-08  6:45 ` [PATCH 20/23] [PATCH] bridge: fix RCU race " Chris Wright
2006-02-08  6:45 ` [PATCH 21/23] [ALSA] emu10k1 - Fix the confliction of Front control Chris Wright
2006-02-08  6:45 ` [PATCH 22/23] [PATCH] x86_64: Dont record local apic ids when they are disabled in MADT Chris Wright
2006-02-08  6:45 ` [PATCH 23/23] [alpha] __cmpxchg() must really always be inlined Chris Wright
2006-02-08 10:07 ` [PATCH 13/23] Fix keyctl usage of strnlen_user() David Howells
2006-02-08 23:39 ` [PATCH 24/23] md: remove slashes from disk names when creation dev names in sysfs Chris Wright

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=20060208064905.310066000@sorel.sous-sol.org \
    --to=chrisw@sous-sol.org \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=chuckw@quantumlinux.com \
    --cc=davej@redhat.com \
    --cc=davi.arnaut@gmail.com \
    --cc=dhowells@redhat.com \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rdunlap@xenotime.net \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    --cc=tytso@mit.edu \
    --cc=zwane@arm.linux.org.uk \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®