diff mbox

[v6,7/7] locks: Disable LOCK_MAND support for MS_SHARELOCK mounts

Message ID 1366977861-27678-8-git-send-email-piastry@etersoft.ru (mailing list archive)
State New, archived
Headers show

Commit Message

Pavel Shilovsky April 26, 2013, 12:04 p.m. UTC
Signed-off-by: Pavel Shilovsky <piastry@etersoft.ru>
---
 fs/locks.c | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox

Patch

diff --git a/fs/locks.c b/fs/locks.c
index 25c3a49..7d67e0e 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -1756,6 +1756,12 @@  SYSCALL_DEFINE2(flock, unsigned int, fd, unsigned int, cmd)
 		goto out;
 	}
 
+	/* Disable LOCK_MAND support for FS mounted with MS_SHARELOCK */
+	if ((cmd & LOCK_MAND) && IS_SHARELOCK(f.file->f_path.dentry->d_inode)) {
+		error = -EPERM;
+		goto out;
+	}
+
 	can_sleep = !(cmd & LOCK_NB);
 	cmd &= ~LOCK_NB;
 	unlock = (cmd == LOCK_UN);