Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

CRED: Fix kernel panic upon security_file_alloc() failure.

In get_empty_filp() since 2.6.29, file_free(f) is called with f->f_cred == NULL
when security_file_alloc() returned an error. As a result, kernel will panic()
due to put_cred(NULL) call within RCU callback.

Fix this bug by assigning f->f_cred before calling security_file_alloc().

Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Tetsuo Handa and committed by
Linus Torvalds
78d29788 bb5b583b

+1 -1
+1 -1
fs/file_table.c
··· 125 125 goto fail; 126 126 127 127 percpu_counter_inc(&nr_files); 128 + f->f_cred = get_cred(cred); 128 129 if (security_file_alloc(f)) 129 130 goto fail_sec; 130 131 131 132 INIT_LIST_HEAD(&f->f_u.fu_list); 132 133 atomic_long_set(&f->f_count, 1); 133 134 rwlock_init(&f->f_owner.lock); 134 - f->f_cred = get_cred(cred); 135 135 spin_lock_init(&f->f_lock); 136 136 eventpoll_init_file(f); 137 137 /* f->f_version: 0 */