mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dongsu Park <dpark@posteo.net>
To: linux-kernel@vger.kernel.org
Cc: linux-fsdevel@vger.kernel.org,
	Peter Hurley <peter@hurleysoftware.com>,
	Josh Triplett <josh@joshtriplett.org>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Howells <dhowells@redhat.com>,
	Alban Crequy <alban@endocode.com>, Dongsu Park <dpark@posteo.net>
Subject: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t
Date: Tue, 18 Aug 2015 17:18:19 +0200	[thread overview]
Message-ID: <692839ff7158dbb96dd20ce8e36c13f85fa64fd7.1439910753.git.dpark@posteo.net> (raw)
In-Reply-To: <882a878038efb5fed381be5d4817ff44d90703d5.1439904209.git.dpark@posteo.net>

To allow devpts to be mounted with options of uid/gid of uint32_t,
use kstrtouint() instead of match_int(). Doing that, mounting devpts
with uid or gid > (2^31 - 1) will work as expected, e.g.:

 # mount -t devpts devpts /tmp/devptsdir -o \
   newinstance,ptmxmode=0666,mode=620,uid=3598450688,gid=3598450693

It was originally by reported on systemd github issues:
https://github.com/systemd/systemd/issues/956

from v1: fix patch format correctly

Reported-by: Alban Crequy <alban@endocode.com>
Signed-off-by: Dongsu Park <dpark@posteo.net>
---
 fs/devpts/inode.c | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c
index c35ffdc12bba..49272fae40a7 100644
--- a/fs/devpts/inode.c
+++ b/fs/devpts/inode.c
@@ -188,23 +188,35 @@ static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts)
 		token = match_token(p, tokens, args);
 		switch (token) {
 		case Opt_uid:
-			if (match_int(&args[0], &option))
+		{
+			char *uidstr = args[0].from;
+			uid_t uidval;
+			int rc = kstrtouint(uidstr, 0, &uidval);
+
+			if (rc)
 				return -EINVAL;
-			uid = make_kuid(current_user_ns(), option);
+			uid = make_kuid(current_user_ns(), uidval);
 			if (!uid_valid(uid))
 				return -EINVAL;
 			opts->uid = uid;
 			opts->setuid = 1;
 			break;
+		}
 		case Opt_gid:
-			if (match_int(&args[0], &option))
+		{
+			char *gidstr = args[0].from;
+			gid_t gidval;
+			int rc = kstrtouint(gidstr, 0, &gidval);
+
+			if (rc)
 				return -EINVAL;
-			gid = make_kgid(current_user_ns(), option);
+			gid = make_kgid(current_user_ns(), gidval);
 			if (!gid_valid(gid))
 				return -EINVAL;
 			opts->gid = gid;
 			opts->setgid = 1;
 			break;
+		}
 		case Opt_mode:
 			if (match_octal(&args[0], &option))
 				return -EINVAL;
-- 
2.1.0


  reply	other threads:[~2015-08-18 15:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-18 14:31 [PATCH] " Dongsu Park
2015-08-18 15:18 ` Dongsu Park [this message]
2015-08-18 23:44   ` [PATCH v2] " Andrew Morton
2015-08-19  7:24     ` Dongsu Park
2015-08-19  7:47       ` Andrew Morton
2015-08-19  8:34         ` Rasmus Villemoes
2015-08-19 10:47         ` Alexey Dobriyan
2015-08-28 19:33   ` Peter Hurley
2015-08-29 10:43     ` Dongsu Park
2015-08-29 21:44       ` Alexey Dobriyan

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=692839ff7158dbb96dd20ce8e36c13f85fa64fd7.1439910753.git.dpark@posteo.net \
    --to=dpark@posteo.net \
    --cc=akpm@linux-foundation.org \
    --cc=alban@endocode.com \
    --cc=dhowells@redhat.com \
    --cc=josh@joshtriplett.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter@hurleysoftware.com \
    --cc=viro@zeniv.linux.org.uk \
    /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

all inboxes | Powered by JetHome®