public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Mike Snitzer <snitzer@kernel.org>
To: Chuck Lever <cel@kernel.org>
Cc: NeilBrown <neil@brown.name>, Jeff Layton <jlayton@kernel.org>,
	Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <dai.ngo@oracle.com>, Tom Talpey <tom@talpey.com>,
	linux-nfs@vger.kernel.org, Chuck Lever <chuck.lever@oracle.com>
Subject: Re: [PATCH v5 5/6] NFSD: Prevent a NULL pointer dereference in fh_getattr()
Date: Mon, 29 Sep 2025 13:39:19 -0400	[thread overview]
Message-ID: <aNrERzXvdy2Sx19l@kernel.org> (raw)
In-Reply-To: <20250929155646.4818-6-cel@kernel.org>

On Mon, Sep 29, 2025 at 11:56:45AM -0400, Chuck Lever wrote:
> From: Chuck Lever <chuck.lever@oracle.com>
> 
> In general, fh_getattr() can be called after the target dentry has
> gone negative. For a negative dentry, d_inode(p.dentry) will return
> NULL. S_ISREG() will dereference that pointer.
> 
> Avoid this potential regression by using the d_is_reg() helper
> instead.
> 
> Suggested-by: NeilBrown <neil@brown.name>
> Fixes: bc70aaeba7df ("NFSD: filecache: add STATX_DIOALIGN and STATX_DIO_READ_ALIGN support")
> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
> ---
>  fs/nfsd/nfsfh.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c
> index ed85dd43da18..16182936828f 100644
> --- a/fs/nfsd/nfsfh.c
> +++ b/fs/nfsd/nfsfh.c
> @@ -696,10 +696,9 @@ __be32 fh_getattr(const struct svc_fh *fhp, struct kstat *stat)
>  		.mnt		= fhp->fh_export->ex_path.mnt,
>  		.dentry		= fhp->fh_dentry,
>  	};
> -	struct inode *inode = d_inode(p.dentry);
>  	u32 request_mask = STATX_BASIC_STATS;
>  
> -	if (S_ISREG(inode->i_mode))
> +	if (d_is_reg(p.dentry))
>  		request_mask |= (STATX_DIOALIGN | STATX_DIO_READ_ALIGN);
>  
>  	if (fhp->fh_maxsize == NFS4_FHSIZE)
> -- 
> 2.51.0
> 
> 

Reviewed-by: Mike Snitzer <snitzer@kernel.org>

  parent reply	other threads:[~2025-09-29 17:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-29 15:56 [PATCH v5 0/6] NFSD direct I/O read Chuck Lever
2025-09-29 15:56 ` [PATCH v5 1/6] NFSD: filecache: add STATX_DIOALIGN and STATX_DIO_READ_ALIGN support Chuck Lever
2025-10-03  7:09   ` Christoph Hellwig
2025-09-29 15:56 ` [PATCH v5 2/6] NFSD: pass nfsd_file to nfsd_iter_read() Chuck Lever
2025-10-03  7:09   ` Christoph Hellwig
2025-09-29 15:56 ` [PATCH v5 3/6] NFSD: Relocate the xdr_reserve_space_vec() call site Chuck Lever
2025-09-29 15:56 ` [PATCH v5 4/6] NFSD: Implement NFSD_IO_DIRECT for NFS READ Chuck Lever
2025-10-03  7:19   ` Christoph Hellwig
2025-10-03 15:06     ` Chuck Lever
2025-09-29 15:56 ` [PATCH v5 5/6] NFSD: Prevent a NULL pointer dereference in fh_getattr() Chuck Lever
2025-09-29 16:13   ` Jeff Layton
2025-09-29 17:39   ` Mike Snitzer [this message]
2025-10-03  7:11   ` Christoph Hellwig
2025-10-03 14:18     ` Chuck Lever
2025-09-29 15:56 ` [PATCH v5 6/6] NFSD: Ignore vfs_getattr() failure in nfsd_file_get_dio_attrs() Chuck Lever
2025-09-29 16:51   ` Jeff Layton
2025-09-29 17:39   ` Mike Snitzer
2025-10-03  7:13   ` Christoph Hellwig
2025-10-03 14:23     ` Chuck Lever

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aNrERzXvdy2Sx19l@kernel.org \
    --to=snitzer@kernel.org \
    --cc=cel@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=dai.ngo@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neil@brown.name \
    --cc=okorniev@redhat.com \
    --cc=tom@talpey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox