[PATCH 1/8] nitro_enclaves: Let 32-bit processes use the ioctl interface

Alexander Graf <[email protected]>
Newsgroups org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
Neither the misc device nor an enclave fd sets .compat_ioctl, so every
NE ioctl answers -ENOTTY to a 32-bit process on a 64-bit kernel. Nothing
about the interface asks for that. Each ioctl argument is a fixed-width
type or a struct built out of fixed-width types, laid out the same
either way, and the one thing that does differ between a 32-bit and a
64-bit caller is the argument pointer, which is what compat_ptr_ioctl()
converts.

So point both file_operations at it. A 32-bit program that drives
enclaves works with no translation layer on either side, and the ioctl
added later in this series is reachable from such a program the day it
lands, instead of waiting for somebody to notice that it is not.

Fixes: 38907e124088 ("nitro_enclaves: Add logic for creating an enclave VM")
Assisted-by: Kiro:claude-opus-5
Signed-off-by: Alexander Graf <[email protected]>
---
 drivers/virt/nitro_enclaves/ne_misc_dev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/virt/nitro_enclaves/ne_misc_dev.c b/drivers/virt/nitro_enclaves/ne_misc_dev.c
index c91300a73f50..8222fbe75800 100644
--- a/drivers/virt/nitro_enclaves/ne_misc_dev.c
+++ b/drivers/virt/nitro_enclaves/ne_misc_dev.c
@@ -67,6 +67,7 @@ static const struct file_operations ne_fops = {
 	.owner		= THIS_MODULE,
 	.llseek		= noop_llseek,
 	.unlocked_ioctl	= ne_ioctl,
+	.compat_ioctl	= compat_ptr_ioctl,
 };
 
 static struct miscdevice ne_misc_dev = {
@@ -1569,6 +1570,7 @@ static const struct file_operations ne_enclave_fops = {
 	.llseek		= noop_llseek,
 	.poll		= ne_enclave_poll,
 	.unlocked_ioctl	= ne_enclave_ioctl,
+	.compat_ioctl	= compat_ptr_ioctl,
 	.release	= ne_enclave_release,
 };
 
-- 
2.47.1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.