kernel-ark/fs
Chuck Ebbert ce51059be5 [PATCH] binfmt_elf: fix checks for bad address
Fix check for bad address; use macro instead of open-coding two checks.

Taken from RHEL4 kernel update.

From: Ernie Petrides <petrides@redhat.com>

  For background, the BAD_ADDR() macro should return TRUE if the address is
  TASK_SIZE, because that's the lowest address that is *not* valid for
  user-space mappings.  The macro was correct in binfmt_aout.c but was wrong
  for the "equal to" case in binfmt_elf.c.  There were two in-line validations
  of user-space addresses in binfmt_elf.c, which have been appropriately
  converted to use the corrected BAD_ADDR() macro in the patch you posted
  yesterday.  Note that the size checks against TASK_SIZE are okay as coded.

  The additional changes that I propose are below.  These are in the error
  paths for bad ELF entry addresses once load_elf_binary() has already
  committed to exec'ing the new image (following the tearing down of the
  task's original address space).

  The 1st hunk deals with the interp-side of the outer "if".  There were two
  problems here.  The printk() should be removed because this path can be
  triggered at will by a bogus interpreter image created and used by a
  malicious user.  Further, the error code should not be ENOEXEC, because that
  causes the loop in search_binary_handler() to continue trying other exec
  handlers (twice, in fact).  But it's too late for this to work correctly,
  because the user address space has already been torn down, and an exec()
  failure cannot be returned to the user code because the code no longer
  exists.  The only recovery is to force a SIGSEGV, but it's best to terminate
  the search loop immediately.  I somewhat arbitrarily chose EINVAL as a
  fallback error code, but any error returned by load_elf_interp() will
  override that (but this value will never be seen by user-space).

  The 2nd hunk deals with the non-interp-side of the outer "if".  There were
  two problems here as well.  The SIGSEGV needs to be forced, because a prior
  sigaction() syscall might have set the associated disposition to SIG_IGN.
  And the ENOEXEC should be changed to EINVAL as described above.

Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com>
Signed-off-by: Ernie Petrides <petrides@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2006-07-03 15:26:59 -07:00
..
9p Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
adfs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
affs
afs
autofs
autofs4
befs
bfs
cifs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
coda Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
configfs
cramfs
debugfs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
devpts
efs
exportfs
ext2 Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
ext3 Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
fat
freevxfs
fuse
hfs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
hfsplus Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
hostfs
hpfs
hppfs
hugetlbfs
isofs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
jbd
jffs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
jffs2 Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
jfs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
lockd Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
minix
msdos
ncpfs Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-06-30 15:39:30 -07:00
nfs [PATCH] nfs: non-procfs build fix 2006-07-02 15:10:20 -07:00
nfs_common
nfsd Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-06-30 15:39:30 -07:00
nls Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
ntfs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
ocfs2
openpromfs
partitions Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
proc Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-06-30 15:39:30 -07:00
qnx4 Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
ramfs
reiserfs [PATCH] reiserfs: update ctime and mtime on expanding truncate 2006-07-01 09:56:04 -07:00
romfs
smbfs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
sysfs
sysv
udf Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
ufs [PATCH] ufs: truncate should allocate block for last byte 2006-07-01 09:56:03 -07:00
vfat
xfs Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
aio.c
attr.c
bad_inode.c
binfmt_aout.c
binfmt_elf_fdpic.c
binfmt_elf.c [PATCH] binfmt_elf: fix checks for bad address 2006-07-03 15:26:59 -07:00
binfmt_em86.c
binfmt_flat.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
binfmt_misc.c
binfmt_script.c
binfmt_som.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
bio.c
block_dev.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
buffer.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-06-30 15:39:30 -07:00
char_dev.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
compat_ioctl.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
compat.c
dcache.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
dcookies.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
direct-io.c
dnotify.c
dquot.c
drop_caches.c
eventpoll.c
exec.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
fcntl.c
fifo.c
file_table.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
file.c
filesystems.c
fs-writeback.c [PATCH] zoned vm counters: conversion of nr_unstable to per zone counter 2006-06-30 11:25:36 -07:00
inode.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/bunk/trivial 2006-06-30 15:39:30 -07:00
inotify_user.c
inotify.c
ioctl.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
ioprio.c [PATCH] SELinux: Add security hook definition for getioprio and insert hooks 2006-06-30 11:25:37 -07:00
Kconfig
Kconfig.binfmt
libfs.c
locks.c
Makefile
mbcache.c
mpage.c
namei.c
namespace.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
nfsctl.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
open.c
pipe.c
pnode.c
pnode.h
posix_acl.c
quota_v1.c
quota_v2.c
quota.c
read_write.c
readdir.c
select.c
seq_file.c
splice.c
stat.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
super.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
sync.c
xattr_acl.c
xattr.c