From patchwork Tue Aug 18 15:18:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsu Park X-Patchwork-Id: 7031791 Return-Path: X-Original-To: patchwork-linux-fsdevel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A7EF99F372 for ; Tue, 18 Aug 2015 15:18:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DECFE2064B for ; Tue, 18 Aug 2015 15:18:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB9112063D for ; Tue, 18 Aug 2015 15:18:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753310AbbHRPSL (ORCPT ); Tue, 18 Aug 2015 11:18:11 -0400 Received: from mx02.posteo.de ([89.146.194.165]:58734 "EHLO mx02.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297AbbHRPSK (ORCPT ); Tue, 18 Aug 2015 11:18:10 -0400 Received: from dovecot04.posteo.de (unknown [185.67.36.27]) by mx02.posteo.de (Postfix) with ESMTPS id 8A17525ACC48; Tue, 18 Aug 2015 17:18:08 +0200 (CEST) Received: from mail.posteo.de (localhost [127.0.0.1]) by dovecot04.posteo.de (Postfix) with ESMTPSA id 3mwbTq2Nk3zFpVk; Tue, 18 Aug 2015 17:18:07 +0200 (CEST) From: Dongsu Park To: linux-kernel@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, Peter Hurley , Josh Triplett , Al Viro , Andrew Morton , David Howells , Alban Crequy , Dongsu Park Subject: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Date: Tue, 18 Aug 2015 17:18:19 +0200 Message-Id: <692839ff7158dbb96dd20ce8e36c13f85fa64fd7.1439910753.git.dpark@posteo.net> X-Mailer: git-send-email 2.1.0 In-Reply-To: <882a878038efb5fed381be5d4817ff44d90703d5.1439904209.git.dpark@posteo.net> References: <882a878038efb5fed381be5d4817ff44d90703d5.1439904209.git.dpark@posteo.net> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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)) + { + 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;