From patchwork Tue Feb 7 13:48:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 9560145 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D6B6360434 for ; Tue, 7 Feb 2017 13:48:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5BC5283B4 for ; Tue, 7 Feb 2017 13:48:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8AD42839B; Tue, 7 Feb 2017 13:48:24 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 488922839B for ; Tue, 7 Feb 2017 13:48:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754172AbdBGNsW (ORCPT ); Tue, 7 Feb 2017 08:48:22 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:33148 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753825AbdBGNsU (ORCPT ); Tue, 7 Feb 2017 08:48:20 -0500 Received: by mail-it0-f67.google.com with SMTP id e137so12313652itc.0 for ; Tue, 07 Feb 2017 05:48:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=quGj4Phk/7JtgH7Y9MvAmhchQ35s9Kg4vUF9j8rddh8=; b=q9Aodn/btjaCPWrmpwKEwzHPUyJhWbrWvB2TqqprGbttNPa51pyBj+TQbRbUBLeLWM G2sodaEi16CgIU+YvOr888FlC6WuIaQe+hlKWj9D+x/72BwqjFt3AGE+vIWWap8BZfrX shu3/TDvYKNogtgxlFQiAmcb1Am5l2/ZpDKAeXoOJRia50A+WSLVY38UqOpRRDr8waYl oILvEMEPvWSF/g8zeabCXgdn6KUgK1zeqFAH6FnfX0E3QrrajOtGm/lhkMpvNelj2qV6 KyhLmaTaNcAbpi6PlMP2uqE7g+PgDB8RElqZ728+FdYozZ3rj9P4pBMJrHcfo4VrGX/c Zobw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=quGj4Phk/7JtgH7Y9MvAmhchQ35s9Kg4vUF9j8rddh8=; b=BLiZHfW9kTSYpmBlzuGDcQJXH3HSPvsGQVmRiT+c4O6KTpYxnljaGiHa7SOIuRTcJE m9qIxY6TvIgU3LohEnuleXx6H6vPH25T2ysKNT43eBUu/Nn9OiiGqanYRmAWyZHFInzx cuU0CWH4QtI648QGywTMVYQiwlD/scr5oBHuTRzsmq87mEl8rUxJMQkWdctFT8fYfdKo 9iwnTSzvmfCQwMu9SNF8maMsGqd32vcGPi9bD6UWduVm618NjvOSg1ilTKSMagEdavka FZH4jXb6DFRl8nOoRhbrFW4QR+xjGYdfEH9XGtN6K9wGm8ADUGZ4x+Tnk2cz4fvaLn8S Efdg== X-Gm-Message-State: AIkVDXLfb4AZzZNIz5OVb6xp3SNQzUNzVw9Umt6SMDjgekAg5MPjXzZ24Z5LLsJG7pNIjQ== X-Received: by 10.36.196.86 with SMTP id v83mr11557070itf.64.1486475299740; Tue, 07 Feb 2017 05:48:19 -0800 (PST) Received: from [192.168.0.107] ([182.139.118.29]) by smtp.gmail.com with ESMTPSA id c21sm9518272iod.38.2017.02.07.05.48.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 05:48:19 -0800 (PST) Subject: [PATCH 3/7] sunrpc: rename NFS_NGROUPS to UNX_NGROUPS for auth unix To: "J. Bruce Fields" , linux-nfs@vger.kernel.org References: <59432847-8e45-4423-c441-0c67ee645f38@gmail.com> Cc: Trond Myklebust , Kinglong Mee From: Kinglong Mee Message-ID: <4852ccc0-52a9-ae62-7bf2-18138615c7d0@gmail.com> Date: Tue, 7 Feb 2017 21:48:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <59432847-8e45-4423-c441-0c67ee645f38@gmail.com> Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP NFS_NGROUPS has been move to sunrpc, rename to UNX_NGROUPS. Signed-off-by: Kinglong Mee --- include/linux/sunrpc/auth.h | 1 + net/sunrpc/auth_unix.c | 18 ++++++++---------- net/sunrpc/svcauth_unix.c | 4 ++-- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/include/linux/sunrpc/auth.h b/include/linux/sunrpc/auth.h index b1bc62b..39c85fb 100644 --- a/include/linux/sunrpc/auth.h +++ b/include/linux/sunrpc/auth.h @@ -32,6 +32,7 @@ */ #define UNX_MAXNODENAME __NEW_UTS_LEN #define UNX_CALLSLACK (21 + XDR_QUADLEN(UNX_MAXNODENAME)) +#define UNX_NGROUPS 16 struct rpcsec_gss_info; diff --git a/net/sunrpc/auth_unix.c b/net/sunrpc/auth_unix.c index 306fc0f..82337e1 100644 --- a/net/sunrpc/auth_unix.c +++ b/net/sunrpc/auth_unix.c @@ -14,12 +14,10 @@ #include #include -#define NFS_NGROUPS 16 - struct unx_cred { struct rpc_cred uc_base; kgid_t uc_gid; - kgid_t uc_gids[NFS_NGROUPS]; + kgid_t uc_gids[UNX_NGROUPS]; }; #define uc_uid uc_base.cr_uid @@ -82,13 +80,13 @@ unx_create_cred(struct rpc_auth *auth, struct auth_cred *acred, int flags, gfp_t if (acred->group_info != NULL) groups = acred->group_info->ngroups; - if (groups > NFS_NGROUPS) - groups = NFS_NGROUPS; + if (groups > UNX_NGROUPS) + groups = UNX_NGROUPS; cred->uc_gid = acred->gid; for (i = 0; i < groups; i++) cred->uc_gids[i] = acred->group_info->gid[i]; - if (i < NFS_NGROUPS) + if (i < UNX_NGROUPS) cred->uc_gids[i] = INVALID_GID; return &cred->uc_base; @@ -132,12 +130,12 @@ unx_match(struct auth_cred *acred, struct rpc_cred *rcred, int flags) if (acred->group_info != NULL) groups = acred->group_info->ngroups; - if (groups > NFS_NGROUPS) - groups = NFS_NGROUPS; + if (groups > UNX_NGROUPS) + groups = UNX_NGROUPS; for (i = 0; i < groups ; i++) if (!gid_eq(cred->uc_gids[i], acred->group_info->gid[i])) return 0; - if (groups < NFS_NGROUPS && gid_valid(cred->uc_gids[groups])) + if (groups < UNX_NGROUPS && gid_valid(cred->uc_gids[groups])) return 0; return 1; } @@ -166,7 +164,7 @@ unx_marshal(struct rpc_task *task, __be32 *p) *p++ = htonl((u32) from_kuid(&init_user_ns, cred->uc_uid)); *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gid)); hold = p++; - for (i = 0; i < 16 && gid_valid(cred->uc_gids[i]); i++) + for (i = 0; i < UNX_NGROUPS && gid_valid(cred->uc_gids[i]); i++) *p++ = htonl((u32) from_kgid(&init_user_ns, cred->uc_gids[i])); *hold = htonl(p - hold - 1); /* gid array length */ *base = htonl((p - base - 1) << 2); /* cred length */ diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index 64af4f0..f81eaa8 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c @@ -403,7 +403,7 @@ svcauth_unix_info_release(struct svc_xprt *xpt) /**************************************************************************** * auth.unix.gid cache * simple cache to map a UID to a list of GIDs - * because AUTH_UNIX aka AUTH_SYS has a max of 16 + * because AUTH_UNIX aka AUTH_SYS has a max of UNX_NGROUPS */ #define GID_HASHBITS 8 #define GID_HASHMAX (1<cr_uid = make_kuid(&init_user_ns, svc_getnl(argv)); /* uid */ cred->cr_gid = make_kgid(&init_user_ns, svc_getnl(argv)); /* gid */ slen = svc_getnl(argv); /* gids length */ - if (slen > 16 || (len -= (slen + 2)*4) < 0) + if (slen > UNX_NGROUPS || (len -= (slen + 2)*4) < 0) goto badcred; cred->cr_group_info = groups_alloc(slen); if (cred->cr_group_info == NULL)