From: Simon Horman <horms@kernel.org>
To: Chris Gellermann <christian.gellermann@codasip.com>
Cc: bongsu.jeon@samsung.com, david@ixit.cz, netdev@vger.kernel.org,
oe-linux-nfc@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] nfc: virtual_ncidev: Add missing ioctl compat handler
Date: Tue, 8 Sep 2026 10:34:14 +0100 [thread overview]
Message-ID: <20260908093414.GQ40544@horms.kernel.org> (raw)
In-Reply-To: <20260904164252.18351-1-christian.gellermann@codasip.com>
On Fri, Sep 04, 2026 at 06:42:52PM +0200, Chris Gellermann wrote:
> The compat handler for ioctls to the virtual nci device is missing. So,
> nci-specific ioctls of a compat task return with -1 and errno set to
> ENOTTY. Add a handler.
>
> The handling of an ioctl() call of a compat task to get the index of
> virtual nci device (IOCTL_GET_NCIDEV_IDX) lands in the default case of
> the ioctl compat handler (see fs/ioctl.c):
>
> COMPAT_SYSCALL_DEFINE3(ioctl, ...)
> {
> ...
> default:
> error = do_vfs_ioctl(fd_file(f), fd, cmd, ...);
> if (error != -ENOIOCTLCMD)
> break;
>
> if (fd_file(f)->f_op->compat_ioctl)
> error = fd_file(f)->f_op->compat_ioctl(fd_file(f), cmd, arg);
> if (error == -ENOIOCTLCMD)
> error = -ENOTTY;
> ...
> }
>
> There, do_vfs_ioctl() returns -ENOIOCTLCMD and compat_ioctl is not
> set for virtual_ncidev_fops, i.e. f_op->compat_ioctl == NULL. So, the
> ioctl() syscall returns with -1 and errno set to ENOTTY to the compat
> task.
>
> To fix this, use the compat_ptr_ioctl helper for compat handling here.
> It shall be used for ioctls that "either ignore the argument or pass a
> pointer to a compatible data type". The driver's sole ioctl takes a user
> void pointer and copies nfc_dev->idx to it, a 4-byte integer across all
> ABIs.
>
> This issue has been found by running the nci_dev kernel selftest as
> rv64 binary on top of a CHERI kernel, where the ioctl() ends up in
> the ioctl compat handler, similar to a 32-bit application on top of a
> 64-bit kernel.
>
> Fixes: e624e6c3e777 ("nfc: Add a virtual nci device driver")
> Signed-off-by: Chris Gellermann <christian.gellermann@codasip.com>
Reviewed-by: Simon Horman <horms@kernel.org>
prev parent reply other threads:[~2026-09-08 9:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-04 16:42 Chris Gellermann
2026-09-08 9:34 ` Simon Horman [this message]
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=20260908093414.GQ40544@horms.kernel.org \
--to=horms@kernel.org \
--cc=bongsu.jeon@samsung.com \
--cc=christian.gellermann@codasip.com \
--cc=david@ixit.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=oe-linux-nfc@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
all inboxes | Powered by JetHome®