lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 19 Apr 2012 11:07:55 +0200
From:	Lukas Czerner <lczerner@...hat.com>
To:	linux-kernel@...r.kernel.org
Cc:	mbroz@...hat.com, linux-fsdevel@...r.kernel.org,
	Lukas Czerner <lczerner@...hat.com>,
	Al Viro <viro@...iv.linux.org.uk>
Subject: [PATCH] fs: print warning when mount flags was ignored

Some mount flags can conflict with each other so they can not be
handled together. Currently when conflicting flags are specified,
some of them are silently ignored putting user in believe that
they was handled correctly.

Fix this by checking for unhandled flags and print warning when
flags was ignored. I am not sure if it's worth translating the flags
into the name, so it just prints the flag as a hexadecimal number.

Obviously we can not fail when conflicting flags are specified,
because it may break buggy application, but it can change in the
future.

Signed-off-by: Lukas Czerner <lczerner@...hat.com>
Reported-by: Milan Broz <mbroz@...hat.com>
Cc: Al Viro <viro@...iv.linux.org.uk>
---
 fs/namespace.c |   24 +++++++++++++++++++-----
 1 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/fs/namespace.c b/fs/namespace.c
index e608199..8736a48 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -2175,18 +2175,32 @@ long do_mount(char *dev_name, char *dir_name, char *type_page,
 		   MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
 		   MS_STRICTATIME);
 
-	if (flags & MS_REMOUNT)
+	if (flags & MS_REMOUNT) {
 		retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
 				    data_page);
-	else if (flags & MS_BIND)
+		flags &= ~MS_REMOUNT;
+	} else if (flags & MS_BIND) {
 		retval = do_loopback(&path, dev_name, flags & MS_REC);
-	else if (flags & (MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE))
+		flags &= ~MS_BIND;
+	} else if (flags & (MS_SHARED | MS_PRIVATE |
+			    MS_SLAVE | MS_UNBINDABLE)) {
 		retval = do_change_type(&path, flags);
-	else if (flags & MS_MOVE)
+		flags &= ~(MS_SHARED | MS_PRIVATE | MS_SLAVE | MS_UNBINDABLE);
+	} else if (flags & MS_MOVE) {
 		retval = do_move_mount(&path, dev_name);
-	else
+		flags &= ~MS_MOVE;
+	} else
 		retval = do_new_mount(&path, type_page, flags, mnt_flags,
 				      dev_name, data_page);
+
+	flags &= (MS_REMOUNT | MS_BIND | MS_SHARED | MS_PRIVATE |
+		  MS_SLAVE | MS_UNBINDABLE | MS_MOVE);
+
+	if (!retval && flags)
+		printk(KERN_WARNING "%s(%u): (%s -> %s) Conflicting mount flags"
+				    " specified. These flags has been "
+				    "ignored: %#.8lx\n", __func__, current->pid,
+				    dev_name, dir_name, flags);
 dput_out:
 	path_put(&path);
 	return retval;
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ