Skip to contentSkip to conversation

cobalt/pipe: Add support for compat_ioctl

PATCH Superseded Jan Kiszka 1 participant 1 message Jun 9, 2021

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 cobalt/pipe: Add support for compat_ioctl

From: Jan Kiszka <[email protected]>

There are only two pipe IOCTLs that take arguments and both are int pointers. Therefore, use the compat_ptr_ioctl pattern, just open-coding it for support of kernels < 5.4.4.

---
 kernel/cobalt/pipe.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
kernel/cobalt/pipe.c +11 -0
index 9465fb2da..19064ea69 100644
@@ -1052,6 +1052,16 @@ static long xnpipe_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	return ret;
 }
 
+/*
+ * Could be replaced with compat_ptr_ioctl if support for kernels < 5.4 is
+ * dropped.
+ */
+static long xnpipe_compat_ioctl(struct file *file, unsigned int cmd,
+				unsigned long arg)
+{
+	return xnpipe_ioctl(file, cmd, (unsigned long)compat_ptr(arg));
+}
+
 static int xnpipe_fasync(int fd, struct file *file, int on)
 {
 	struct xnpipe_state *state = file->private_data;
@@ -1112,6 +1122,7 @@ static struct file_operations xnpipe_fops = {
 	.write = xnpipe_write,
 	.poll = xnpipe_poll,
 	.unlocked_ioctl = xnpipe_ioctl,
+	.compat_ioctl = xnpipe_compat_ioctl,
 	.open = xnpipe_open,
 	.release = xnpipe_release,
 	.fasync = xnpipe_fasync
Signature · 1 line
2.26.2