From patchwork Mon Dec 4 19:03:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thiago Becker X-Patchwork-Id: 10091337 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 0FD0F60327 for ; Mon, 4 Dec 2017 19:04:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0122B290AA for ; Mon, 4 Dec 2017 19:04:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E971E290FA; Mon, 4 Dec 2017 19:04:11 +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 964AD290AA for ; Mon, 4 Dec 2017 19:04:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752730AbdLDTEJ (ORCPT ); Mon, 4 Dec 2017 14:04:09 -0500 Received: from mail-ua0-f195.google.com ([209.85.217.195]:36394 "EHLO mail-ua0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751546AbdLDTEB (ORCPT ); Mon, 4 Dec 2017 14:04:01 -0500 Received: by mail-ua0-f195.google.com with SMTP id w47so13263228uah.3; Mon, 04 Dec 2017 11:04:00 -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=sFecUdEpVLCBTS6LdV+Cn4dm7oCFoc5WdNCjr49Qy74=; b=JKyvI47REGeeo3ynytV6by82RJhdYv6H++G2WjN/z1eYJuaYWr3K9uDubiwmcuhgHB BQIknaz5DVz3N0Ol07IUGlvHkNA6/DMwWH6wA4shewHYXzG2lJq5Gz1ifk9tz7VSEEM2 ONd3qKgloymTDADR/ycWrHPE3PuEp2MOchPV3bztIsl76iLMZCTHv1as+WJb3n67MxeY pkuosS3Ey+v1Ojd0WblF/g6rhB7zp5/J8NCY3bwj+vHxOqM4lS1KFz20IyOYpQWA+k82 4C8QKVCO+06k/MLcRJKY6/uIu0OfllGhqsiWeQk44a5B7YqOxRSJJv8UIW07GLQz0cNs h5wQ== 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=sFecUdEpVLCBTS6LdV+Cn4dm7oCFoc5WdNCjr49Qy74=; b=KF1oxY+vBgMEbVlxYr5OU7bpqhX9kciDkCimTBlaWKy1YLuNuWPzkDv9qW8rR8fGzy LYYtSHHO0feyCv7bNAC8UUEVTC3YgTkMAzpMYvUQpCCDZd2Td2HbrmZl8FsdAXbsbAr4 /O+5PVk7ZJsn1+jJBboQSZnbq0lUnZvn66oB3onZW5MHsLj8u7hiIQ+Bdi0fLFQXKIGu g9Lg6KA9nUalUywuqS5VShumZkLOA6vT85cCs7kqeeF/gvHBHI2a/zlcAb2TFzvsNM3v SkSBECBQQk89oY3h+w13rXPQaQ8wGGswpvvOHLIND3ReX7XFwqv71SjyhZgvtP1kYJXQ qumw== X-Gm-Message-State: AKGB3mJs/+/MMbevNMhI8CtyYueg+cj1zJSkB2BMEuFO3aMQS+T3Gw0R GtMMdOrubna8nenHEPiC8w== X-Google-Smtp-Source: AGs4zMa6RyrvIN3CRLAvUj13pcU8il/DnNJor8ab4QnCJdC+rveINVCyquuzZrxPF10GbRJ+Tok6xA== X-Received: by 10.176.24.66 with SMTP id j2mr41607uag.79.1512414240193; Mon, 04 Dec 2017 11:04:00 -0800 (PST) Received: from tbecker-rhat.redhat.com ([201.37.68.249]) by smtp.googlemail.com with ESMTPSA id o12sm2941797uaj.10.2017.12.04.11.03.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Dec 2017 11:03:59 -0800 (PST) From: Thiago Rafael Becker To: bfields@fieldses.org, neilb@suse.com Cc: linux-nfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Thiago Rafael Becker Subject: [PATCH 2/3, v3] kernel: Move groups_sort to the caller of set_groups. Date: Mon, 4 Dec 2017 17:03:23 -0200 Message-Id: <20171204190324.6629-3-thiago.becker@gmail.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171204190324.6629-1-thiago.becker@gmail.com> References: <20171204190324.6629-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 740b67d..94e2ac0 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;