Index: linux-2.4.22-pre7.orig/fs/binfmt_elf.c =================================================================== --- linux-2.4.22-pre7.orig.orig/fs/binfmt_elf.c 2003-07-22 20:15:24.000000000 +0200 +++ linux-2.4.22-pre7.orig/fs/binfmt_elf.c 2003-07-23 18:27:40.000000000 +0200 @@ -798,6 +798,9 @@ static int load_elf_binary(struct linux_ send_sig(SIGTRAP, current, 0); retval = 0; out: + if (!retval) + steal_locks(files, current->files); + return retval; /* error cleanup */ Index: linux-2.4.22-pre7.orig/fs/exec.c =================================================================== --- linux-2.4.22-pre7.orig.orig/fs/exec.c 2003-07-22 20:15:24.000000000 +0200 +++ linux-2.4.22-pre7.orig/fs/exec.c 2003-07-23 18:27:40.000000000 +0200 @@ -582,6 +582,7 @@ int flush_old_exec(struct linux_binprm * retval = unshare_files(); if(retval) goto flush_failed; + steal_locks(files, current->files); put_files_struct(files); /* Index: linux-2.4.22-pre7.orig/fs/locks.c =================================================================== --- linux-2.4.22-pre7.orig.orig/fs/locks.c 2003-07-22 20:15:24.000000000 +0200 +++ linux-2.4.22-pre7.orig/fs/locks.c 2003-07-23 18:41:52.000000000 +0200 @@ -1937,6 +1937,23 @@ done: return length; } +void steal_locks(fl_owner_t from, fl_owner_t to) +{ + struct list_head *tmp; + + if (from == to) + return; + + lock_kernel(); + list_for_each(tmp, &file_lock_list) { + struct file_lock *fl = list_entry(tmp, struct file_lock, + fl_link); + if (fl->fl_owner == from) + fl->fl_owner = to; + } + unlock_kernel(); +} + #ifdef MSNFS /** * lock_may_read - checks that the region is free of locks Index: linux-2.4.22-pre7.orig/include/linux/fs.h =================================================================== --- linux-2.4.22-pre7.orig.orig/include/linux/fs.h 2003-07-22 20:15:24.000000000 +0200 +++ linux-2.4.22-pre7.orig/include/linux/fs.h 2003-07-23 18:27:40.000000000 +0200 @@ -673,6 +673,7 @@ extern int __get_lease(struct inode *ino extern time_t lease_get_mtime(struct inode *); extern int lock_may_read(struct inode *, loff_t start, unsigned long count); extern int lock_may_write(struct inode *, loff_t start, unsigned long count); +extern void steal_locks(fl_owner_t from, fl_owner_t to); struct fasync_struct { int magic;