Linux CXL
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "John Groves" <john@jagalactic.com>
Cc: nvdimm@lists.linux.dev, linux-cxl@vger.kernel.org
Subject: Re: [PATCH V14 07/12] famfs: MAP_CREATE ioctl and fmap ingest (ABI 44)
Date: Sat, 29 Aug 2026 17:30:26 +0000	[thread overview]
Message-ID: <20260829173026.D607D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <010001a04e81b68e-8f5128b9-249f-49af-be87-024b15eb0bd9-000000@email.amazonses.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing memory barriers when publishing and reading `inode->i_private` allows concurrent readers to see uninitialized metadata.
- [Medium] Reserved fields in the UAPI structs are not validated to be zero, breaking forward compatibility.
--

commit 01eb70d8c2de27c662f746e15fb2d3e809666490
Author: John Groves <John@Groves.net>

famfs: MAP_CREATE ioctl and fmap ingest (ABI 44)
    
Add the famfs file ioctl handler (FAMFSIOC_NOP, FAMFSIOC_MAP_CREATE) and
the KABI-44 self-describing fmap message: the wire ABI in famfs_ioctl.h
(famfs_ioc_fmap_header plus the simple and interleaved extent structs), the
in-core famfs_file_meta, and famfs_file_init_dax(), which copies the
message in, parses both the simple-extent and interleaved (striped) wire
forms into inode->i_private, and sets S_DAX.

> diff --git a/fs/famfs/famfs_file.c b/fs/famfs/famfs_file.c
> index 9c1cd2f674893..f099e0d08673f 100644
> --- a/fs/famfs/famfs_file.c
> +++ b/fs/famfs/famfs_file.c
[ ... ]
> @@ -13,9 +13,377 @@
[ ... ]
> +static int
> +famfs_file_init_dax(struct file *file, void __user *arg)
> +{
> +	struct famfs_ioc_fmap_header fmh;
[ ... ]
> +	if (copy_from_user(&fmh, arg, sizeof(fmh)))
> +		return -EFAULT;
> +
> +	if (fmh.fmap_version != FAMFS_FMAP_VERSION)
> +		return -EINVAL;
> +	if (fmh.fmap_size < sizeof(fmh))
> +		return -EINVAL;

[Severity: Medium]
Are the reserved and reserved1 fields in famfs_ioc_fmap_header validated
to be zero here? 

If userspace passes uninitialized or garbage data in these fields, the kernel
will blindly accept it. This could prevent the kernel from safely assigning
meaning to these fields in the future without breaking backward compatibility,
since it won't be able to distinguish between older applications passing
garbage and newer applications intentionally using the flags. 

The reserved fields in famfs_ioc_simple_ext and famfs_ioc_iext also appear
to lack zero-validation.

> +	if (fmh.fmap_size > FAMFS_FMAP_MSG_MAX)
> +		return -EFBIG;
[ ... ]
> +	/* Publish the famfs metadata on inode->i_private */
> +	inode_lock(inode);
> +	if (inode->i_private) {
> +		rc = -EEXIST; /* file already has famfs metadata */
> +	} else {
> +		inode->i_private = meta;
> +		i_size_write(inode, meta->file_size);

[Severity: High]
Does this assignment to inode->i_private need a release memory barrier?

This plain store publishes the structure without a release barrier, allowing
prior initialization stores to be reordered after it. A concurrent reader
could observe a non-NULL inode->i_private pointer but read uninitialized or
stale metadata fields.

For instance, a concurrent mmap() on the same file calls famfs_file_mmap()
which in turn calls famfs_file_invalid(inode). Because famfs_file_mmap()
does not hold inode_lock, famfs_file_invalid() will execute a plain load
(struct famfs_file_meta *meta = inode->i_private;) without an acquire
barrier. 

If it reads uninitialized data like meta->file_size, it could fail the 
i_size != meta->file_size check, which permanently sets meta->error = true,
thereby permanently bricking the file mapping.

Should smp_store_release() and smp_load_acquire() be used here to enforce
the required memory ordering?

> +		inode->i_flags |= S_DAX;
> +		meta = NULL; /* owned by the inode now */
> +		rc = 0;
> +	}
> +	inode_unlock(inode);
[ ... ]

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/010001a04e801a4e-8eb212cd-b263-4043-ab65-33e480d2d7d4-000000@email.amazonses.com?part=7

  reply	other threads:[~2026-08-29 17:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260829171004.7336-1-john@jagalactic.com>
2026-08-29 17:10 ` [PATCH V14 00/12] Subject: [PATCH v14 00/12] famfs: the Fabric-Attached Memory File System (standalone) John Groves
2026-08-29 17:10   ` [PATCH V14 01/12] dax: replace exported dax_dev_get() with non-allocating dax_dev_find() John Groves
2026-08-29 17:11   ` [PATCH V14 02/12] famfs: Module operations, fs_context, and mount John Groves
2026-08-29 17:28     ` sashiko-bot
2026-08-29 17:11   ` [PATCH V14 03/12] famfs: Add daxdev table and dax notify_failure support John Groves
2026-08-29 17:32     ` sashiko-bot
2026-08-29 17:11   ` [PATCH V14 04/12] famfs: Introduce inode_operations and super_operations John Groves
2026-08-29 17:11   ` [PATCH V14 05/12] famfs: Introduce file_operations read/write John Groves
2026-08-29 17:25     ` sashiko-bot
2026-08-29 17:11   ` [PATCH V14 06/12] famfs: Introduce mmap and VM fault handling John Groves
2026-08-29 17:26     ` sashiko-bot
2026-08-29 17:11   ` [PATCH V14 07/12] famfs: MAP_CREATE ioctl and fmap ingest (ABI 44) John Groves
2026-08-29 17:30     ` sashiko-bot [this message]
2026-08-29 17:12   ` [PATCH V14 08/12] famfs: iomap_begin and file-to-dax offset resolution John Groves
2026-08-29 17:25     ` sashiko-bot
2026-08-29 17:12   ` [PATCH V14 09/12] famfs: Register secondary daxdevs by path (FAMFSIOC_DAXDEV_OPEN) John Groves
2026-08-29 17:25     ` sashiko-bot
2026-08-29 17:13   ` [PATCH V14 10/12] famfs: Add runtime operation-permission (opts) framework John Groves
2026-08-29 17:13   ` [PATCH V14 11/12] famfs: Report device capacity via statfs so df works John Groves
2026-08-29 17:30     ` sashiko-bot
2026-08-29 17:13   ` [PATCH V14 12/12] famfs: Add documentation John Groves

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=20260829173026.D607D1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=john@jagalactic.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=nvdimm@lists.linux.dev \
    --cc=sashiko-reviews@lists.linux.dev \
    /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