Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3918895imu; Mon, 7 Jan 2019 11:55:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/Xz0FqYjvwiTkX/ZHbiMUujJ9bGGt0fIbTTjaY9XtsuJ2DnU5jlHSIFPeExOXA3/1GKANXb X-Received: by 2002:a62:8a51:: with SMTP id y78mr63784799pfd.35.1546890957335; Mon, 07 Jan 2019 11:55:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546890957; cv=none; d=google.com; s=arc-20160816; b=oXxPmSY703a52ie3UAnIfuHSV8/ItoWKkD5iX8fqXQXOY/qTehXdubtI3kfvKaZsAW QSRX4b1fFny3hy1pDga+vQmlpz2MYH9cpe9BIOEUIJjD4j2jvN9GOJsf8eMlox7yc8Y2 EgwT0YO2QIn/tLj2PomC/sc40Y/aCPOzEY29SGUcWL6ydo2JN4j+vHLFzbOfr9iAvdWX n5gUawnFqvVMKILeB+uRxaLws3ysFy4VInEbfl4698fYpx4yNyEYeseliPNHDB8YSjAS m8RX6nf2QxVTU9RQaXuLZNW6Ul2lIbBgn/TiMrYPhuhjGrtl7Erms81FJsD2CHnbIZKc 4d7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=GLx6mKVNS7mQ/rFAFpF8Lz4QyeUdXHV8Txo29+ehDYY=; b=owqDnxMh5wXP6wVW4p1rhmaMo6as7nmDMjMxx9NmmFLGzdXf/brCmU7LqljYZqNf5o kJl4DZOAKBCGxj4cx7AePqUvSuaC749bIYyCOcuWB6K01wL9AIMcuyf3cN2wlDMgW0D0 cWctRaZipaouNoZkANG0xSaBjIfEaDargoXA6ZPPtB0MRkiETh2bfoKb6/zylXDxJbbz 4yN0neIUxOhFTU9PazXAvHckrxFuSTe7v2U8MwbabFswPhLu2gbcIKDDDinp4RMuTMf8 ObizFNSm8Gq0YsPBxW4MMtlRe8IHc0ZAJON9zF0Y5dQgz1QXtyDrpKD9sHccoy3M7GBR stfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=u2MQP8qq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d32si10288071pla.136.2019.01.07.11.55.41; Mon, 07 Jan 2019 11:55:57 -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=@oracle.com header.s=corp-2018-07-02 header.b=u2MQP8qq; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727268AbfAGSCJ (ORCPT + 99 others); Mon, 7 Jan 2019 13:02:09 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:44498 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726681AbfAGSCI (ORCPT ); Mon, 7 Jan 2019 13:02:08 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x07HxWc6103545; Mon, 7 Jan 2019 18:02:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2018-07-02; bh=GLx6mKVNS7mQ/rFAFpF8Lz4QyeUdXHV8Txo29+ehDYY=; b=u2MQP8qqf9FUTB8WEzq/mCDDH7XjBlhFVEutjVkG20ZvQ93qwPafOx02W3qJ9sZu1a2+ TpnJToS9ohaxefivN5f8Mfr4Jg7EvV2DTmbHNikloDIRhdE9XWqeYRUdKYQz/SEF5NPd zgLbMx1CJlyYR3CYQLWPTpHiv4ZysFK/DBd19DivOd41zesG094SQT7Ndll0ZTrJOCuM d6yRJqQ52UMmsECocxyJkfAoHLqZ8U3mIYmnleGO5bm/eoKS/BCgxa+L2J0dxbJtoJ99 zTJP04AfcutKl5twPuL34IeOQzdvrBuZDTn3m191hdu4M5nNb6feq1RTorSfoQ2soXcs hA== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2130.oracle.com with ESMTP id 2ptm0ty9jf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 07 Jan 2019 18:02:04 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id x07I22BV018379 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 7 Jan 2019 18:02:03 GMT Received: from abhmp0018.oracle.com (abhmp0018.oracle.com [141.146.116.24]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x07I22GT022111; Mon, 7 Jan 2019 18:02:02 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 07 Jan 2019 10:02:01 -0800 Date: Mon, 7 Jan 2019 10:02:00 -0800 From: "Darrick J. Wong" To: Su Yanjun Cc: linux-xfs@vger.kernel.org, linux-kernel@vger.kernel.org, suyanjun218@gmail.com Subject: Re: [PATCH] xfs: correct statx's result_mask value Message-ID: <20190107180200.GK12689@magnolia> References: <1546854790-5233-1-git-send-email-suyj.fnst@cn.fujitsu.com> <20190107175229.GJ12689@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190107175229.GJ12689@magnolia> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9129 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901070154 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jan 07, 2019 at 09:52:29AM -0800, 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... > > ...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? Ignore the above; vfs_getattr_nosec actually does zero the kstat buffer before calling ->getattr. We also set result_mask to STATX_BASIC_STATS. Now I'm really confused: why is this necessary at all? What incorrect masks did you see, and under what circumstances? --D > --D > > > > > if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE) > > stat->attributes |= STATX_ATTR_IMMUTABLE; > > -- > > 2.7.4 > > > > > >