Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9045010pxu; Mon, 28 Dec 2020 05:17:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJwINBGFmZQgfciEBvRcMJ/k6NwsmpMX/OPe3GBB/ELqK6z5RsM7olxeNAB8DA2LgKD85Nbj X-Received: by 2002:a50:ee1a:: with SMTP id g26mr42346776eds.68.1609161446063; Mon, 28 Dec 2020 05:17:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161446; cv=none; d=google.com; s=arc-20160816; b=XNiBJlmYGVxkevbepkd/FpHDZGUHTjb9hPWlqeo0VOTLW8LuUqrTNQByeGsS28rsg7 4Ie7Xe2bgNBZjsXuBQ+dgzNr3kLtP26xYF//QyTNzfTeNfRc4ymBaBcF8s7xBH5HbTLF PwxPVWUmXgRnUbmmIFFLIiVVKoaScJt/ieRvTeYHdQ42En8pV3c7qd91TEnXzg1xfgLK Q7gie2W3LkrfVZVuUsjJ/HuN7lqyf6DcEPUBUckesgzv8gar5G6hOqAyoSsPA/bgyX2Y vQS+d3fW5r4N4HkzFX1YUYW1VVIitvCiAAOrYwB9lT9hUHd+249lF+zApiLXpNazzsW1 wdtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J4LQ9ZwpHuzNudsz1nCpdXo8TtvWcRBfynTNv5OERfY=; b=ZjB+PF+IrHn1xPSbtdbkiBEjm8fBZOQZsYNhFHvB0QUlykuHd9NMPIiEdRKOPKxnKT ldyZybJ5yufgTZz9fZdCx7JRVH0egpNGvX7F+4R7MCxyW6TAUNoyUfcTVJAA70to/1Tg LS4qAzOBkEecnQao8XfZIHL9zOm/HyY/LPB4CWfAFLmSiCIkKbxP94lhreJ7B0tj8oV9 jJ7MeaJsqjsBuDJU4ihO9/5RkrYFI5rjP2DB2Hzg7Cq2bTKnXUBmT1hyzynd4anj4zim YDy6VthJ1i9PEOJDgDNoQC8NupSXh0r7pUu8tEfKGdCfeJnEGD3ARxyWiIm5d0b6DBjY niOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Leb8ohIa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v14si18960612ejb.322.2020.12.28.05.17.02; Mon, 28 Dec 2020 05:17:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Leb8ohIa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731258AbgL1NNi (ORCPT + 99 others); Mon, 28 Dec 2020 08:13:38 -0500 Received: from mail.kernel.org ([198.145.29.99]:41476 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732227AbgL1NN3 (ORCPT ); Mon, 28 Dec 2020 08:13:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9062120728; Mon, 28 Dec 2020 13:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161169; bh=to4sIerXwMYJ2477U9/vkaK71bkbQN/73hAhCf5gOUE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Leb8ohIaaaZy2bjq/ojdX6f5e3cgzYxlMZQIxUl1lTeix+MB5CLsC/gMsKyM1UuxV OPAyyJ8hE28HRpUwy1tEbj7YkeY1xW5uifGxgAToPiXy8g6Gr+BW+VLZPewGULI/HG 6fO2XST4E2VuB+DfJ69eVJtGcd7+fRMn1FDEDnjU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ondrej Mosnacek , Scott Mayhew , Olga Kornievskaia , Trond Myklebust , Sasha Levin Subject: [PATCH 4.14 124/242] NFSv4.2: condition READDIRs mask for security label based on LSM state Date: Mon, 28 Dec 2020 13:48:49 +0100 Message-Id: <20201228124910.801548563@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Olga Kornievskaia [ Upstream commit 05ad917561fca39a03338cb21fe9622f998b0f9c ] Currently, the client will always ask for security_labels if the server returns that it supports that feature regardless of any LSM modules (such as Selinux) enforcing security policy. This adds performance penalty to the READDIR operation. Client adjusts superblock's support of the security_label based on the server's support but also current client's configuration of the LSM modules. Thus, prior to using the default bitmask in READDIR, this patch checks the server's capabilities and then instructs READDIR to remove FATTR4_WORD2_SECURITY_LABEL from the bitmask. v5: fixing silly mistakes of the rushed v4 v4: simplifying logic v3: changing label's initialization per Ondrej's comment v2: dropping selinux hook and using the sb cap. Suggested-by: Ondrej Mosnacek Suggested-by: Scott Mayhew Signed-off-by: Olga Kornievskaia Fixes: 2b0143b5c986 ("VFS: normal filesystems (and lustre): d_inode() annotations") Signed-off-by: Trond Myklebust Signed-off-by: Sasha Levin --- fs/nfs/nfs4proc.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index bb899a6fe8ac0..9f2ba4874f10f 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c @@ -4445,12 +4445,12 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, u64 cookie, struct page **pages, unsigned int count, bool plus) { struct inode *dir = d_inode(dentry); + struct nfs_server *server = NFS_SERVER(dir); struct nfs4_readdir_arg args = { .fh = NFS_FH(dir), .pages = pages, .pgbase = 0, .count = count, - .bitmask = NFS_SERVER(d_inode(dentry))->attr_bitmask, .plus = plus, }; struct nfs4_readdir_res res; @@ -4465,9 +4465,15 @@ static int _nfs4_proc_readdir(struct dentry *dentry, struct rpc_cred *cred, dprintk("%s: dentry = %pd2, cookie = %Lu\n", __func__, dentry, (unsigned long long)cookie); + if (!(server->caps & NFS_CAP_SECURITY_LABEL)) + args.bitmask = server->attr_bitmask_nl; + else + args.bitmask = server->attr_bitmask; + nfs4_setup_readdir(cookie, NFS_I(dir)->cookieverf, dentry, &args); res.pgbase = args.pgbase; - status = nfs4_call_sync(NFS_SERVER(dir)->client, NFS_SERVER(dir), &msg, &args.seq_args, &res.seq_res, 0); + status = nfs4_call_sync(server->client, server, &msg, &args.seq_args, + &res.seq_res, 0); if (status >= 0) { memcpy(NFS_I(dir)->cookieverf, res.verifier.data, NFS4_VERIFIER_SIZE); status += args.pgbase; -- 2.27.0