aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorKirill Korotaev <dev@sw.ru>2006-09-29 05:00:05 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-29 12:18:12 -0400
commit3b9b8ab65d8eed784b9164d03807cb2bda7b5cd6 (patch)
tree104c7b01768acd7e152cbf66e4868a73804e8af9 /kernel
parentfc09561d6392771a392dea55c287de7e849b6b63 (diff)
[PATCH] Fix unserialized task->files changing
Fixed race on put_files_struct on exec with proc. Restoring files on current on error path may lead to proc having a pointer to already kfree-d files_struct. ->files changing at exit.c and khtread.c are safe as exit_files() makes all things under lock. Found during OpenVZ stress testing. [akpm@osdl.org: add export] Signed-off-by: Pavel Emelianov <xemul@openvz.org> Signed-off-by: Kirill Korotaev <dev@openvz.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/exit.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/kernel/exit.c b/kernel/exit.c
index d891883420f7..4b6fb054b25d 100644
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -487,6 +487,18 @@ void fastcall put_files_struct(struct files_struct *files)
487 487
488EXPORT_SYMBOL(put_files_struct); 488EXPORT_SYMBOL(put_files_struct);
489 489
490void reset_files_struct(struct task_struct *tsk, struct files_struct *files)
491{
492 struct files_struct *old;
493
494 old = tsk->files;
495 task_lock(tsk);
496 tsk->files = files;
497 task_unlock(tsk);
498 put_files_struct(old);
499}
500EXPORT_SYMBOL(reset_files_struct);
501
490static inline void __exit_files(struct task_struct *tsk) 502static inline void __exit_files(struct task_struct *tsk)
491{ 503{
492 struct files_struct * files = tsk->files; 504 struct files_struct * files = tsk->files;