Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp4336309imu; Mon, 7 Jan 2019 21:17:42 -0800 (PST) X-Google-Smtp-Source: ALg8bN6WStr/aM3gsjMbhG0kxE7vhaA/bkXqJ9iptWkzFC9W7ynQ+gA3GNm2DhslXBZOQfqabtIE X-Received: by 2002:a62:710a:: with SMTP id m10mr356710pfc.69.1546924662635; Mon, 07 Jan 2019 21:17:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546924662; cv=none; d=google.com; s=arc-20160816; b=y3zg2dWDTUgxuNltI9uZGiVe7F6RtY1OIWECo3y5ktePkm8aixyRPfb2ryx69PnDd6 k9YTP+Fmu9vLQ4xg9rBtPKfp8tL0XoEHiNiaCdLcEl7jxJnG4KpKRmYfJejG0E0n2a6p dn2OzICKzfw538XvIaYn7gHjX2ZGO3bqrY6jDh/ZSO3ktu1ty8YdPCbXIsqcNE8qhPYg uaFQMtdrQEvCfQ9uUeWXCpP4OHQH1kYEftgA0LMfJ5xtyBOAAECgUqhy4z9lznnzN11h 1FYwRRGLWKRMdiZZr/DknwAsARwGqhOXAdKeV3GvrkDrCShXBGSDq+h/S9Tf7xzFM4vo HyNA== 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:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=7KN4DAzWB12MFmywi7ee6bsj7XLH6K9XJAB8f1zSZxY=; b=ixObicJE/UpoVAR21SIDnszzI0Zdjo1tF3R9PZb6fJWOOoooha1NzJd1mpSczYBIJF Z/NEnJvPyIeffAlxGiMmn9Ly5cR8B4E2XpY8zqJCHQNbRw7q30MCay//YeH7fKPn6nLd DjXmc9jfk5K25J+nE6+UYCVorMuiX1VQaxVP3tc+32yy/C70sOVXvYrpwuUpo1b09YRd DBSTmBUEnqRgGc/PtgQbtC1S96ZJ/q6k2U6o/+JCe7326CH5G8IeBE5oo1u+qNxyvb0l FRRMCbf8Qcd2B/qO7GjJjbpqI+MidYquSSRhOSYwYzFJXPM5AdvAWCyctaq/paGSxBXf zsYA== ARC-Authentication-Results: i=1; mx.google.com; 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 b24si8862930pgi.308.2019.01.07.21.17.27; Mon, 07 Jan 2019 21:17:42 -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; 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 S1727633AbfAHFPZ (ORCPT + 99 others); Tue, 8 Jan 2019 00:15:25 -0500 Received: from mail.cn.fujitsu.com ([183.91.158.132]:11274 "EHLO heian.cn.fujitsu.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725838AbfAHFPZ (ORCPT ); Tue, 8 Jan 2019 00:15:25 -0500 X-IronPort-AV: E=Sophos;i="5.56,452,1539619200"; d="scan'208";a="51530011" Received: from unknown (HELO cn.fujitsu.com) ([10.167.33.5]) by heian.cn.fujitsu.com with ESMTP; 08 Jan 2019 13:15:17 +0800 Received: from G08CNEXCHPEKD03.g08.fujitsu.local (unknown [10.167.33.85]) by cn.fujitsu.com (Postfix) with ESMTP id 47EEB4BAC81A; Tue, 8 Jan 2019 13:15:15 +0800 (CST) Received: from [10.167.225.53] (10.167.225.53) by G08CNEXCHPEKD03.g08.fujitsu.local (10.167.33.89) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 8 Jan 2019 13:15:14 +0800 Subject: Re: [PATCH] xfs: correct statx's result_mask value To: "Darrick J. Wong" CC: Eric Sandeen , , , References: <1546854790-5233-1-git-send-email-suyj.fnst@cn.fujitsu.com> <20190107175229.GJ12689@magnolia> <2b27e2ec-368b-d24c-8443-e265f87e417c@sandeen.net> <67e03af1-6e11-4236-76e6-6127b6cfb9b9@cn.fujitsu.com> <20190108050739.GQ12689@magnolia> From: "Su Yanjun " Message-ID: <5c103aa0-8711-ceb3-38f8-dffe983526ff@cn.fujitsu.com> Date: Tue, 8 Jan 2019 13:15:11 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20190108050739.GQ12689@magnolia> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit X-Originating-IP: [10.167.225.53] X-yoursite-MailScanner-ID: 47EEB4BAC81A.AE083 X-yoursite-MailScanner: Found to be clean X-yoursite-MailScanner-From: suyj.fnst@cn.fujitsu.com X-Spam-Status: No Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/8/2019 1:07 PM, Darrick J. Wong wrote: > On Tue, Jan 08, 2019 at 12:58:43PM +0800, Su Yanjun wrote: >> >> On 1/8/2019 2:04 AM, Eric Sandeen wrote: >>> On 1/7/19 11:52 AM, Darrick J. Wong wrote: >>>> On Mon, Jan 07, 2019 at 04:53:10AM -0500, Su Yanjun wrote: >>>>> For statx syscall, xfs return the wrong result_mask. >>>>> >>>>> Signed-off-by: Su Yanjun >>>>> --- >>>>> fs/xfs/xfs_iops.c | 3 +++ >>>>> 1 file changed, 3 insertions(+) >>>>> >>>>> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c >>>>> index f48ffd7..3811457 100644 >>>>> --- a/fs/xfs/xfs_iops.c >>>>> +++ b/fs/xfs/xfs_iops.c >>>>> @@ -521,6 +521,9 @@ xfs_vn_getattr( >>>>> stat->btime.tv_nsec = ip->i_d.di_crtime.t_nsec; >>>>> } >>>>> } >>>>> + >>>>> + /* Only return mask that we care */ >>>>> + stat->result_mask &= request_mask; >>>> Why not just: >>>> >>>> stat->result_mask = STATX_BASIC_STATS; >>>> >>>> at the top of the function? >>>> >>>> I don't see the need to mask off result_mask at all, since we could some >>>> day elect to return more than what's in request_mask... >> When we run xfstests with nfs, the generic/423 case runs failed. So i review >> the nfs' >> nfs_getattr code it does validate the request_mask. >> >> Then i review the xfs' getattr code, it has no such check. Whatever >> request_mask >>  is set, the stat's result_mask always the 0x7ff. > Yes, statx can return more data than what userspace callers ask for: > >> Maybe it has Unclear semantics about statx's result_mask. > "A filesystem may also fill in fields that the caller didn't ask for if > it has values for them available and the information is available at no > extra cost. If this happens, the corresponding bits will be set in > stx_mask." > > --D I get it, then the testcase generic/423 may need update in xfstests. Thanks for your reply. >>>> ...waitaminute, are you seeing garbage in the result_mask that's >>>> returned to userspace? I also noticed the vfs stat functions declare >>>> "struct kstat stat;" without explicitly zeroing the structure fields, >>>> which means (I think) that we can leak stack information if the kernel >>>> isn't built with the stackleak plugin? >> No such problem. >>> A clear problem statement and reproducer steps would be hugely useful >>> here. >>> >>> -Eric >> Thanks, >> Su >> >> >