Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3687477ybv; Mon, 10 Feb 2020 04:43:22 -0800 (PST) X-Google-Smtp-Source: APXvYqy5eFjo0xrc2gjGg/575wqiPreZQpsDwcAW55WiX1ogiOWDcYh7DF4OgeODlAH6jENC8Z53 X-Received: by 2002:a05:6830:1e72:: with SMTP id m18mr865442otr.226.1581338602528; Mon, 10 Feb 2020 04:43:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581338602; cv=none; d=google.com; s=arc-20160816; b=b3As/C7NlluHLaMAO6w2a9zzu2YeD2fSZ0iHaDhH7RexzGtEetV6e84lLC8qu4uI77 WqO5bbSIqmXpOVmP8/dvxXSKTQ11vZg5HjGpiV3lpLgnG1GAB4T8IbA/TxlkHjYXAXt8 Iul/Ay3cXe4+yZE6hOJt5f2kE7b8Ygtn10601sVNlq34Z3tLWZBiK85+IJIgfPyVkrq1 /foI6N2xqCG6ZtF/kIFdzXL11RxACI0Mu8/3kg/5PekFNGD8dzCopTtD1bSgdgaZqsCq dFtN8rJmiK/E+jn7nQldVr1PZjSJlrE0grHdxRdeetgliVed9C4QRNjvzAYJIbHM/ZXg NZWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=t0/x8JTQ/ybvJou7PAVv1hNyXBX1jpu7PWl5DS/Pk3I=; b=IENAjPKDn1i3gaBh3aMApRu/G08xM1CpQ+/QsC9TJs9pEvnS+zapqFpOGw1H77aHNp Ir9oCGOGV89m0+iWqxoUeI9VFOm1t2WsP6GUzdXYcWZ/yemkfLB3YNUx2ohu1GW8blDp g4EUJLdPC9gHrjD1OpO0RdYC6n1BvwruiKYefDngBV/4nHJvff5Nh2oKakiUpYdznIq8 0ToL1X5tztlCM7FNN90pf5bvlZ8X3eh7GZwdcjG4bjRCFjoJlTDnhB3Awy42y9X5j3Y3 QZzVtlcBIrQHS9Z6bHTFZFXr46jLunLehf3guzZsyrTo+7wRU3I6SFL4J7dHWmpruFW0 2ZLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="yEWz99f/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s8si134242oic.7.2020.02.10.04.43.10; Mon, 10 Feb 2020 04:43:22 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="yEWz99f/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730159AbgBJMmI (ORCPT + 99 others); Mon, 10 Feb 2020 07:42:08 -0500 Received: from mail.kernel.org ([198.145.29.99]:36194 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728793AbgBJMjI (ORCPT ); Mon, 10 Feb 2020 07:39:08 -0500 Received: from localhost (unknown [209.37.97.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7452C21739; Mon, 10 Feb 2020 12:39:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581338347; bh=B5hLKhpq6cjqTTsTyMRcu297qAOTyJ+oN2hGM8KnKHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yEWz99f/Mdsw98LwyyhK7jSyFw1sOl3hqcuZ1p0m/oaOuW4rQSZ0N6JE2hRjTchvR 6cAyOGnnef45Ws94ZAVVOf5XPUYMaMg0Dg9VS5Sy0rseESkMko1Avo7noRGFEJ+2um OvgsajcL0WGo9I7uckFciHQk3pz1ximcrjZZaybw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Aurelien Aptel , Steve French , Pavel Shilovsky Subject: [PATCH 5.4 303/309] cifs: fix mode bits from dir listing when mounted with modefromsid Date: Mon, 10 Feb 2020 04:34:19 -0800 Message-Id: <20200210122436.056141941@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200210122406.106356946@linuxfoundation.org> References: <20200210122406.106356946@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Aurelien Aptel commit e3e056c35108661e418c803adfc054bf683426e7 upstream. When mounting with -o modefromsid, the mode bits are stored in an ACE. Directory enumeration (e.g. ls -l /mnt) triggers an SMB Query Dir which does not include ACEs in its response. The mode bits in this case are silently set to a default value of 755 instead. This patch marks the dentry created during the directory enumeration as needing re-evaluation (i.e. additional Query Info with ACEs) so that the mode bits can be properly extracted. Quick repro: $ mount.cifs //win19.test/data /mnt -o ...,modefromsid $ touch /mnt/foo && chmod 751 /mnt/foo $ stat /mnt/foo # reports 751 (OK) $ sleep 2 # dentry older than 1s by default get invalidated $ ls -l /mnt # since dentry invalid, ls does a Query Dir # and reports foo as 755 (WRONG) Signed-off-by: Aurelien Aptel Signed-off-by: Steve French CC: Stable Reviewed-by: Pavel Shilovsky Signed-off-by: Greg Kroah-Hartman --- fs/cifs/readdir.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/fs/cifs/readdir.c +++ b/fs/cifs/readdir.c @@ -174,7 +174,8 @@ cifs_fill_common_info(struct cifs_fattr * may look wrong since the inodes may not have timed out by the time * "ls" does a stat() call on them. */ - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) + if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) || + (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)) fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL &&