diff options
Diffstat (limited to 'fs/locks.c')
-rw-r--r-- | fs/locks.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/fs/locks.c b/fs/locks.c index 838ca542c556..0e5873b0be54 100644 --- a/fs/locks.c +++ b/fs/locks.c | |||
@@ -1343,6 +1343,14 @@ static int __setlease(struct file *filp, long arg, struct file_lock **flp) | |||
1343 | struct inode *inode = dentry->d_inode; | 1343 | struct inode *inode = dentry->d_inode; |
1344 | int error, rdlease_count = 0, wrlease_count = 0; | 1344 | int error, rdlease_count = 0, wrlease_count = 0; |
1345 | 1345 | ||
1346 | if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE)) | ||
1347 | return -EACCES; | ||
1348 | if (!S_ISREG(inode->i_mode)) | ||
1349 | return -EINVAL; | ||
1350 | error = security_file_lock(filp, arg); | ||
1351 | if (error) | ||
1352 | return error; | ||
1353 | |||
1346 | time_out_leases(inode); | 1354 | time_out_leases(inode); |
1347 | 1355 | ||
1348 | BUG_ON(!(*flp)->fl_lmops->fl_break); | 1356 | BUG_ON(!(*flp)->fl_lmops->fl_break); |
@@ -1426,18 +1434,8 @@ out: | |||
1426 | 1434 | ||
1427 | int setlease(struct file *filp, long arg, struct file_lock **lease) | 1435 | int setlease(struct file *filp, long arg, struct file_lock **lease) |
1428 | { | 1436 | { |
1429 | struct dentry *dentry = filp->f_path.dentry; | ||
1430 | struct inode *inode = dentry->d_inode; | ||
1431 | int error; | 1437 | int error; |
1432 | 1438 | ||
1433 | if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE)) | ||
1434 | return -EACCES; | ||
1435 | if (!S_ISREG(inode->i_mode)) | ||
1436 | return -EINVAL; | ||
1437 | error = security_file_lock(filp, arg); | ||
1438 | if (error) | ||
1439 | return error; | ||
1440 | |||
1441 | lock_kernel(); | 1439 | lock_kernel(); |
1442 | error = __setlease(filp, arg, lease); | 1440 | error = __setlease(filp, arg, lease); |
1443 | unlock_kernel(); | 1441 | unlock_kernel(); |
@@ -1464,14 +1462,6 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg) | |||
1464 | struct inode *inode = dentry->d_inode; | 1462 | struct inode *inode = dentry->d_inode; |
1465 | int error; | 1463 | int error; |
1466 | 1464 | ||
1467 | if ((current->fsuid != inode->i_uid) && !capable(CAP_LEASE)) | ||
1468 | return -EACCES; | ||
1469 | if (!S_ISREG(inode->i_mode)) | ||
1470 | return -EINVAL; | ||
1471 | error = security_file_lock(filp, arg); | ||
1472 | if (error) | ||
1473 | return error; | ||
1474 | |||
1475 | locks_init_lock(&fl); | 1465 | locks_init_lock(&fl); |
1476 | error = lease_init(filp, arg, &fl); | 1466 | error = lease_init(filp, arg, &fl); |
1477 | if (error) | 1467 | if (error) |
@@ -1485,9 +1475,9 @@ int fcntl_setlease(unsigned int fd, struct file *filp, long arg) | |||
1485 | 1475 | ||
1486 | error = fasync_helper(fd, filp, 1, &flp->fl_fasync); | 1476 | error = fasync_helper(fd, filp, 1, &flp->fl_fasync); |
1487 | if (error < 0) { | 1477 | if (error < 0) { |
1488 | /* remove lease just inserted by __setlease */ | 1478 | /* remove lease just inserted by setlease */ |
1489 | flp->fl_type = F_UNLCK | F_INPROGRESS; | 1479 | flp->fl_type = F_UNLCK | F_INPROGRESS; |
1490 | flp->fl_break_time = jiffies- 10; | 1480 | flp->fl_break_time = jiffies - 10; |
1491 | time_out_leases(inode); | 1481 | time_out_leases(inode); |
1492 | goto out_unlock; | 1482 | goto out_unlock; |
1493 | } | 1483 | } |