From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3256A51121D; Wed, 30 Sep 2026 16:43:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786598; cv=none; b=AaE7fTyr45UTofN+Y///kjIlHHijTN1R3RngAwAZSLLGiukAhXz0Czew0XWnL0Kgssfd4lzZDGb2eNP6rhh3iu7Z1V7LMMc3itDxEMZByoqDLd8CzNZjip3VhXbUDWlet7ndxvtd7DUOTcIBwyzHIPPGZLkn0lwsqxHawZFERso= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790786598; c=relaxed/simple; bh=+O/opH0SGAA6YE29yVJkmJmS65HSNdPTy5eCW8YQojA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iycw+QfSu6xvcrCpFkXHbqdYs5UhWmFPDlBw+6nMxtQVQHeaFFfI9ycLBTER/jUFgZmOIr81kYIM0HhZfaDaQmE381AFJsxWYU+Cy2swekUwJWLTe1C2vgKxGPYs2Y7SrSe5Iho42cK+BkqD15wNDx0579UwA/v/hma02tgL+mg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=09NH+Gfq; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="09NH+Gfq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C43A1F000FF; Wed, 30 Sep 2026 16:43:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1790786597; bh=CscmBSj2xN+VAkSWyh+OykMfuHsWZ8q1CWuMP00FbQg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=09NH+GfqHAjYdIW7VilW8WPAPOzou1d9wjDXf+6wgHi5jrRWQiBEm6eS8ZGmeN659 pSRi33HkbcGPmhk4EuwCyoxMaeiat2Ezo7JAPZhycCgjs+ohtCohvMhMcxtLaBeIl0 HVbk4VkrZd2A7XaRYt+4Dm6k8lfK6hL8IrkqHDhU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chris Gellermann , Simon Horman , David Heidelberg , Sasha Levin Subject: [PATCH 6.1 881/982] nfc: virtual_ncidev: Add missing ioctl compat handler Date: Wed, 30 Sep 2026 17:26:57 +0200 Message-ID: <20260930152435.672739970@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260930152416.775402466@linuxfoundation.org> References: <20260930152416.775402466@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chris Gellermann [ Upstream commit 51814683e28fc64eceb415962376956c3cfc75a7 ] 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 Reviewed-by: Simon Horman Link: https://patch.msgid.link/20260904164252.18351-1-christian.gellermann@codasip.com Signed-off-by: David Heidelberg Signed-off-by: Sasha Levin --- drivers/nfc/virtual_ncidev.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nfc/virtual_ncidev.c b/drivers/nfc/virtual_ncidev.c index 85c06dbb2c449..1f9b3fb04e0ae 100644 --- a/drivers/nfc/virtual_ncidev.c +++ b/drivers/nfc/virtual_ncidev.c @@ -196,7 +196,8 @@ static const struct file_operations virtual_ncidev_fops = { .write = virtual_ncidev_write, .open = virtual_ncidev_open, .release = virtual_ncidev_close, - .unlocked_ioctl = virtual_ncidev_ioctl + .unlocked_ioctl = virtual_ncidev_ioctl, + .compat_ioctl = compat_ptr_ioctl, }; static int __init virtual_ncidev_init(void) -- 2.53.0