mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ben Hutchings <ben@decadent.org.uk>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Kees Cook <keescook@chromium.org>,
	PaX Team <pageexec@freemail.hu>, Andi Kleen <ak@linux.intel.com>,
	Brad Spengler <spender@grsecurity.net>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: [ 064/105] kernel/sys.c: fix stack memory content leak via UNAME26
Date: Sun, 28 Oct 2012 23:16:40 +0000	[thread overview]
Message-ID: <20121028231556.720251581@decadent.org.uk> (raw)
In-Reply-To: <20121028231536.970033833@decadent.org.uk>

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

------------------

From: Kees Cook <keescook@chromium.org>

commit 2702b1526c7278c4d65d78de209a465d4de2885e upstream.

Calling uname() with the UNAME26 personality set allows a leak of kernel
stack contents.  This fixes it by defensively calculating the length of
copy_to_user() call, making the len argument unsigned, and initializing
the stack buffer to zero (now technically unneeded, but hey, overkill).

CVE-2012-0957

Reported-by: PaX Team <pageexec@freemail.hu>
Signed-off-by: Kees Cook <keescook@chromium.org>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: PaX Team <pageexec@freemail.hu>
Cc: Brad Spengler <spender@grsecurity.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
---
 kernel/sys.c |   12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index c5cb5b9..01865c6 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1265,15 +1265,16 @@ DECLARE_RWSEM(uts_sem);
  * Work around broken programs that cannot handle "Linux 3.0".
  * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
  */
-static int override_release(char __user *release, int len)
+static int override_release(char __user *release, size_t len)
 {
 	int ret = 0;
-	char buf[65];
 
 	if (current->personality & UNAME26) {
-		char *rest = UTS_RELEASE;
+		const char *rest = UTS_RELEASE;
+		char buf[65] = { 0 };
 		int ndots = 0;
 		unsigned v;
+		size_t copy;
 
 		while (*rest) {
 			if (*rest == '.' && ++ndots >= 3)
@@ -1283,8 +1284,9 @@ static int override_release(char __user *release, int len)
 			rest++;
 		}
 		v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
-		snprintf(buf, len, "2.6.%u%s", v, rest);
-		ret = copy_to_user(release, buf, len);
+		copy = min(sizeof(buf), max_t(size_t, 1, len));
+		copy = scnprintf(buf, copy, "2.6.%u%s", v, rest);
+		ret = copy_to_user(release, buf, copy + 1);
 	}
 	return ret;
 }



  parent reply	other threads:[~2012-10-28 23:40 UTC|newest]

Thread overview: 110+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-28 23:15 [ 000/105] 3.2.33-stable review Ben Hutchings
2012-10-28 23:15 ` [ 001/105] netfilter: ipset: avoid use of kernel-only types Ben Hutchings
2012-10-28 23:15 ` [ 002/105] samsung-laptop: dont handle backlight if handled by acpi/video Ben Hutchings
2012-10-28 23:15 ` [ 003/105] samsung-laptop: make the dmi check less strict (part 2) Ben Hutchings
2012-10-28 23:15 ` [ 004/105] jbd: Fix assertion failure in commit code due to lacking transaction credits Ben Hutchings
2012-10-28 23:15 ` [ 005/105] mtd: nand: allow NAND_NO_SUBPAGE_WRITE to be set from driver Ben Hutchings
2012-10-28 23:15 ` [ 006/105] ALSA: hda - Fix oops caused by recent commit "Fix internal mic for Lenovo Ideapad U300s" Ben Hutchings
2012-10-28 23:15 ` [ 007/105] e1000: fix vlan processing regression Ben Hutchings
2012-10-28 23:15 ` [ 008/105] SUNRPC: Set alloc_slot for backchannel tcp ops Ben Hutchings
2012-10-28 23:15 ` [ 009/105] drm/i915: dont pwrite tiled objects through the gtt Ben Hutchings
2012-10-28 23:15 ` [ 010/105] drm/i915: no lvds quirk for Zotac ZDBOX SD ID12/ID13 Ben Hutchings
2012-10-28 23:15 ` [ 011/105] sparc64: fix ptrace interaction with force_successful_syscall_return() Ben Hutchings
2012-10-28 23:15 ` [ 012/105] sparc64: Like x86 we should check current->mm during perf backtrace generation Ben Hutchings
2012-10-28 23:15 ` [ 013/105] sparc64: Fix bit twiddling in sparc_pmu_enable_event() Ben Hutchings
2012-10-28 23:15 ` [ 014/105] sparc64: do not clobber personality flags in sys_sparc64_personality() Ben Hutchings
2012-10-28 23:15 ` [ 015/105] sparc64: Be less verbose during vmemmap population Ben Hutchings
2012-10-28 23:15 ` [ 016/105] [media] au0828: fix case where STREAMOFF being called on stopped stream causes BUG() Ben Hutchings
2012-10-28 23:15 ` [ 017/105] net: Fix skb_under_panic oops in neigh_resolve_output Ben Hutchings
2012-10-28 23:15 ` [ 018/105] skge: Add DMA mask quirk for Marvell 88E8001 on ASUS P5NSLI motherboard Ben Hutchings
2012-10-28 23:15 ` [ 019/105] vlan: dont deliver frames for unknown vlans to protocols Ben Hutchings
2012-10-28 23:15 ` [ 020/105] RDS: fix rds-ping spinlock recursion Ben Hutchings
2012-10-28 23:15 ` [ 021/105] tcp: resets are misrouted Ben Hutchings
2012-10-28 23:15 ` [ 022/105] staging: comedi: amplc_pc236: fix invalid register access during detach Ben Hutchings
2012-10-28 23:15 ` [ 023/105] nfsd4: fix nfs4 stateid leak Ben Hutchings
2012-10-28 23:16 ` [ 024/105] viafb: dont touch clock state on OLPC XO-1.5 Ben Hutchings
2012-10-28 23:16 ` [ 025/105] module: taint kernel when lve module is loaded Ben Hutchings
2012-10-28 23:16 ` [ 026/105] ACPI: EC: Make the GPE storm threshold a module parameter Ben Hutchings
2012-10-29  0:04   ` Jonathan Nieder
2012-10-28 23:16 ` [ 027/105] ACPI: EC: Add a quirk for CLEVO M720T/M730T laptop Ben Hutchings
2012-10-28 23:16 ` [ 028/105] ARM: vfp: fix saving d16-d31 vfp registers on v6+ kernels Ben Hutchings
2012-10-28 23:16 ` [ 029/105] [SCSI] scsi_debug: Fix off-by-one bug when unmapping region Ben Hutchings
2012-10-28 23:16 ` [ 030/105] [SCSI] storvsc: Account for in-transit packets in the RESET path Ben Hutchings
2012-10-28 23:16 ` [ 031/105] timers: Fix endless looping between cascade() and internal_add_timer() Ben Hutchings
2012-10-28 23:16 ` [ 032/105] timekeeping: Cast raw_interval to u64 to avoid shift overflow Ben Hutchings
2012-10-28 23:16 ` [ 033/105] video/udlfb: fix line counting in fb_write Ben Hutchings
2012-10-28 23:16 ` [ 034/105] tmpfs,ceph,gfs2,isofs,reiserfs,xfs: fix fh_len checking Ben Hutchings
2012-10-28 23:16 ` [ 035/105] ext4: race-condition protection for ext4_convert_unwritten_extents_endio Ben Hutchings
2012-10-28 23:16 ` [ 036/105] ALSA: hda - Fix memory leaks at error path in patch_cirrus.c Ben Hutchings
2012-10-28 23:16 ` [ 037/105] nohz: Fix idle ticks in cpu summary line of /proc/stat Ben Hutchings
2012-10-28 23:16 ` [ 038/105] ALSA: hda - do not detect jack on internal speakers for Realtek Ben Hutchings
2012-10-28 23:16 ` [ 039/105] pktgen: fix crash when generating IPv6 packets Ben Hutchings
2012-10-28 23:16 ` [ 040/105] md/raid10: use correct limit variable Ben Hutchings
2012-10-28 23:16 ` [ 041/105] Bluetooth: SMP: Fix setting unknown auth_req bits Ben Hutchings
2012-10-28 23:16 ` [ 042/105] mips,kgdb: fix recursive page fault with CONFIG_KPROBES Ben Hutchings
2012-10-28 23:16 ` [ 043/105] xen/bootup: allow read_tscp call for Xen PV guests Ben Hutchings
2012-10-28 23:16 ` [ 044/105] xen/bootup: allow {read|write}_cr8 pvops call Ben Hutchings
2012-10-28 23:16 ` [ 045/105] pcmcia: sharpsl: dont discard sharpsl_pcmcia_ops Ben Hutchings
2012-10-28 23:16 ` [ 046/105] oprofile, x86: Fix wrapping bug in op_x86_get_ctrl() Ben Hutchings
2012-10-28 23:16 ` [ 047/105] drm/radeon: Dont destroy I2C Bus Rec in radeon_ext_tmds_enc_destroy() Ben Hutchings
2012-10-28 23:16 ` [ 048/105] mac80211: check if key has TKIP type before updating IV Ben Hutchings
2012-10-28 23:16 ` [ 049/105] bcma: fix unregistration of cores Ben Hutchings
2012-10-28 23:16 ` [ 050/105] net/wireless: ipw2200: Fix panic occurring in ipw_handle_promiscuous_tx() Ben Hutchings
2012-10-28 23:16 ` [ 051/105] iwlwifi: fix 6000 series channel switch command Ben Hutchings
2012-10-28 23:16 ` [ 052/105] cgroup: notify_on_release may not be triggered in some cases Ben Hutchings
2012-10-28 23:16 ` [ 053/105] ALSA: hda - Always check array bounds in alc_get_line_out_pfx Ben Hutchings
2012-10-28 23:16 ` [ 054/105] NLM: nlm_lookup_file() may return NLMv4-specific error codes Ben Hutchings
2012-10-28 23:16 ` [ 055/105] SUNRPC: Prevent kernel stack corruption on long values of flush Ben Hutchings
2012-10-28 23:16 ` [ 056/105] USB: cdc-acm: fix pipe type of write endpoint Ben Hutchings
2012-10-28 23:16 ` [ 057/105] usb: acm: fix the computation of the number of data bits Ben Hutchings
2012-10-28 23:16 ` [ 058/105] usb: host: xhci: New system added for Compliance Mode Patch on SN65LVPE502CP Ben Hutchings
2012-10-28 23:16 ` [ 059/105] USB: option: blacklist net interface on ZTE devices Ben Hutchings
2012-10-28 23:16 ` [ 060/105] USB: option: add more " Ben Hutchings
2012-10-28 23:16 ` [ 061/105] s390: fix linker script for 31 bit builds Ben Hutchings
2012-10-28 23:16 ` [ 062/105] xen/x86: dont corrupt %eip when returning from a signal handler Ben Hutchings
2012-10-28 23:16 ` [ 063/105] ALSA: hda - add dock support for Thinkpad T430 Ben Hutchings
2012-10-28 23:16 ` Ben Hutchings [this message]
2012-10-28 23:16 ` [ 065/105] ARM: 7559/1: smp: switch away from the idmap before updating init_mm.mm_count Ben Hutchings
2012-10-28 23:16 ` [ 066/105] usb hub: send clear_tt_buffer_complete events when canceling TT clear work Ben Hutchings
2012-10-28 23:16 ` [ 067/105] cpufreq / powernow-k8: Remove usage of smp_processor_id() in preemptible code Ben Hutchings
2012-10-28 23:16 ` [ 068/105] arch/tile: avoid generating .eh_frame information in modules Ben Hutchings
2012-10-28 23:16 ` [ 069/105] amd64_edac:__amd64_set_scrub_rate(): avoid overindexing scrubrates[] Ben Hutchings
2012-10-28 23:16 ` [ 070/105] SUNRPC: Clear the connect flag when socket state is TCP_CLOSE_WAIT Ben Hutchings
2012-10-28 23:16 ` [ 071/105] Revert "SUNRPC: Ensure we close the socket on EPIPE errors too..." Ben Hutchings
2012-10-28 23:16 ` [ 072/105] SUNRPC: Prevent races in xs_abort_connection() Ben Hutchings
2012-10-28 23:16 ` [ 073/105] SUNRPC: Get rid of the xs_error_report socket callback Ben Hutchings
2012-10-28 23:16 ` [ 074/105] Revert "ath9k_hw: Updated AR9003 tx gain table for 5GHz" Ben Hutchings
2012-10-28 23:16 ` [ 075/105] USB: serial: Fix memory leak in sierra_release() Ben Hutchings
2012-10-28 23:16 ` [ 076/105] usb-storage: add unusual_devs entry for Casio EX-N1 digital camera Ben Hutchings
2012-10-28 23:16 ` [ 077/105] Drivers: hv: Cleanup error handling in vmbus_open() Ben Hutchings
2012-10-28 23:16 ` [ 078/105] sysfs: sysfs_pathname/sysfs_add_one: Use strlcat() instead of strcat() Ben Hutchings
2012-10-28 23:16 ` [ 079/105] vhost: fix mergeable bufs on BE hosts Ben Hutchings
2012-10-28 23:16 ` [ 080/105] USB: whiteheat: fix memory leak in error path Ben Hutchings
2012-10-28 23:16 ` [ 081/105] USB: opticon: fix DMA from stack Ben Hutchings
2012-10-28 23:16 ` [ 082/105] USB: opticon: fix memory leak in error path Ben Hutchings
2012-10-28 23:16 ` [ 083/105] USB: mct_u232: fix broken close Ben Hutchings
2012-10-28 23:17 ` [ 084/105] USB: sierra: fix memory leak in attach error path Ben Hutchings
2012-10-28 23:17 ` [ 085/105] USB: sierra: fix memory leak in probe " Ben Hutchings
2012-10-28 23:17 ` [ 086/105] USB: mos7840: fix urb leak at release Ben Hutchings
2012-10-28 23:17 ` [ 087/105] USB: mos7840: fix port-device leak in error path Ben Hutchings
2012-10-28 23:17 ` [ 088/105] USB: mos7840: remove NULL-urb submission Ben Hutchings
2012-10-28 23:17 ` [ 089/105] USB: mos7840: remove invalid disconnect handling Ben Hutchings
2012-10-28 23:17 ` [ 090/105] ehci: fix Lucid nohandoff pci quirk to be more generic with BIOS versions Ben Hutchings
2012-10-28 23:17 ` [ 091/105] ehci: Add yet-another Lucid nohandoff pci quirk Ben Hutchings
2012-10-28 23:17 ` [ 092/105] xhci: Fix potential NULL ptr deref in command cancellation Ben Hutchings
2012-10-28 23:17 ` [ 093/105] freezer: exec should clear PF_NOFREEZE along with PF_KTHREAD Ben Hutchings
2012-10-28 23:17 ` [ 094/105] mm: fix XFS oops due to dirty pages without buffers on s390 Ben Hutchings
2012-10-28 23:17 ` [ 095/105] genalloc: stop crashing the system when destroying a pool Ben Hutchings
2012-10-28 23:17 ` [ 096/105] drivers/rtc/rtc-imxdi.c: add missing spin lock initialization Ben Hutchings
2012-10-28 23:17 ` [ 097/105] gen_init_cpio: avoid stack overflow when expanding Ben Hutchings
2012-10-28 23:17 ` [ 098/105] fs/compat_ioctl.c: VIDEO_SET_SPU_PALETTE missing error check Ben Hutchings
2012-10-28 23:17 ` [ 099/105] Revert "lockd: use rpc clients cl_nodename for id encoding" Ben Hutchings
2012-10-28 23:17 ` [ 100/105] netfilter: nf_conntrack: fix racy timer handling with reliable events Ben Hutchings
2012-10-28 23:17 ` [ 101/105] tpm: Propagate error from tpm_transmit to fix a timeout hang Ben Hutchings
2012-10-28 23:17 ` [ 102/105] usb: gadget: at91_udc: fix dt support Ben Hutchings
2012-10-29  6:21   ` Fabio Porcedda
2012-10-29 14:41     ` Ben Hutchings
2012-10-28 23:17 ` [ 103/105] ALSA: ac97 - Fix missing NULL check in snd_ac97_cvol_new() Ben Hutchings
2012-10-28 23:17 ` [ 104/105] ALSA: emu10k1: add chip details for E-mu 1010 PCIe card Ben Hutchings
2012-10-28 23:17 ` [ 105/105] Add CDC-ACM support for the CX93010-2x UCMxx USB Modem Ben Hutchings
2012-10-29  2:24 ` [ 000/105] 3.2.33-stable review Ben Hutchings

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=20121028231556.720251581@decadent.org.uk \
    --to=ben@decadent.org.uk \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pageexec@freemail.hu \
    --cc=spender@grsecurity.net \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome