Linux-Fsdevel Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] fs/nsfs.c: fix ioctl support of compat processes
@ 2020-07-24  0:12 Dmitry V. Levin
  2020-07-24  9:20 ` Arnd Bergmann
  0 siblings, 1 reply; 5+ messages in thread
From: Dmitry V. Levin @ 2020-07-24  0:12 UTC (permalink / raw)
  To: Alexander Viro, Serge Hallyn, Andrei Vagin, Eric W. Biederman
  Cc: Ákos Uzonyi, Arnd Bergmann, linux-fsdevel, linux-kernel

According to Documentation/driver-api/ioctl.rst, in order to support
32-bit user space running on a 64-bit kernel, each subsystem or driver
that implements an ioctl callback handler must also implement the
corresponding compat_ioctl handler.  The compat_ptr_ioctl() helper can
be used in place of a custom compat_ioctl file operation for drivers
that only take arguments that are pointers to compatible data
structures.

In case of NS_* ioctls only NS_GET_OWNER_UID accepts an argument, and
this argument is a pointer to uid_t type, which is universally defined
to __kernel_uid32_t.

This change fixes compat strace --pidns-translation.

Note: when backporting this patch to stable kernels, commit
"compat_ioctl: add compat_ptr_ioctl()" is needed as well.

Reported-by: Ákos Uzonyi <uzonyi.akos@gmail.com>
Fixes: 6786741dbf99 ("nsfs: add ioctl to get an owning user namespace for ns file descriptor")
Cc: stable@vger.kernel.org # v4.9+
Signed-off-by: Dmitry V. Levin <ldv@altlinux.org>
---
 fs/nsfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/nsfs.c b/fs/nsfs.c
index 800c1d0eb0d0..a00236bffa2c 100644
--- a/fs/nsfs.c
+++ b/fs/nsfs.c
@@ -21,6 +21,7 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl,
 static const struct file_operations ns_file_operations = {
 	.llseek		= no_llseek,
 	.unlocked_ioctl = ns_ioctl,
+	.compat_ioctl	= compat_ptr_ioctl,
 };
 
 static char *ns_dname(struct dentry *dentry, char *buffer, int buflen)

-- 
ldv

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-09-07 18:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-24  0:12 [PATCH] fs/nsfs.c: fix ioctl support of compat processes Dmitry V. Levin
2020-07-24  9:20 ` Arnd Bergmann
2020-07-24 10:28   ` Dmitry V. Levin
2020-07-24 19:31     ` Eric W. Biederman
2020-09-07 18:17       ` Dmitry V. Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).