public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vasiliy Kulikov <segoon@openwall.com>
To: "Arkadiusz Miśkiewicz" <a.miskiewicz@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Alexey Dobriyan <adobriyan@gmail.com>
Subject: [PATCH] proc: fix mount -t proc -o AAA
Date: Fri, 23 Mar 2012 21:10:58 +0400	[thread overview]
Message-ID: <20120323171058.GA3279@albatros> (raw)
In-Reply-To: <201203220903.15360.a.miskiewicz@gmail.com>

Hi Arkadiusz,

On Thu, Mar 22, 2012 at 09:03 +0100, Arkadiusz Miśkiewicz wrote:
> Hi,
> 
> I'm trying to use hidepid feature in 3.3 kernel but I'm getting weird
> things like options not being applied _sometimes_ at mount.
> 
> [@ ~]# cat /proc/mounts
> sh: cat: /proc/mounts: No such file or directory
> [@ ~]# strace -e mount -f -F -s 200 mount none /proc -t proc -o hidepid=2,gid=17                            
> mount("none", "/proc", "proc", MS_MGC_VAL, "hidepid=2,gid=17") = 0
> [@ ~]# cat /proc/mounts
> rootfs / rootfs rw 0 0
> /dev/sda3 / xfs rw,relatime,attr2,noquota 0 0
> run /run tmpfs rw,relatime 0 0
> none /proc proc rw,relatime 0 0
> 
> No hidepid, no gid - huh?
> 
> [@ ~]# mount /proc -o remount,hidepid=2,gid=17
> [@ ~]# cat /proc/mounts
> rootfs / rootfs rw 0 0
> /dev/sda3 / xfs rw,relatime,attr2,noquota 0 0
> run /run tmpfs rw,relatime 0 0
> none /proc proc rw,relatime,gid=17,hidepid=2 0 0
> 
> remount and hidepid/gid is there
> 
> [@ ~]# umount /proc
> [@ ~]# strace -e mount -f -F -s 200 mount none /proc -t proc -o hidepid=2,gid=17                            
> mount("none", "/proc", "proc", MS_MGC_VAL, "hidepid=2,gid=17") = 0
> [@ ~]# cat /proc/mounts
> rootfs / rootfs rw 0 0
> /dev/sda3 / xfs rw,relatime,attr2,noquota 0 0
> run /run tmpfs rw,relatime 0 0
> none /proc proc rw,relatime,gid=17,hidepid=2 0 0
> 
> and now I'm lost - every new umount & mount gets hidepid/gid right.
> 
> Any ideas why initial mount fails to get hidepid/gid options applied?
> The syscall seems correct.

Thanks for the report.  Please test the following patch.

--------------------------------------------------------------
From: Vasiliy Kulikov <segoon@openwall.com>
Date: Fri, 23 Mar 2012 20:56:42 +0400
Subject: [PATCH] proc: fix mount -t proc -o AAA

proc_parse_options() inside of proc_mount() runs only once at the boot
time without any given options.  So, following umount(2)+mount(2) ignore
mount options: proc_parse_options() is not called as ->s_root is already
initialized.  To fix that parse mount options unconditionally.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
Reported-by: Arkadiusz Miśkiewicz <a.miskiewicz@gmail.com>
---
 fs/proc/root.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/fs/proc/root.c b/fs/proc/root.c
index 46a15d8..eed44bf 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -115,12 +115,13 @@ static struct dentry *proc_mount(struct file_system_type *fs_type,
 	if (IS_ERR(sb))
 		return ERR_CAST(sb);
 
+	if (!proc_parse_options(options, ns)) {
+		deactivate_locked_super(sb);
+		return ERR_PTR(-EINVAL);
+	}
+
 	if (!sb->s_root) {
 		sb->s_flags = flags;
-		if (!proc_parse_options(options, ns)) {
-			deactivate_locked_super(sb);
-			return ERR_PTR(-EINVAL);
-		}
 		err = proc_fill_super(sb);
 		if (err) {
 			deactivate_locked_super(sb);
-- 
1.7.0.4


  reply	other threads:[~2012-03-23 17:11 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-22  8:03 3.3 and hidepid feature problem - options not always applied at mount Arkadiusz Miśkiewicz
2012-03-23 17:10 ` Vasiliy Kulikov [this message]
2012-03-23 18:45   ` [PATCH] proc: fix mount -t proc -o AAA Arkadiusz Miśkiewicz
2012-03-23 19:18     ` Vasiliy Kulikov
2012-03-23 23:15   ` Andrew Morton
2012-03-25  7:24     ` Arkadiusz Miśkiewicz
2012-03-25 15:36       ` Vasiliy Kulikov
2012-03-25 17:40         ` Arkadiusz Miśkiewicz
2012-03-25 17:49           ` Vasiliy Kulikov
2012-03-25 22:23         ` Valdis.Kletnieks
2012-03-26 22:37           ` Andrew Morton
2012-03-31 13:55             ` [PATCH] proc: reset mount options after the last procfs umount Vasiliy Kulikov
2012-03-31 14:19               ` Arkadiusz Miśkiewicz
2012-03-31 15:20                 ` Vasiliy Kulikov
2012-03-31 15:31                   ` Arkadiusz Miśkiewicz
2012-03-31 15:46                     ` Vasiliy Kulikov
2012-03-26 22:35       ` [PATCH] proc: fix mount -t proc -o AAA Andrew Morton
2012-03-25 15:27     ` Vasiliy Kulikov
2012-03-31 13:51     ` Vasiliy Kulikov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120323171058.GA3279@albatros \
    --to=segoon@openwall.com \
    --cc=a.miskiewicz@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox