[{"id":3681204,"web_url":"http://patchwork.ozlabs.org/comment/3681204/","msgid":"<20260422233823.GA3778109@frogsfrogsfrogs>","list_archive_url":null,"date":"2026-04-22T23:38:23","subject":"Re: [PATCH v9 01/17] fs: Move file_kattr initialization to callers","submitter":{"id":77032,"url":"http://patchwork.ozlabs.org/api/people/77032/","name":"Darrick J. Wong","email":"djwong@kernel.org"},"content":"On Wed, Apr 22, 2026 at 07:29:55PM -0400, Chuck Lever wrote:\n> From: Chuck Lever <chuck.lever@oracle.com>\n> \n> fileattr_fill_xflags() and fileattr_fill_flags() memset the\n> entire file_kattr struct before populating select fields, so\n> callers cannot pre-set fields in fa->fsx_xflags without having\n> their values clobbered. Darrick Wong noted that a function\n> named \"fill_xflags\" touching more than xflags forces callers\n> to know implementation details beyond its apparent scope.\n> \n> Drop the memset from both fill functions and initialize at the\n> entry points instead: ioctl_setflags(), ioctl_fssetxattr(),\n> the file_setattr() syscall, and xfs_ioc_fsgetxattra() now\n> declare fa with an aggregate initializer. ioctl_getflags(),\n> ioctl_fsgetxattr(), and the file_getattr() syscall already\n> aggregate-initialize fa to pass flags_valid/fsx_valid hints\n> into vfs_fileattr_get().\n> \n> Subsequent patches rely on this so that ->fileattr_get()\n> handlers can set case-sensitivity flags (FS_XFLAG_CASEFOLD,\n> FS_XFLAG_CASENONPRESERVING) in fa->fsx_xflags before the fill\n> functions run.\n> \n> Suggested-by: Darrick J. Wong <djwong@kernel.org>\n> Reviewed-by: Jan Kara <jack@suse.cz>\n> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>\n\nHeh, I never did review this one so \nReviewed-by: \"Darrick J. Wong\" <djwong@kernel.org>\n\n--D\n\n> ---\n>  fs/file_attr.c     | 12 ++++--------\n>  fs/xfs/xfs_ioctl.c |  2 +-\n>  2 files changed, 5 insertions(+), 9 deletions(-)\n> \n> diff --git a/fs/file_attr.c b/fs/file_attr.c\n> index da983e105d70..f429da66a317 100644\n> --- a/fs/file_attr.c\n> +++ b/fs/file_attr.c\n> @@ -15,12 +15,10 @@\n>   * @fa:\t\tfileattr pointer\n>   * @xflags:\tFS_XFLAG_* flags\n>   *\n> - * Set ->fsx_xflags, ->fsx_valid and ->flags (translated xflags).  All\n> - * other fields are zeroed.\n> + * Set ->fsx_xflags, ->fsx_valid and ->flags (translated xflags).\n>   */\n>  void fileattr_fill_xflags(struct file_kattr *fa, u32 xflags)\n>  {\n> -\tmemset(fa, 0, sizeof(*fa));\n>  \tfa->fsx_valid = true;\n>  \tfa->fsx_xflags = xflags;\n>  \tif (fa->fsx_xflags & FS_XFLAG_IMMUTABLE)\n> @@ -48,11 +46,9 @@ EXPORT_SYMBOL(fileattr_fill_xflags);\n>   * @flags:\tFS_*_FL flags\n>   *\n>   * Set ->flags, ->flags_valid and ->fsx_xflags (translated flags).\n> - * All other fields are zeroed.\n>   */\n>  void fileattr_fill_flags(struct file_kattr *fa, u32 flags)\n>  {\n> -\tmemset(fa, 0, sizeof(*fa));\n>  \tfa->flags_valid = true;\n>  \tfa->flags = flags;\n>  \tif (fa->flags & FS_SYNC_FL)\n> @@ -325,7 +321,7 @@ int ioctl_setflags(struct file *file, unsigned int __user *argp)\n>  {\n>  \tstruct mnt_idmap *idmap = file_mnt_idmap(file);\n>  \tstruct dentry *dentry = file->f_path.dentry;\n> -\tstruct file_kattr fa;\n> +\tstruct file_kattr fa = {};\n>  \tunsigned int flags;\n>  \tint err;\n>  \n> @@ -357,7 +353,7 @@ int ioctl_fssetxattr(struct file *file, void __user *argp)\n>  {\n>  \tstruct mnt_idmap *idmap = file_mnt_idmap(file);\n>  \tstruct dentry *dentry = file->f_path.dentry;\n> -\tstruct file_kattr fa;\n> +\tstruct file_kattr fa = {};\n>  \tint err;\n>  \n>  \terr = copy_fsxattr_from_user(&fa, argp);\n> @@ -431,7 +427,7 @@ SYSCALL_DEFINE5(file_setattr, int, dfd, const char __user *, filename,\n>  \tstruct path filepath __free(path_put) = {};\n>  \tunsigned int lookup_flags = 0;\n>  \tstruct file_attr fattr;\n> -\tstruct file_kattr fa;\n> +\tstruct file_kattr fa = {};\n>  \tint error;\n>  \n>  \tBUILD_BUG_ON(sizeof(struct file_attr) < FILE_ATTR_SIZE_VER0);\n> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c\n> index 46e234863644..ed9b4846c05f 100644\n> --- a/fs/xfs/xfs_ioctl.c\n> +++ b/fs/xfs/xfs_ioctl.c\n> @@ -517,7 +517,7 @@ xfs_ioc_fsgetxattra(\n>  \txfs_inode_t\t\t*ip,\n>  \tvoid\t\t\t__user *arg)\n>  {\n> -\tstruct file_kattr\tfa;\n> +\tstruct file_kattr\tfa = {};\n>  \n>  \txfs_ilock(ip, XFS_ILOCK_SHARED);\n>  \txfs_fill_fsxattr(ip, XFS_ATTR_FORK, &fa);\n> \n> -- \n> 2.53.0\n> \n>","headers":{"Return-Path":"\n <linux-cifs+bounces-11031-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=ezVtpBVv;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-cifs+bounces-11031-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"ezVtpBVv\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g1G3r2vJTz1yDD\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 23 Apr 2026 09:42:32 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 7BD3B300BDBF\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 23:38:25 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 7C0A63A4523;\n\tWed, 22 Apr 2026 23:38:24 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 546162BE026;\n\tWed, 22 Apr 2026 23:38:24 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id E08E0C19425;\n\tWed, 22 Apr 2026 23:38:23 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776901104; cv=none;\n b=fIAYGfjGQA21/RPJ1h5GjciAq/MOuenwNG2lEA+EsmzKnukCzZq7hG1VwFtX8TJdgt+kE9WKtPRoTr0nj1mRo2KhgKg0g8pMhZkK/uHmZX6GMDvFgvh9OSdsB+/tV9zxajmRWl1aTnl8H0D4V7JN70qiRb6HUSbQbVCtRr5Vhvs=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776901104; c=relaxed/simple;\n\tbh=cA0ZR5J/e3BV4LxJ7qZBjOuZwp2IQKJzAscafkI55UU=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=iUArHdIYHab4ipN0JXC30b9hEJ5+9VicoFMxtL1sPP2smJuZpXVeO15gmTk6/3Z3NyTe4McsHuBUGfCKlYfPOdLRLbeGwzo/Rjlbs/z38pxdIyLKnQKiFdezb3dO60bg7zvfv1Jmrv7Vsh5Chyq6nrfXy0UzJHTi9uNbxDKUyhA=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=ezVtpBVv; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1776901104;\n\tbh=cA0ZR5J/e3BV4LxJ7qZBjOuZwp2IQKJzAscafkI55UU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=ezVtpBVv1QMF6X9CFXadmDeGdwQ+lK71l5/X2+S0Y2NUH1w14TuTXFtm/J/iaIcGu\n\t EF5cAl6y2Vhv2hCcnNmgTxoIo1dwdxhPtlWq9cNpo4IM7RZ2+h76UMiOie6HmtapIl\n\t 3HKX1mi1BY4P8U98ZIxqrv59ejKNYkgTyRrlkaaWeC8M9hf5SVq1yqT4N6R3WlgVa8\n\t 1paua8ccPeMwKAurOHnqmV/AyxV0VYYPv23r0lnFDZt5eaLdWsIOFVXsa14SrCwQZ0\n\t MiM3BzfGaTinld59+KmN1n63TEaa1cSBjrbe1rwlsaABMnGhsmWaRILzz9nOn98xNq\n\t hFG3JN3FV+7SQ==","Date":"Wed, 22 Apr 2026 16:38:23 -0700","From":"\"Darrick J. Wong\" <djwong@kernel.org>","To":"Chuck Lever <cel@kernel.org>","Cc":"Al Viro <viro@zeniv.linux.org.uk>,\n\tChristian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,\n\tlinux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org,\n\tlinux-xfs@vger.kernel.org, linux-cifs@vger.kernel.org,\n\tlinux-nfs@vger.kernel.org, linux-api@vger.kernel.org,\n\tlinux-f2fs-devel@lists.sourceforge.net, hirofumi@mail.parknet.co.jp,\n\tlinkinjeon@kernel.org, sj1557.seo@samsung.com, yuezhang.mo@sony.com,\n\talmaz.alexandrovich@paragon-software.com, slava@dubeyko.com,\n\tglaubitz@physik.fu-berlin.de, frank.li@vivo.com, tytso@mit.edu,\n\tadilger.kernel@dilger.ca, cem@kernel.org, sfrench@samba.org,\n\tpc@manguebit.org, ronniesahlberg@gmail.com, sprasad@microsoft.com,\n\ttrondmy@kernel.org, anna@kernel.org, jaegeuk@kernel.org,\n\tchao@kernel.org, hansg@kernel.org, senozhatsky@chromium.org,\n\tChuck Lever <chuck.lever@oracle.com>","Subject":"Re: [PATCH v9 01/17] fs: Move file_kattr initialization to callers","Message-ID":"<20260422233823.GA3778109@frogsfrogsfrogs>","References":"<20260422-case-sensitivity-v9-0-be023cc070e2@oracle.com>\n <20260422-case-sensitivity-v9-1-be023cc070e2@oracle.com>","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260422-case-sensitivity-v9-1-be023cc070e2@oracle.com>"}}]