Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f7789dc0 authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'locks-3.15' of git://git.samba.org/jlayton/linux

Pull file locking updates from Jeff Layton:
 "Highlights:

   - maintainership change for fs/locks.c.  Willy's not interested in
     maintaining it these days, and is OK with Bruce and I taking it.
   - fix for open vs setlease race that Al ID'ed
   - cleanup and consolidation of file locking code
   - eliminate unneeded BUG() call
   - merge of file-private lock implementation"

* 'locks-3.15' of git://git.samba.org/jlayton/linux:
  locks: make locks_mandatory_area check for file-private locks
  locks: fix locks_mandatory_locked to respect file-private locks
  locks: require that flock->l_pid be set to 0 for file-private locks
  locks: add new fcntl cmd values for handling file private locks
  locks: skip deadlock detection on FL_FILE_PVT locks
  locks: pass the cmd value to fcntl_getlk/getlk64
  locks: report l_pid as -1 for FL_FILE_PVT locks
  locks: make /proc/locks show IS_FILE_PVT locks as type "FLPVT"
  locks: rename locks_remove_flock to locks_remove_file
  locks: consolidate checks for compatible filp->f_mode values in setlk handlers
  locks: fix posix lock range overflow handling
  locks: eliminate BUG() call when there's an unexpected lock on file close
  locks: add __acquires and __releases annotations to locks_start and locks_stop
  locks: remove "inline" qualifier from fl_link manipulation functions
  locks: clean up comment typo
  locks: close potential race between setlease and open
  MAINTAINERS: update entry for fs/locks.c
parents 7df93452 29723ade
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -3521,7 +3521,8 @@ F: include/scsi/libfcoe.h
F:	include/uapi/scsi/fc/

FILE LOCKING (flock() and fcntl()/lockf())
M:	Matthew Wilcox <matthew@wil.cx>
M:	Jeff Layton <jlayton@redhat.com>
M:	J. Bruce Fields <bfields@fieldses.org>
L:	linux-fsdevel@vger.kernel.org
S:	Maintained
F:	include/linux/fcntl.h
+3 −0
Original line number Diff line number Diff line
@@ -203,6 +203,9 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
	int ret;

	switch (cmd) {
	case F_GETLKP:
	case F_SETLKP:
	case F_SETLKPW:
	case F_GETLK64:
	case F_SETLK64:
	case F_SETLKW64:
+30 −5
Original line number Diff line number Diff line
@@ -399,12 +399,28 @@ static int put_compat_flock64(struct flock *kfl, struct compat_flock64 __user *u
}
#endif

static unsigned int
convert_fcntl_cmd(unsigned int cmd)
{
	switch (cmd) {
	case F_GETLK64:
		return F_GETLK;
	case F_SETLK64:
		return F_SETLK;
	case F_SETLKW64:
		return F_SETLKW;
	}

	return cmd;
}

COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
		       compat_ulong_t, arg)
{
	mm_segment_t old_fs;
	struct flock f;
	long ret;
	unsigned int conv_cmd;

	switch (cmd) {
	case F_GETLK:
@@ -441,16 +457,18 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
	case F_GETLK64:
	case F_SETLK64:
	case F_SETLKW64:
	case F_GETLKP:
	case F_SETLKP:
	case F_SETLKPW:
		ret = get_compat_flock64(&f, compat_ptr(arg));
		if (ret != 0)
			break;
		old_fs = get_fs();
		set_fs(KERNEL_DS);
		ret = sys_fcntl(fd, (cmd == F_GETLK64) ? F_GETLK :
				((cmd == F_SETLK64) ? F_SETLK : F_SETLKW),
				(unsigned long)&f);
		conv_cmd = convert_fcntl_cmd(cmd);
		ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f);
		set_fs(old_fs);
		if (cmd == F_GETLK64 && ret == 0) {
		if ((conv_cmd == F_GETLK || conv_cmd == F_GETLKP) && ret == 0) {
			/* need to return lock information - see above for commentary */
			if (f.l_start > COMPAT_LOFF_T_MAX)
				ret = -EOVERFLOW;
@@ -471,8 +489,15 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd,
		       compat_ulong_t, arg)
{
	if ((cmd == F_GETLK64) || (cmd == F_SETLK64) || (cmd == F_SETLKW64))
	switch (cmd) {
	case F_GETLK64:
	case F_SETLK64:
	case F_SETLKW64:
	case F_GETLKP:
	case F_SETLKP:
	case F_SETLKPW:
		return -EINVAL;
	}
	return compat_sys_fcntl64(fd, cmd, arg);
}

+25 −12
Original line number Diff line number Diff line
@@ -272,9 +272,19 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
	case F_SETFL:
		err = setfl(fd, filp, arg);
		break;
#if BITS_PER_LONG != 32
	/* 32-bit arches must use fcntl64() */
	case F_GETLKP:
#endif
	case F_GETLK:
		err = fcntl_getlk(filp, (struct flock __user *) arg);
		err = fcntl_getlk(filp, cmd, (struct flock __user *) arg);
		break;
#if BITS_PER_LONG != 32
	/* 32-bit arches must use fcntl64() */
	case F_SETLKP:
	case F_SETLKPW:
#endif
		/* Fallthrough */
	case F_SETLK:
	case F_SETLKW:
		err = fcntl_setlk(fd, filp, cmd, (struct flock __user *) arg);
@@ -389,10 +399,13 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
	
	switch (cmd) {
	case F_GETLK64:
			err = fcntl_getlk64(f.file, (struct flock64 __user *) arg);
	case F_GETLKP:
		err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg);
		break;
	case F_SETLK64:
	case F_SETLKW64:
	case F_SETLKP:
	case F_SETLKPW:
		err = fcntl_setlk64(fd, f.file, cmd,
				(struct flock64 __user *) arg);
		break;
+1 −1
Original line number Diff line number Diff line
@@ -235,7 +235,7 @@ static void __fput(struct file *file)
	 * in the file cleanup chain.
	 */
	eventpoll_release(file);
	locks_remove_flock(file);
	locks_remove_file(file);

	if (unlikely(file->f_flags & FASYNC)) {
		if (file->f_op->fasync)
Loading