From patchwork Thu Nov 30 13:04:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 10084853 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 7A12760234 for ; Thu, 30 Nov 2017 13:07:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69D7E29F30 for ; Thu, 30 Nov 2017 13:07:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E6E829F99; Thu, 30 Nov 2017 13:07:22 +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.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, 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 109A029F30 for ; Thu, 30 Nov 2017 13:07:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752994AbdK3NGz (ORCPT ); Thu, 30 Nov 2017 08:06:55 -0500 Received: from mail-qk0-f195.google.com ([209.85.220.195]:44863 "EHLO mail-qk0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752804AbdK3NGy (ORCPT ); Thu, 30 Nov 2017 08:06:54 -0500 Received: by mail-qk0-f195.google.com with SMTP id h19so8652277qkj.11; Thu, 30 Nov 2017 05:06:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qEicMTto2JfNHn23SFWhkxOyknTtI+BfrAVkHL8mYKs=; b=vX2P8AxSuJ3iAALEA9AEWmSW66IgBpgmcVbvEqUJUGncSvgus8dNnr0crNn532CNHi lftq5iTdpmzjTVbOOM9yvqMglzS+r7rnxrPY67upg6o0Nemrl2UvFQg2JGcSEsWA8v8S ni9Pv5uhBuDlR6UcomWR11ILAcNd0XyLiiTT6qIMvvYYGC0uIMfbl/C4El73lamu6bG7 5vdYXu/xz5mherFLOidw9o6lm4GyDB/aFBKOBGnrY8CMdK7lDMTA8P2oCiC12kihFIzb tgR0nOVTORKJdzTwDgivPk+NX/FWMpTrRxYsVd62n5BBo5B+0SbfYgfTzdsaI/LkNDYz n75A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qEicMTto2JfNHn23SFWhkxOyknTtI+BfrAVkHL8mYKs=; b=dvY+kCciSlqU5uPmI6U/ol7S3in6Pch3g7af8FDeRaWqODcBXbJaaDOFKBZifXxG/B CeliShz7Txv4mETIUhKDG9TB8k62yJFHF51RgLbHh5I6IiBuaQqqVmAlhu0ly2sew2t5 60qbTHyY9rmbs3V85YVjcq0MElcKV07zMFJ4KrV9Ta87J3N0kxFM8fQrXPsdNpNCxjp1 H6/FsMws8q2gICMo82AiMDyIAUWVoBH745+ljHHJnSt7csy7ncZ9OyyaVJ/pCQbyPQNu bfdeJ1VkVlPlYtEsfFMc1ofVA1VPVo8PDsljJFgnO6AT+s/fHtv0KHGxe2iAo7XdxKbj DvpA== X-Gm-Message-State: AKGB3mKdZBmeQC+9vGsqGbHRCQ4CSbAESUaZ4Uo0MTq1RKdE3D5ysShB zorQPvPSplAqdo5hzahGVg== X-Google-Smtp-Source: AGs4zMZd9v+1Ww78d4LGuSaMYjywXlThtwrumAD3pHh+J6lTgyXnsmmp2FAovHTOAHzDH9+etBagBQ== X-Received: by 10.233.232.13 with SMTP id a13mr2482048qkg.186.1512047213388; Thu, 30 Nov 2017 05:06:53 -0800 (PST) Received: from tbecker-rhat.redhat.com ([189.7.118.40]) by smtp.googlemail.com with ESMTPSA id c72sm2862490qka.31.2017.11.30.05.06.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Nov 2017 05:06:52 -0800 (PST) From: Thiago Rafael Becker To: bfields@fieldses.org Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Thiago Rafael Becker Subject: [PATCH 2/3, V2] kernel: Move groups_sort to the caller of set_groups. Date: Thu, 30 Nov 2017 11:04:56 -0200 Message-Id: <20171130130457.11429-3-thiago.becker@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171130130457.11429-1-thiago.becker@gmail.com> References: <20171130130457.11429-1-thiago.becker@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 The responsibility for calling groups_sort is now on the caller of set_groups. Signed-off-by: Thiago Rafael Becker --- kernel/groups.c | 1 + kernel/uid16.c | 1 + net/sunrpc/svcauth_unix.c | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/kernel/groups.c b/kernel/groups.c index 4c9c9ed..17073a9 100644 --- a/kernel/groups.c +++ b/kernel/groups.c @@ -208,6 +208,7 @@ SYSCALL_DEFINE2(setgroups, int, gidsetsize, gid_t __user *, grouplist) return retval; } + groups_sort(group_info); retval = set_current_groups(group_info); put_group_info(group_info); diff --git a/kernel/uid16.c b/kernel/uid16.c index ce74a49..ef1da2a 100644 --- a/kernel/uid16.c +++ b/kernel/uid16.c @@ -192,6 +192,7 @@ SYSCALL_DEFINE2(setgroups16, int, gidsetsize, old_gid_t __user *, grouplist) return retval; } + groups_sort(group_info); retval = set_current_groups(group_info); put_group_info(group_info); diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c index f81eaa8..91e3d34 100644 --- a/net/sunrpc/svcauth_unix.c +++ b/net/sunrpc/svcauth_unix.c @@ -20,6 +20,7 @@ #include "netns.h" +void groups_sort(struct group_info *group_info); /* * AUTHUNIX and AUTHNULL credentials are both handled here. @@ -520,6 +521,12 @@ static int unix_gid_parse(struct cache_detail *cd, ug.gi->gid[i] = kgid; } + /* Sort the groups before inserting this entry + * into the cache to avoid future corrutpions + * by multiple simultaneous attempts to sort this + * entry. + */ + groups_sort(ug.gi); ugp = unix_gid_lookup(cd, uid); if (ugp) { struct cache_head *ch;