lkml.org 
[lkml]   [2005]   [Nov]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: local denial-of-service with file leases
* Avi Kivity (avi@argo.co.il) 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 <chrisw@osdl.org>
---

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 majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
\
 
 \ /
  Last update: 2005-11-11 09:48    [W:0.057 / U:0.296 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site