Re: [PATCH] unserialized task->files changing

From: Kirill Korotaev
Date: Tue Aug 08 2006 - 06:42:12 EST

Eric Dumazet wrote:
On Tuesday 08 August 2006 12:12, Christoph Hellwig wrote:

On Tue, Aug 08, 2006 at 02:07:49PM +0400, Kirill Korotaev wrote:

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.

This is three times the exact same code sequence, it should probably go
into a helper:

void reset_current_files(struct files_struct *files)
struct files_struct *old = current->files;

current->files = files;

More over I think you want to task_lock() before reading current->files into 'old'

old = current->files;
current->files = files;

or maybe a xchg() ?

yeah, never do assignments in declarations :)

BTW, not sure about kthread_exit_files() yet, but looks like it suffers too.

unshare_files() changes current->files w/o locking as well. but I can't see
where it puts the old files... hmm...

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at