mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-22 14:41:27 +00:00
[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>
This commit is contained in:
parent
fc09561d63
commit
3b9b8ab65d
5 changed files with 18 additions and 10 deletions
|
@ -487,6 +487,18 @@ void fastcall put_files_struct(struct files_struct *files)
|
|||
|
||||
EXPORT_SYMBOL(put_files_struct);
|
||||
|
||||
void reset_files_struct(struct task_struct *tsk, struct files_struct *files)
|
||||
{
|
||||
struct files_struct *old;
|
||||
|
||||
old = tsk->files;
|
||||
task_lock(tsk);
|
||||
tsk->files = files;
|
||||
task_unlock(tsk);
|
||||
put_files_struct(old);
|
||||
}
|
||||
EXPORT_SYMBOL(reset_files_struct);
|
||||
|
||||
static inline void __exit_files(struct task_struct *tsk)
|
||||
{
|
||||
struct files_struct * files = tsk->files;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue