https://github.com/torvalds/linux
Revision 28f300d23674fa01ae747c66ce861d4ee6aebe8c authored by Pavel Emelyanov on 19 September 2007, 05:46:45 UTC, committed by Linus Torvalds on 19 September 2007, 18:24:18 UTC
It turned out, that the user namespace is released during the do_exit() in
exit_task_namespaces(), but the struct user_struct is released only during the
put_task_struct(), i.e.  MUCH later.

On debug kernels with poisoned slabs this will cause the oops in
uid_hash_remove() because the head of the chain, which resides inside the
struct user_namespace, will be already freed and poisoned.

Since the uid hash itself is required only when someone can search it, i.e.
when the namespace is alive, we can safely unhash all the user_struct-s from
it during the namespace exiting.  The subsequent free_uid() will complete the
user_struct destruction.

For example simple program

   #include <sched.h>

   char stack[2 * 1024 * 1024];

   int f(void *foo)
   {
   	return 0;
   }

   int main(void)
   {
   	clone(f, stack + 1 * 1024 * 1024, 0x10000000, 0);
   	return 0;
   }

run on kernel with CONFIG_USER_NS turned on will oops the
kernel immediately.

This was spotted during OpenVZ kernel testing.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: Alexey Dobriyan <adobriyan@openvz.org>
Acked-by: "Serge E. Hallyn" <serue@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 735de22
History
Tip revision: 28f300d23674fa01ae747c66ce861d4ee6aebe8c authored by Pavel Emelyanov on 19 September 2007, 05:46:45 UTC
Fix user namespace exiting OOPs
Tip revision: 28f300d
File Mode Size
9p
adfs
affs
afs
autofs
autofs4
befs
bfs
cifs
coda
configfs
cramfs
debugfs
devpts
dlm
ecryptfs
efs
exportfs
ext2
ext3
ext4
fat
freevxfs
fuse
gfs2
hfs
hfsplus
hostfs
hpfs
hppfs
hugetlbfs
isofs
jbd
jbd2
jffs2
jfs
lockd
minix
msdos
ncpfs
nfs
nfs_common
nfsd
nls
ntfs
ocfs2
openpromfs
partitions
proc
qnx4
ramfs
reiserfs
romfs
smbfs
sysfs
sysv
udf
ufs
vfat
xfs
Kconfig -rw-r--r-- 74.2 KB
Kconfig.binfmt -rw-r--r-- 5.3 KB
Makefile -rw-r--r-- 3.7 KB
aio.c -rw-r--r-- 45.6 KB
anon_inodes.c -rw-r--r-- 5.1 KB
attr.c -rw-r--r-- 4.1 KB
bad_inode.c -rw-r--r-- 7.8 KB
binfmt_aout.c -rw-r--r-- 15.2 KB
binfmt_elf.c -rw-r--r-- 47.7 KB
binfmt_elf_fdpic.c -rw-r--r-- 47.4 KB
binfmt_em86.c -rw-r--r-- 2.8 KB
binfmt_flat.c -rw-r--r-- 26.5 KB
binfmt_misc.c -rw-r--r-- 15.5 KB
binfmt_script.c -rw-r--r-- 2.7 KB
binfmt_som.c -rw-r--r-- 7.8 KB
bio.c -rw-r--r-- 29.0 KB
block_dev.c -rw-r--r-- 34.8 KB
buffer.c -rw-r--r-- 80.5 KB
char_dev.c -rw-r--r-- 13.2 KB
compat.c -rw-r--r-- 53.8 KB
compat_ioctl.c -rw-r--r-- 104.4 KB
dcache.c -rw-r--r-- 55.5 KB
dcookies.c -rw-r--r-- 6.4 KB
direct-io.c -rw-r--r-- 34.4 KB
dnotify.c -rw-r--r-- 4.3 KB
dquot.c -rw-r--r-- 53.0 KB
drop_caches.c -rw-r--r-- 1.4 KB
eventfd.c -rw-r--r-- 5.1 KB
eventpoll.c -rw-r--r-- 36.9 KB
exec.c -rw-r--r-- 40.8 KB
fcntl.c -rw-r--r-- 14.2 KB
fifo.c -rw-r--r-- 3.1 KB
file.c -rw-r--r-- 6.2 KB
file_table.c -rw-r--r-- 6.8 KB
filesystems.c -rw-r--r-- 5.5 KB
fs-writeback.c -rw-r--r-- 20.0 KB
generic_acl.c -rw-r--r-- 4.2 KB
inode.c -rw-r--r-- 37.4 KB
inotify.c -rw-r--r-- 19.3 KB
inotify_user.c -rw-r--r-- 17.4 KB
internal.h -rw-r--r-- 934 bytes
ioctl.c -rw-r--r-- 3.7 KB
ioprio.c -rw-r--r-- 4.7 KB
libfs.c -rw-r--r-- 16.0 KB
locks.c -rw-r--r-- 57.5 KB
mbcache.c -rw-r--r-- 18.3 KB
mpage.c -rw-r--r-- 20.3 KB
namei.c -rw-r--r-- 68.8 KB
namespace.c -rw-r--r-- 46.6 KB
nfsctl.c -rw-r--r-- 2.4 KB
no-block.c -rw-r--r-- 663 bytes
open.c -rw-r--r-- 26.1 KB
pipe.c -rw-r--r-- 24.4 KB
pnode.c -rw-r--r-- 7.6 KB
pnode.h -rw-r--r-- 1006 bytes
posix_acl.c -rw-r--r-- 8.5 KB
quota.c -rw-r--r-- 12.2 KB
quota_v1.c -rw-r--r-- 5.7 KB
quota_v2.c -rw-r--r-- 20.1 KB
read_write.c -rw-r--r-- 17.9 KB
read_write.h -rw-r--r-- 542 bytes
readdir.c -rw-r--r-- 6.8 KB
select.c -rw-r--r-- 20.4 KB
seq_file.c -rw-r--r-- 10.3 KB
signalfd.c -rw-r--r-- 9.6 KB
splice.c -rw-r--r-- 39.9 KB
stack.c -rw-r--r-- 1.1 KB
stat.c -rw-r--r-- 10.6 KB
super.c -rw-r--r-- 22.1 KB
sync.c -rw-r--r-- 7.0 KB
timerfd.c -rw-r--r-- 5.0 KB
utimes.c -rw-r--r-- 4.8 KB
xattr.c -rw-r--r-- 13.8 KB
xattr_acl.c -rw-r--r-- 2.3 KB

back to top