Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752778AbbH1Tda (ORCPT ); Fri, 28 Aug 2015 15:33:30 -0400 Received: from mail-qk0-f176.google.com ([209.85.220.176]:36515 "EHLO mail-qk0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752164AbbH1Td3 (ORCPT ); Fri, 28 Aug 2015 15:33:29 -0400 From: Peter Hurley Subject: Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t To: Dongsu Park , Al Viro , Andrew Morton References: <882a878038efb5fed381be5d4817ff44d90703d5.1439904209.git.dpark@posteo.net> <692839ff7158dbb96dd20ce8e36c13f85fa64fd7.1439910753.git.dpark@posteo.net> Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Josh Triplett , David Howells , Alban Crequy Message-ID: <55E0B786.70101@hurleysoftware.com> Date: Fri, 28 Aug 2015 15:33:26 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <692839ff7158dbb96dd20ce8e36c13f85fa64fd7.1439910753.git.dpark@posteo.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2443 Lines: 81 On 08/18/2015 11:18 AM, Dongsu Park wrote: > 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 > Signed-off-by: Dongsu Park > --- > 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)) match_int() => make_kuid/kgid is a widespread pattern in filesystems for handling uid/gid mount parameters. How about adding a for-purpose string-to-uid/gid function, rather than open-coding? Regards, Peter Hurley > + { > + 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; > -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/