From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753183AbdLEOFi (ORCPT ); Tue, 5 Dec 2017 09:05:38 -0500 Received: from mail-qt0-f194.google.com ([209.85.216.194]:44054 "EHLO mail-qt0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752880AbdLEOFe (ORCPT ); Tue, 5 Dec 2017 09:05:34 -0500 X-Google-Smtp-Source: AGs4zMY4LXahOXWGlmMGkXztxqBonu0MNEjOSdDS5HwLzCxDlg4QG4TsO3oubPp431ll5315EzGc5g== 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 0/3 v3] Move groups_sort outisde of set_groups Date: Tue, 5 Dec 2017 12:05:09 -0200 Message-Id: <20171205140512.13349-1-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-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In cases where group_info is cached (e.g. sunrpc), multiplpe threads may call set_groups with a freshly created group_info cache (e.g. nfsd), and attempt to sort them simultaneously, which configures a race condition that can overwrite some groups in the cache and lead to errors. In the case of nfsd, the client was receiving EPERM if the group used to provide authorization was overwritten by this race condition. In an email exchange with bfields, we agreed that it seems unintuitive that the groups are sorted on set_groups, and that it would be better to move the responsibility of sorting to the caller of set_groups. These patches: - Export groups_sort in include/linux/cred.h - Add a call to groups_sort after the groups are inserted in group_info - Remove the call to sort_groups from set_groups Thiago Rafael Becker (3): kernel: make groups_sort globally visible kernel: Move groups_sort to the caller of set_groups. kernel: set_groups doesn't call groups_sort anymore. include/linux/cred.h | 1 + kernel/groups.c | 6 ++++-- kernel/uid16.c | 1 + net/sunrpc/svcauth_unix.c | 7 +++++++ 4 files changed, 13 insertions(+), 2 deletions(-) -- 2.9.5