|
@@ -2084,26 +2084,22 @@ static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl)
|
|
/* Report the first existing lock that would conflict with l.
|
|
/* Report the first existing lock that would conflict with l.
|
|
* This implements the F_GETLK command of fcntl().
|
|
* This implements the F_GETLK command of fcntl().
|
|
*/
|
|
*/
|
|
-int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l)
|
|
|
|
|
|
+int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock *flock)
|
|
{
|
|
{
|
|
struct file_lock file_lock;
|
|
struct file_lock file_lock;
|
|
- struct flock flock;
|
|
|
|
int error;
|
|
int error;
|
|
|
|
|
|
- error = -EFAULT;
|
|
|
|
- if (copy_from_user(&flock, l, sizeof(flock)))
|
|
|
|
- goto out;
|
|
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
- if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK))
|
|
|
|
|
|
+ if (flock->l_type != F_RDLCK && flock->l_type != F_WRLCK)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- error = flock_to_posix_lock(filp, &file_lock, &flock);
|
|
|
|
|
|
+ error = flock_to_posix_lock(filp, &file_lock, flock);
|
|
if (error)
|
|
if (error)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
if (cmd == F_OFD_GETLK) {
|
|
if (cmd == F_OFD_GETLK) {
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
- if (flock.l_pid != 0)
|
|
|
|
|
|
+ if (flock->l_pid != 0)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
cmd = F_GETLK;
|
|
cmd = F_GETLK;
|
|
@@ -2115,15 +2111,12 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l)
|
|
if (error)
|
|
if (error)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- flock.l_type = file_lock.fl_type;
|
|
|
|
|
|
+ flock->l_type = file_lock.fl_type;
|
|
if (file_lock.fl_type != F_UNLCK) {
|
|
if (file_lock.fl_type != F_UNLCK) {
|
|
- error = posix_lock_to_flock(&flock, &file_lock);
|
|
|
|
|
|
+ error = posix_lock_to_flock(flock, &file_lock);
|
|
if (error)
|
|
if (error)
|
|
goto rel_priv;
|
|
goto rel_priv;
|
|
}
|
|
}
|
|
- error = -EFAULT;
|
|
|
|
- if (!copy_to_user(l, &flock, sizeof(flock)))
|
|
|
|
- error = 0;
|
|
|
|
rel_priv:
|
|
rel_priv:
|
|
locks_release_private(&file_lock);
|
|
locks_release_private(&file_lock);
|
|
out:
|
|
out:
|
|
@@ -2216,26 +2209,16 @@ check_fmode_for_setlk(struct file_lock *fl)
|
|
* This implements both the F_SETLK and F_SETLKW commands of fcntl().
|
|
* This implements both the F_SETLK and F_SETLKW commands of fcntl().
|
|
*/
|
|
*/
|
|
int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
- struct flock __user *l)
|
|
|
|
|
|
+ struct flock *flock)
|
|
{
|
|
{
|
|
struct file_lock *file_lock = locks_alloc_lock();
|
|
struct file_lock *file_lock = locks_alloc_lock();
|
|
- struct flock flock;
|
|
|
|
- struct inode *inode;
|
|
|
|
|
|
+ struct inode *inode = locks_inode(filp);
|
|
struct file *f;
|
|
struct file *f;
|
|
int error;
|
|
int error;
|
|
|
|
|
|
if (file_lock == NULL)
|
|
if (file_lock == NULL)
|
|
return -ENOLCK;
|
|
return -ENOLCK;
|
|
|
|
|
|
- inode = locks_inode(filp);
|
|
|
|
-
|
|
|
|
- /*
|
|
|
|
- * This might block, so we do it before checking the inode.
|
|
|
|
- */
|
|
|
|
- error = -EFAULT;
|
|
|
|
- if (copy_from_user(&flock, l, sizeof(flock)))
|
|
|
|
- goto out;
|
|
|
|
-
|
|
|
|
/* Don't allow mandatory locks on files that may be memory mapped
|
|
/* Don't allow mandatory locks on files that may be memory mapped
|
|
* and shared.
|
|
* and shared.
|
|
*/
|
|
*/
|
|
@@ -2244,7 +2227,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
- error = flock_to_posix_lock(filp, file_lock, &flock);
|
|
|
|
|
|
+ error = flock_to_posix_lock(filp, file_lock, flock);
|
|
if (error)
|
|
if (error)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
@@ -2259,7 +2242,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
switch (cmd) {
|
|
switch (cmd) {
|
|
case F_OFD_SETLK:
|
|
case F_OFD_SETLK:
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
- if (flock.l_pid != 0)
|
|
|
|
|
|
+ if (flock->l_pid != 0)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
cmd = F_SETLK;
|
|
cmd = F_SETLK;
|
|
@@ -2268,7 +2251,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
break;
|
|
break;
|
|
case F_OFD_SETLKW:
|
|
case F_OFD_SETLKW:
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
- if (flock.l_pid != 0)
|
|
|
|
|
|
+ if (flock->l_pid != 0)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
cmd = F_SETLKW;
|
|
cmd = F_SETLKW;
|
|
@@ -2313,26 +2296,22 @@ out:
|
|
/* Report the first existing lock that would conflict with l.
|
|
/* Report the first existing lock that would conflict with l.
|
|
* This implements the F_GETLK command of fcntl().
|
|
* This implements the F_GETLK command of fcntl().
|
|
*/
|
|
*/
|
|
-int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l)
|
|
|
|
|
|
+int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 *flock)
|
|
{
|
|
{
|
|
struct file_lock file_lock;
|
|
struct file_lock file_lock;
|
|
- struct flock64 flock;
|
|
|
|
int error;
|
|
int error;
|
|
|
|
|
|
- error = -EFAULT;
|
|
|
|
- if (copy_from_user(&flock, l, sizeof(flock)))
|
|
|
|
- goto out;
|
|
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
- if ((flock.l_type != F_RDLCK) && (flock.l_type != F_WRLCK))
|
|
|
|
|
|
+ if (flock->l_type != F_RDLCK && flock->l_type != F_WRLCK)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- error = flock64_to_posix_lock(filp, &file_lock, &flock);
|
|
|
|
|
|
+ error = flock64_to_posix_lock(filp, &file_lock, flock);
|
|
if (error)
|
|
if (error)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
if (cmd == F_OFD_GETLK) {
|
|
if (cmd == F_OFD_GETLK) {
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
- if (flock.l_pid != 0)
|
|
|
|
|
|
+ if (flock->l_pid != 0)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
cmd = F_GETLK64;
|
|
cmd = F_GETLK64;
|
|
@@ -2344,13 +2323,9 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l)
|
|
if (error)
|
|
if (error)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
- flock.l_type = file_lock.fl_type;
|
|
|
|
|
|
+ flock->l_type = file_lock.fl_type;
|
|
if (file_lock.fl_type != F_UNLCK)
|
|
if (file_lock.fl_type != F_UNLCK)
|
|
- posix_lock_to_flock64(&flock, &file_lock);
|
|
|
|
-
|
|
|
|
- error = -EFAULT;
|
|
|
|
- if (!copy_to_user(l, &flock, sizeof(flock)))
|
|
|
|
- error = 0;
|
|
|
|
|
|
+ posix_lock_to_flock64(flock, &file_lock);
|
|
|
|
|
|
locks_release_private(&file_lock);
|
|
locks_release_private(&file_lock);
|
|
out:
|
|
out:
|
|
@@ -2361,26 +2336,16 @@ out:
|
|
* This implements both the F_SETLK and F_SETLKW commands of fcntl().
|
|
* This implements both the F_SETLK and F_SETLKW commands of fcntl().
|
|
*/
|
|
*/
|
|
int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
- struct flock64 __user *l)
|
|
|
|
|
|
+ struct flock64 *flock)
|
|
{
|
|
{
|
|
struct file_lock *file_lock = locks_alloc_lock();
|
|
struct file_lock *file_lock = locks_alloc_lock();
|
|
- struct flock64 flock;
|
|
|
|
- struct inode *inode;
|
|
|
|
|
|
+ struct inode *inode = locks_inode(filp);
|
|
struct file *f;
|
|
struct file *f;
|
|
int error;
|
|
int error;
|
|
|
|
|
|
if (file_lock == NULL)
|
|
if (file_lock == NULL)
|
|
return -ENOLCK;
|
|
return -ENOLCK;
|
|
|
|
|
|
- /*
|
|
|
|
- * This might block, so we do it before checking the inode.
|
|
|
|
- */
|
|
|
|
- error = -EFAULT;
|
|
|
|
- if (copy_from_user(&flock, l, sizeof(flock)))
|
|
|
|
- goto out;
|
|
|
|
-
|
|
|
|
- inode = locks_inode(filp);
|
|
|
|
-
|
|
|
|
/* Don't allow mandatory locks on files that may be memory mapped
|
|
/* Don't allow mandatory locks on files that may be memory mapped
|
|
* and shared.
|
|
* and shared.
|
|
*/
|
|
*/
|
|
@@ -2389,7 +2354,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
goto out;
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
|
|
- error = flock64_to_posix_lock(filp, file_lock, &flock);
|
|
|
|
|
|
+ error = flock64_to_posix_lock(filp, file_lock, flock);
|
|
if (error)
|
|
if (error)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
@@ -2404,7 +2369,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
switch (cmd) {
|
|
switch (cmd) {
|
|
case F_OFD_SETLK:
|
|
case F_OFD_SETLK:
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
- if (flock.l_pid != 0)
|
|
|
|
|
|
+ if (flock->l_pid != 0)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
cmd = F_SETLK64;
|
|
cmd = F_SETLK64;
|
|
@@ -2413,7 +2378,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
|
|
break;
|
|
break;
|
|
case F_OFD_SETLKW:
|
|
case F_OFD_SETLKW:
|
|
error = -EINVAL;
|
|
error = -EINVAL;
|
|
- if (flock.l_pid != 0)
|
|
|
|
|
|
+ if (flock->l_pid != 0)
|
|
goto out;
|
|
goto out;
|
|
|
|
|
|
cmd = F_SETLKW64;
|
|
cmd = F_SETLKW64;
|