Re: local denial-of-service with file leases

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



* Avi Kivity ([email protected]) wrote:
> the following program will oom a the 2.6.14.1 kernel, running as an 
> ordinary user:

I don't have a good mechanism for testing leases, but this should fix
the leak.  Mind testing?

thanks,
-chris
--

When unlocking lease make sure to release fasync_struct.

Signed-off-by: Chris Wright <[email protected]>
---

diff --git a/fs/locks.c b/fs/locks.c
index a1e8b22..abba0f6 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1412,7 +1412,7 @@ int fcntl_setlease(unsigned int fd, stru
 	struct file_lock fl, *flp = &fl;
 	struct dentry *dentry = filp->f_dentry;
 	struct inode *inode = dentry->d_inode;
-	int error;
+	int error, on = 1;
 
 	if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE))
 		return -EACCES;
@@ -1433,7 +1433,10 @@ int fcntl_setlease(unsigned int fd, stru
 	if (error)
 		goto out_unlock;
 
-	error = fasync_helper(fd, filp, 1, &flp->fl_fasync);
+	if (arg == F_UNLCK)
+		on = 0;
+
+	error = fasync_helper(fd, filp, on, &flp->fl_fasync);
 	if (error < 0) {
 		/* remove lease just inserted by __setlease */
 		flp->fl_type = F_UNLCK | F_INPROGRESS;
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux