Skip to contentSkip to conversation

remove compat_sys_mount

PATCH In review Christoph Hellwig 4 participants 15 messages Sep 17, 2020 – Oct 11, 2020

Subsystems (14)
x86 VFS PowerPC MIPS +10 more subsystems
lore
Share & tools
lore
#0 lore raw

Hi Al,

this series moves the NFSv4 binary mount data compat handling to fs/nfs/, and removes the now pointless compat_sys_mount.

Diffstat:

 b/arch/alpha/kernel/osf_sys.c                        |  116 +++--------
 b/arch/arm64/include/asm/unistd32.h                  |    2 
 b/arch/mips/kernel/syscalls/syscall_n32.tbl          |    2 
 b/arch/mips/kernel/syscalls/syscall_o32.tbl          |    2 
 b/arch/parisc/kernel/syscalls/syscall.tbl            |    2 
 b/arch/powerpc/kernel/syscalls/syscall.tbl           |    2 
 b/arch/s390/kernel/syscalls/syscall.tbl              |    2 
 b/arch/sparc/kernel/syscalls/syscall.tbl             |    2 
 b/arch/x86/entry/syscalls/syscall_32.tbl             |    2 
 b/fs/Makefile                                        |    1 
 b/fs/internal.h                                      |    3 
 b/fs/namespace.c                                     |   29 --
 b/fs/nfs/fs_context.c                                |  195 ++++++++++++-------
 b/include/linux/compat.h                             |    6 
 b/include/linux/fs.h                                 |    2 
 b/include/uapi/asm-generic/unistd.h                  |    2 
 b/tools/include/uapi/asm-generic/unistd.h            |    2 
 b/tools/perf/arch/powerpc/entry/syscalls/syscall.tbl |    2 
 b/tools/perf/arch/s390/entry/syscalls/syscall.tbl    |    2 
 fs/compat.c                                          |  132 ------------
 20 files changed, 179 insertions(+), 329 deletions(-)
#1 lore raw

PATCH 1/5 nfs: simplify nfs4_parse_monolithic

Remove a level of indentation for the version 1 mount data parsing, and simplify the NULL data case a little bit as well.

---
 fs/nfs/fs_context.c | 135 +++++++++++++++++++++-----------------------
 1 file changed, 63 insertions(+), 72 deletions(-)
fs/nfs/fs_context.c +63 -72
index 524812984e2d43..cbf6a4ba5e5806 100644
@@ -1049,89 +1049,80 @@ static int nfs4_parse_monolithic(struct fs_context *fc,
 	struct sockaddr *sap = (struct sockaddr *)&ctx->nfs_server.address;
 	char *c;
 
-	if (data == NULL)
-		goto out_no_data;
+	if (!data) {
+		if (is_remount_fc(fc))
+			goto done;
+		return nfs_invalf(fc,
+			"NFS4: mount program didn't pass any mount data");
+	}
 
 	ctx->version = 4;
 
-	switch (data->version) {
-	case 1:
-		if (data->host_addrlen > sizeof(ctx->nfs_server.address))
-			goto out_no_address;
-		if (data->host_addrlen == 0)
-			goto out_no_address;
-		ctx->nfs_server.addrlen = data->host_addrlen;
-		if (copy_from_user(sap, data->host_addr, data->host_addrlen))
-			return -EFAULT;
-		if (!nfs_verify_server_address(sap))
-			goto out_no_address;
-		ctx->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port);
-
-		if (data->auth_flavourlen) {
-			rpc_authflavor_t pseudoflavor;
-			if (data->auth_flavourlen > 1)
-				goto out_inval_auth;
-			if (copy_from_user(&pseudoflavor,
-					   data->auth_flavours,
-					   sizeof(pseudoflavor)))
-				return -EFAULT;
-			ctx->selected_flavor = pseudoflavor;
-		} else
-			ctx->selected_flavor = RPC_AUTH_UNIX;
-
-		c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
-		if (IS_ERR(c))
-			return PTR_ERR(c);
-		ctx->nfs_server.hostname = c;
-
-		c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN);
-		if (IS_ERR(c))
-			return PTR_ERR(c);
-		ctx->nfs_server.export_path = c;
-		dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c);
+	if (data->version != 1)
+		return generic_parse_monolithic(fc, data);
 
-		c = strndup_user(data->client_addr.data, 16);
-		if (IS_ERR(c))
-			return PTR_ERR(c);
-		ctx->client_address = c;
-
-		/*
-		 * Translate to nfs_fs_context, which nfs_fill_super
-		 * can deal with.
-		 */
+	if (data->host_addrlen > sizeof(ctx->nfs_server.address))
+		goto out_no_address;
+	if (data->host_addrlen == 0)
+		goto out_no_address;
+	ctx->nfs_server.addrlen = data->host_addrlen;
+	if (copy_from_user(sap, data->host_addr, data->host_addrlen))
+		return -EFAULT;
+	if (!nfs_verify_server_address(sap))
+		goto out_no_address;
+	ctx->nfs_server.port = ntohs(((struct sockaddr_in *)sap)->sin_port);
 
-		ctx->flags	= data->flags & NFS4_MOUNT_FLAGMASK;
-		ctx->rsize	= data->rsize;
-		ctx->wsize	= data->wsize;
-		ctx->timeo	= data->timeo;
-		ctx->retrans	= data->retrans;
-		ctx->acregmin	= data->acregmin;
-		ctx->acregmax	= data->acregmax;
-		ctx->acdirmin	= data->acdirmin;
-		ctx->acdirmax	= data->acdirmax;
-		ctx->nfs_server.protocol = data->proto;
-		nfs_validate_transport_protocol(ctx);
-		if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP)
-			goto out_invalid_transport_udp;
+	if (data->auth_flavourlen) {
+		rpc_authflavor_t pseudoflavor;
 
-		break;
-	default:
-		goto generic;
+		if (data->auth_flavourlen > 1)
+			goto out_inval_auth;
+		if (copy_from_user(&pseudoflavor, data->auth_flavours,
+				   sizeof(pseudoflavor)))
+			return -EFAULT;
+		ctx->selected_flavor = pseudoflavor;
+	} else {
+		ctx->selected_flavor = RPC_AUTH_UNIX;
 	}
 
+	c = strndup_user(data->hostname.data, NFS4_MAXNAMLEN);
+	if (IS_ERR(c))
+		return PTR_ERR(c);
+	ctx->nfs_server.hostname = c;
+
+	c = strndup_user(data->mnt_path.data, NFS4_MAXPATHLEN);
+	if (IS_ERR(c))
+		return PTR_ERR(c);
+	ctx->nfs_server.export_path = c;
+	dfprintk(MOUNT, "NFS: MNTPATH: '%s'\n", c);
+
+	c = strndup_user(data->client_addr.data, 16);
+	if (IS_ERR(c))
+		return PTR_ERR(c);
+	ctx->client_address = c;
+
+	/*
+	 * Translate to nfs_fs_context, which nfs_fill_super
+	 * can deal with.
+	 */
+
+	ctx->flags	= data->flags & NFS4_MOUNT_FLAGMASK;
+	ctx->rsize	= data->rsize;
+	ctx->wsize	= data->wsize;
+	ctx->timeo	= data->timeo;
+	ctx->retrans	= data->retrans;
+	ctx->acregmin	= data->acregmin;
+	ctx->acregmax	= data->acregmax;
+	ctx->acdirmin	= data->acdirmin;
+	ctx->acdirmax	= data->acdirmax;
+	ctx->nfs_server.protocol = data->proto;
+	nfs_validate_transport_protocol(ctx);
+	if (ctx->nfs_server.protocol == XPRT_TRANSPORT_UDP)
+		goto out_invalid_transport_udp;
+done:
 	ctx->skip_reconfig_option_check = true;
 	return 0;
 
-generic:
-	return generic_parse_monolithic(fc, data);
-
-out_no_data:
-	if (is_remount_fc(fc)) {
-		ctx->skip_reconfig_option_check = true;
-		return 0;
-	}
-	return nfs_invalf(fc, "NFS4: mount program didn't pass any mount data");
-
 out_inval_auth:
 	return nfs_invalf(fc, "NFS4: Invalid number of RPC auth flavours %d",
 		      data->auth_flavourlen);
Signature · 1 line
2.28.0
#2 lore raw

PATCH 2/5 fs,nfs: lift compat nfs4 mount data handling into the nfs code

In reply to Christoph Hellwig

There is no reason the generic fs code should bother with NFS specific binary mount data - lift the conversion into nfs4_parse_monolithic instead.

---
 fs/compat.c         | 75 ---------------------------------------------
 fs/nfs/fs_context.c | 62 +++++++++++++++++++++++++++++++++++++
 2 files changed, 62 insertions(+), 75 deletions(-)
fs/compat.c +0 -75
index 436d228cf71c09..9b00523d7fa571 100644
@@ -19,73 +19,6 @@
 #include <linux/uaccess.h>
 #include "internal.h"
 
-struct compat_nfs_string {
-	compat_uint_t len;
-	compat_uptr_t data;
-};
-
-static inline void compat_nfs_string(struct nfs_string *dst,
-				     struct compat_nfs_string *src)
-{
-	dst->data = compat_ptr(src->data);
-	dst->len = src->len;
-}
-
-struct compat_nfs4_mount_data_v1 {
-	compat_int_t version;
-	compat_int_t flags;
-	compat_int_t rsize;
-	compat_int_t wsize;
-	compat_int_t timeo;
-	compat_int_t retrans;
-	compat_int_t acregmin;
-	compat_int_t acregmax;
-	compat_int_t acdirmin;
-	compat_int_t acdirmax;
-	struct compat_nfs_string client_addr;
-	struct compat_nfs_string mnt_path;
-	struct compat_nfs_string hostname;
-	compat_uint_t host_addrlen;
-	compat_uptr_t host_addr;
-	compat_int_t proto;
-	compat_int_t auth_flavourlen;
-	compat_uptr_t auth_flavours;
-};
-
-static int do_nfs4_super_data_conv(void *raw_data)
-{
-	int version = *(compat_uint_t *) raw_data;
-
-	if (version == 1) {
-		struct compat_nfs4_mount_data_v1 *raw = raw_data;
-		struct nfs4_mount_data *real = raw_data;
-
-		/* copy the fields backwards */
-		real->auth_flavours = compat_ptr(raw->auth_flavours);
-		real->auth_flavourlen = raw->auth_flavourlen;
-		real->proto = raw->proto;
-		real->host_addr = compat_ptr(raw->host_addr);
-		real->host_addrlen = raw->host_addrlen;
-		compat_nfs_string(&real->hostname, &raw->hostname);
-		compat_nfs_string(&real->mnt_path, &raw->mnt_path);
-		compat_nfs_string(&real->client_addr, &raw->client_addr);
-		real->acdirmax = raw->acdirmax;
-		real->acdirmin = raw->acdirmin;
-		real->acregmax = raw->acregmax;
-		real->acregmin = raw->acregmin;
-		real->retrans = raw->retrans;
-		real->timeo = raw->timeo;
-		real->wsize = raw->wsize;
-		real->rsize = raw->rsize;
-		real->flags = raw->flags;
-		real->version = raw->version;
-	}
-
-	return 0;
-}
-
-#define NFS4_NAME	"nfs4"
-
 COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
 		       const char __user *, dir_name,
 		       const char __user *, type, compat_ulong_t, flags,
@@ -111,14 +44,6 @@ COMPAT_SYSCALL_DEFINE5(mount, const char __user *, dev_name,
 	if (IS_ERR(options))
 		goto out2;
 
-	if (kernel_type && options) {
-		if (!strcmp(kernel_type, NFS4_NAME)) {
-			retval = -EINVAL;
-			if (do_nfs4_super_data_conv(options))
-				goto out3;
-		}
-	}
-
 	retval = do_mount(kernel_dev, dir_name, kernel_type, flags, options);
 
  out3:
fs/nfs/fs_context.c +62 -0

74 lines not on this page · raw message

Signature · 1 line
2.28.0
maintainer
#3 lore raw

Re: [PATCH 2/5] fs,nfs: lift compat nfs4 mount data handling into the nfs code

Quoted 3 lines · Christoph Hellwig

There is no reason the generic fs code should bother with NFS specific binary mount data - lift the conversion into nfs4_parse_monolithic instead.

Considering the size of struct compat_nfs4_mount_data_v1... Do we really need to bother with that "copy in place, so we go through the fields backwards" logics? Just make that

fs/nfs/fs_context.c static int nfs23_parse_monolithic(struct fs_context *fc, · line 1076

Quoted 2 lines
fs/nfs/fs_context.c +2 -0
+static void nfs4_compat_mount_data_conv(struct nfs4_mount_data *data)
+{
	struct compat_nfs4_mount_data_v1 compat;
	compat = *(struct compat_nfs4_mount_data_v1 *)data;

and copy the damnt thing without worrying about the field order...

#4 lore raw

Re: [PATCH 2/5] fs,nfs: lift compat nfs4 mount data handling into the nfs code

Quoted 9 lines · Al Viro
Quoted 3 lines · Christoph Hellwig

There is no reason the generic fs code should bother with NFS specific binary mount data - lift the conversion into nfs4_parse_monolithic instead.

Considering the size of struct compat_nfs4_mount_data_v1... Do we really need to bother with that "copy in place, so we go through the fields backwards" logics? Just make that

Quoted 5 lines

fs/nfs/fs_context.c static int nfs23_parse_monolithic(struct fs_context *fc, · line 1076

Quoted 2 lines
fs/nfs/fs_context.c +2 -0
+static void nfs4_compat_mount_data_conv(struct nfs4_mount_data *data)
+{
	struct compat_nfs4_mount_data_v1 compat;
	compat = *(struct compat_nfs4_mount_data_v1 *)data;

and copy the damnt thing without worrying about the field order...

Maybe. But then again why bother? I just sticked to the existing code as much as possible.

#5 lore raw

Re: [PATCH 2/5] fs,nfs: lift compat nfs4 mount data handling into the nfs code

Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Al Viro
Quoted 3 lines · Christoph Hellwig

There is no reason the generic fs code should bother with NFS specific binary mount data - lift the conversion into nfs4_parse_monolithic instead.

Considering the size of struct compat_nfs4_mount_data_v1... Do we really need to bother with that "copy in place, so we go through the fields backwards" logics? Just make that

Quoted 8 lines
Quoted 5 lines

fs/nfs/fs_context.c static int nfs23_parse_monolithic(struct fs_context *fc, · line 1076

Quoted 2 lines
fs/nfs/fs_context.c +2 -0
+static void nfs4_compat_mount_data_conv(struct nfs4_mount_data *data)
+{
	struct compat_nfs4_mount_data_v1 compat;
	compat = *(struct compat_nfs4_mount_data_v1 *)data;

and copy the damnt thing without worrying about the field order...

Maybe. But then again why bother? I just sticked to the existing code as much as possible.

Trond, Anna: what is your preference?

#6 lore raw

Re: [PATCH 2/5] fs,nfs: lift compat nfs4 mount data handling into the nfs code

This is for the binary mount stuff? That was already legacy code when I first started, and mount uses text options now. My preference is for keeping it as close to the original code as possible.

I'm curious if you've been able to test this? I'm not sure if there is a way to force binary mount data through mount.nfs

Anna

Quoted 22 lines · Christoph Hellwig
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Al Viro
Quoted 3 lines · Christoph Hellwig

There is no reason the generic fs code should bother with NFS specific binary mount data - lift the conversion into nfs4_parse_monolithic instead.

Considering the size of struct compat_nfs4_mount_data_v1... Do we really need to bother with that "copy in place, so we go through the fields backwards" logics? Just make that

Quoted 8 lines
Quoted 5 lines

fs/nfs/fs_context.c static int nfs23_parse_monolithic(struct fs_context *fc, · line 1076

Quoted 2 lines
fs/nfs/fs_context.c +2 -0
+static void nfs4_compat_mount_data_conv(struct nfs4_mount_data *data)
+{
    struct compat_nfs4_mount_data_v1 compat;
    compat = *(struct compat_nfs4_mount_data_v1 *)data;

and copy the damnt thing without worrying about the field order...

Maybe. But then again why bother? I just sticked to the existing code as much as possible.

Trond, Anna: what is your preference?

#7 lore raw

Re: [PATCH 2/5] fs,nfs: lift compat nfs4 mount data handling into the nfs code

Quoted 3 lines · Anna Schumaker

This is for the binary mount stuff? That was already legacy code when I first started, and mount uses text options now. My preference is for keeping it as close to the original code as possible.

Ok. Al, are you fine with the series as-is then?

Quoted 3 lines

I'm curious if you've been able to test this? I'm not sure if there is a way to force binary mount data through mount.nfs

The test is pretty trivial - even the most recent nfsutils supports the binary mount data. You just need to patch out the detection for a modern kernel.

maintainer
#8 lore raw

Re: [PATCH 2/5] fs,nfs: lift compat nfs4 mount data handling into the nfs code

Quoted 6 lines · Christoph Hellwig
Quoted 3 lines · Anna Schumaker

This is for the binary mount stuff? That was already legacy code when I first started, and mount uses text options now. My preference is for keeping it as close to the original code as possible.

Ok. Al, are you fine with the series as-is then?

I can live with that. I'm not fond of in_compat_syscall() proliferation, but in this case it's reasonably sane...

OK, applied.

#9 lore raw

PATCH 3/5 fs: remove compat_sys_mount

In reply to Christoph Hellwig

compat_sys_mount is identical to the regular sys_mount now, so remove it and use the native version everywhere.

---
 arch/arm64/include/asm/unistd32.h             |  2 +-
 arch/mips/kernel/syscalls/syscall_n32.tbl     |  2 +-
 arch/mips/kernel/syscalls/syscall_o32.tbl     |  2 +-
 arch/parisc/kernel/syscalls/syscall.tbl       |  2 +-
 arch/powerpc/kernel/syscalls/syscall.tbl      |  2 +-
 arch/s390/kernel/syscalls/syscall.tbl         |  2 +-
 arch/sparc/kernel/syscalls/syscall.tbl        |  2 +-
 arch/x86/entry/syscalls/syscall_32.tbl        |  2 +-
 fs/Makefile                                   |  1 -
 fs/compat.c                                   | 57 -------------------
 fs/internal.h                                 |  3 -
 fs/namespace.c                                |  4 +-
 include/linux/compat.h                        |  6 --
 include/uapi/asm-generic/unistd.h             |  2 +-
 tools/include/uapi/asm-generic/unistd.h       |  2 +-
 .../arch/powerpc/entry/syscalls/syscall.tbl   |  2 +-
 .../perf/arch/s390/entry/syscalls/syscall.tbl |  2 +-
 17 files changed, 14 insertions(+), 81 deletions(-)
 delete mode 100644 fs/compat.c
arch/arm64/include/asm/unistd32.h +1 -1
index 734860ac7cf9d5..5fd095d6545022 100644
@@ -53,7 +53,7 @@ __SYSCALL(__NR_lseek, compat_sys_lseek)
 #define __NR_getpid 20
 __SYSCALL(__NR_getpid, sys_getpid)
 #define __NR_mount 21
-__SYSCALL(__NR_mount, compat_sys_mount)
+__SYSCALL(__NR_mount, sys_mount)
 			/* 22 was sys_umount */
 __SYSCALL(22, sys_ni_syscall)
 #define __NR_setuid 23
arch/mips/kernel/syscalls/syscall_n32.tbl +1 -1
index f9df9edb67a407..61fa9e7013cbc1 100644
@@ -167,7 +167,7 @@
 157	n32	sync				sys_sync
 158	n32	acct				sys_acct
 159	n32	settimeofday			compat_sys_settimeofday
-160	n32	mount				compat_sys_mount
+160	n32	mount				sys_mount
 161	n32	umount2				sys_umount
 162	n32	swapon				sys_swapon
 163	n32	swapoff				sys_swapoff
arch/mips/kernel/syscalls/syscall_o32.tbl +1 -1
index 195b43cf27c848..b992e89be7ff8a 100644
@@ -29,7 +29,7 @@
 18	o32	unused18			sys_ni_syscall
 19	o32	lseek				sys_lseek
 20	o32	getpid				sys_getpid
-21	o32	mount				sys_mount			compat_sys_mount
+21	o32	mount				sys_mount
 22	o32	umount				sys_oldumount
 23	o32	setuid				sys_setuid
 24	o32	getuid				sys_getuid
arch/parisc/kernel/syscalls/syscall.tbl +1 -1
index def64d221cd4fb..07efd978182fea 100644
@@ -29,7 +29,7 @@
 18	common	stat			sys_newstat			compat_sys_newstat
 19	common	lseek			sys_lseek			compat_sys_lseek
 20	common	getpid			sys_getpid
-21	common	mount			sys_mount			compat_sys_mount
+21	common	mount			sys_mount
 22	common	bind			sys_bind
 23	common	setuid			sys_setuid
 24	common	getuid			sys_getuid
arch/powerpc/kernel/syscalls/syscall.tbl +1 -1
index c2d737ff2e7bec..a36ad4fec73c19 100644
@@ -34,7 +34,7 @@
 18	spu	oldstat				sys_ni_syscall
 19	common	lseek				sys_lseek			compat_sys_lseek
 20	common	getpid				sys_getpid
-21	nospu	mount				sys_mount			compat_sys_mount
+21	nospu	mount				sys_mount
 22	32	umount				sys_oldumount
 22	64	umount				sys_ni_syscall
 22	spu	umount				sys_ni_syscall
arch/s390/kernel/syscalls/syscall.tbl +1 -1
index 10456bc936fb09..4b803dfbee2be9 100644
@@ -26,7 +26,7 @@
 16   32		lchown			-				sys_lchown16
 19   common	lseek			sys_lseek			compat_sys_lseek
 20   common	getpid			sys_getpid			sys_getpid
-21   common	mount			sys_mount			compat_sys_mount
+21   common	mount			sys_mount			sys_mount
 22   common	umount			sys_oldumount			sys_oldumount
 23   32		setuid			-				sys_setuid16
 24   32		getuid			-				sys_getuid16
arch/sparc/kernel/syscalls/syscall.tbl +1 -1
index 4af114e84f2022..d5ff798fa08f80 100644
@@ -201,7 +201,7 @@
 164	64	utrap_install		sys_utrap_install
 165	common	quotactl		sys_quotactl
 166	common	set_tid_address		sys_set_tid_address
-167	common	mount			sys_mount			compat_sys_mount
+167	common	mount			sys_mount
 168	common	ustat			sys_ustat			compat_sys_ustat
 169	common	setxattr		sys_setxattr
 170	common	lsetxattr		sys_lsetxattr
arch/x86/entry/syscalls/syscall_32.tbl +1 -1
index 9d11028736661b..5a40b226fb7b7a 100644
@@ -32,7 +32,7 @@
 18	i386	oldstat			sys_stat
 19	i386	lseek			sys_lseek			compat_sys_lseek
 20	i386	getpid			sys_getpid
-21	i386	mount			sys_mount			compat_sys_mount
+21	i386	mount			sys_mount
 22	i386	umount			sys_oldumount
 23	i386	setuid			sys_setuid16
 24	i386	getuid			sys_getuid16
fs/Makefile +0 -1
index 1c7b0e3f6daa11..d72ee2ce7af080 100644
@@ -37,7 +37,6 @@ obj-$(CONFIG_FS_DAX)		+= dax.o
 obj-$(CONFIG_FS_ENCRYPTION)	+= crypto/
 obj-$(CONFIG_FS_VERITY)		+= verity/
 obj-$(CONFIG_FILE_LOCKING)      += locks.o
-obj-$(CONFIG_COMPAT)		+= compat.o
 obj-$(CONFIG_BINFMT_AOUT)	+= binfmt_aout.o
 obj-$(CONFIG_BINFMT_EM86)	+= binfmt_em86.o
 obj-$(CONFIG_BINFMT_MISC)	+= binfmt_misc.o
fs/compat.c deleted +0 -57

57 lines not on this page · raw message

fs/internal.h +0 -3
index 10517ece45167f..a7cd0f64faa4ab 100644
@@ -82,9 +82,6 @@ int may_linkat(struct path *link);
 /*
  * namespace.c
  */
-extern void *copy_mount_options(const void __user *);
-extern char *copy_mount_string(const void __user *);
-
 extern struct vfsmount *lookup_mnt(const struct path *);
 extern int finish_automount(struct vfsmount *, struct path *);
 
fs/namespace.c +2 -2
index bae0e95b3713a3..12b431b61462b9 100644
@@ -3072,7 +3072,7 @@ static void shrink_submounts(struct mount *mnt)
 	}
 }
 
-void *copy_mount_options(const void __user * data)
+static void *copy_mount_options(const void __user * data)
 {
 	char *copy;
 	unsigned size;
@@ -3097,7 +3097,7 @@ void *copy_mount_options(const void __user * data)
 	return copy;
 }
 
-char *copy_mount_string(const void __user *data)
+static char *copy_mount_string(const void __user *data)
 {
 	return data ? strndup_user(data, PATH_MAX) : NULL;
 }
include/linux/compat.h +0 -6
index b354ce58966e2d..92db17cc5c5e33 100644
@@ -522,12 +522,6 @@ asmlinkage long compat_sys_fcntl64(unsigned int fd, unsigned int cmd,
 asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
 				 compat_ulong_t arg);
 
-/* fs/namespace.c */
-asmlinkage long compat_sys_mount(const char __user *dev_name,
-				 const char __user *dir_name,
-				 const char __user *type, compat_ulong_t flags,
-				 const void __user *data);
-
 /* fs/open.c */
 asmlinkage long compat_sys_statfs(const char __user *pathname,
 				  struct compat_statfs __user *buf);
include/uapi/asm-generic/unistd.h +1 -1
index 995b36c2ea7d8a..fc98c943760976 100644
@@ -140,7 +140,7 @@ __SYSCALL(__NR_renameat, sys_renameat)
 #define __NR_umount2 39
 __SYSCALL(__NR_umount2, sys_umount)
 #define __NR_mount 40
-__SC_COMP(__NR_mount, sys_mount, compat_sys_mount)
+__SYSCALL(__NR_mount, sys_mount)
 #define __NR_pivot_root 41
 __SYSCALL(__NR_pivot_root, sys_pivot_root)
 
tools/include/uapi/asm-generic/unistd.h +1 -1
index 995b36c2ea7d8a..fc98c943760976 100644
@@ -140,7 +140,7 @@ __SYSCALL(__NR_renameat, sys_renameat)
 #define __NR_umount2 39
 __SYSCALL(__NR_umount2, sys_umount)
 #define __NR_mount 40
-__SC_COMP(__NR_mount, sys_mount, compat_sys_mount)
+__SYSCALL(__NR_mount, sys_mount)
 #define __NR_pivot_root 41
 __SYSCALL(__NR_pivot_root, sys_pivot_root)
 
tools/perf/arch/powerpc/entry/syscalls/syscall.tbl +1 -1
index 3ca6fe057a0b1f..c2866c65965061 100644
@@ -32,7 +32,7 @@
 18	spu	oldstat				sys_ni_syscall
 19	common	lseek				sys_lseek			compat_sys_lseek
 20	common	getpid				sys_getpid
-21	nospu	mount				sys_mount			compat_sys_mount
+21	nospu	mount				sys_mount
 22	32	umount				sys_oldumount
 22	64	umount				sys_ni_syscall
 22	spu	umount				sys_ni_syscall
tools/perf/arch/s390/entry/syscalls/syscall.tbl +1 -1
index 6a0bbea225db0d..8e0806f6c38eb0 100644
@@ -26,7 +26,7 @@
 16   32		lchown			-				compat_sys_s390_lchown16
 19   common	lseek			sys_lseek			compat_sys_lseek
 20   common	getpid			sys_getpid			sys_getpid
-21   common	mount			sys_mount			compat_sys_mount
+21   common	mount			sys_mount
 22   common	umount			sys_oldumount			compat_sys_oldumount
 23   32		setuid			-				compat_sys_s390_setuid16
 24   32		getuid			-				compat_sys_s390_getuid16
Signature · 1 line
2.28.0
#10 lore raw

PATCH 4/5 alpha: simplify osf_mount

In reply to Christoph Hellwig

Merge the mount_args structures and mount helpers to simplify the code a bit.

---
 arch/alpha/kernel/osf_sys.c | 111 +++++++++---------------------------
 1 file changed, 28 insertions(+), 83 deletions(-)
arch/alpha/kernel/osf_sys.c +28 -83
index d5367a1c6300c1..5fd155b13503b5 100644
@@ -421,109 +421,54 @@ SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd,
  *
  * Although to be frank, neither are the native Linux/i386 ones..
  */
-struct ufs_args {
+struct osf_mount_args {
 	char __user *devname;
 	int flags;
 	uid_t exroot;
+	/* this has lots more here for cdfs at least, but we don't bother */
 };
 
-struct cdfs_args {
-	char __user *devname;
-	int flags;
-	uid_t exroot;
-
-	/* This has lots more here, which Linux handles with the option block
-	   but I'm too lazy to do the translation into ASCII.  */
-};
-
-struct procfs_args {
-	char __user *devname;
-	int flags;
-	uid_t exroot;
-};
-
-/*
- * We can't actually handle ufs yet, so we translate UFS mounts to
- * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
- * layout is so braindead it's a major headache doing it.
- *
- * Just how long ago was it written? OTOH our UFS driver may be still
- * unhappy with OSF UFS. [CHECKME]
- */
-static int
-osf_ufs_mount(const char __user *dirname,
-	      struct ufs_args __user *args, int flags)
+SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
+		int, flag, void __user *, data)
 {
-	int retval;
-	struct cdfs_args tmp;
+	struct osf_mount_args tmp;
 	struct filename *devname;
-
-	retval = -EFAULT;
-	if (copy_from_user(&tmp, args, sizeof(tmp)))
-		goto out;
-	devname = getname(tmp.devname);
-	retval = PTR_ERR(devname);
-	if (IS_ERR(devname))
-		goto out;
-	retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
-	putname(devname);
- out:
-	return retval;
-}
-
-static int
-osf_cdfs_mount(const char __user *dirname,
-	       struct cdfs_args __user *args, int flags)
-{
+	const char *fstype;
 	int retval;
-	struct cdfs_args tmp;
-	struct filename *devname;
-
-	retval = -EFAULT;
-	if (copy_from_user(&tmp, args, sizeof(tmp)))
-		goto out;
-	devname = getname(tmp.devname);
-	retval = PTR_ERR(devname);
-	if (IS_ERR(devname))
-		goto out;
-	retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
-	putname(devname);
- out:
-	return retval;
-}
-
-static int
-osf_procfs_mount(const char __user *dirname,
-		 struct procfs_args __user *args, int flags)
-{
-	struct procfs_args tmp;
 
 	if (copy_from_user(&tmp, args, sizeof(tmp)))
 		return -EFAULT;
 
-	return do_mount("", dirname, "proc", flags, NULL);
-}
-
-SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
-		int, flag, void __user *, data)
-{
-	int retval;
-
 	switch (typenr) {
-	case 1:
-		retval = osf_ufs_mount(path, data, flag);
+	case 1: /* ufs */
+		/*
+		 * We can't actually handle ufs yet, so we translate UFS mounts
+		 * to ext2 mounts. I wouldn't mind a UFS filesystem, but the UFS
+		 * layout is so braindead it's a major headache doing it.
+		 *
+		 * Just how long ago was it written? OTOH our UFS driver may be
+		 * still unhappy with OSF UFS. [CHECKME]
+		 */
+		fstype = "ext2";
+		devname = getname(tmp.devname);
 		break;
-	case 6:
-		retval = osf_cdfs_mount(path, data, flag);
+	case 6: /* cdfs */
+		fstype = "iso9660";
+		devname = getname(tmp.devname);
 		break;
-	case 9:
-		retval = osf_procfs_mount(path, data, flag);
+	case 9: /* procfs */
+		fstype = "proc";
+		devname = getname_kernel("");
 		break;
 	default:
-		retval = -EINVAL;
 		printk("osf_mount(%ld, %x)\n", typenr, flag);
+		return -EINVAL;
 	}
 
+	if (IS_ERR(devname))
+		return PTR_ERR(devname);
+	retval = do_mount(devname.name, dirname, fstype, flags, NULL);
+	putname(devname);
 	return retval;
 }
 
Signature · 1 line
2.28.0
#11 lore raw

Re: [PATCH 4/5] alpha: simplify osf_mount

Quoted 92 lines · Christoph Hellwig

Merge the mount_args structures and mount helpers to simplify the code a bit.

---
 arch/alpha/kernel/osf_sys.c | 111 +++++++++---------------------------
 1 file changed, 28 insertions(+), 83 deletions(-)
arch/alpha/kernel/osf_sys.c +6 -62
index d5367a1c6300c1..5fd155b13503b5 100644
@@ -421,109 +421,54 @@ SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd,
  *
  * Although to be frank, neither are the native Linux/i386 ones..
  */
-struct ufs_args {
+struct osf_mount_args {
 	char __user *devname;
 	int flags;
 	uid_t exroot;
+	/* this has lots more here for cdfs at least, but we don't bother */
 };
 
-struct cdfs_args {
-	char __user *devname;
-	int flags;
-	uid_t exroot;
-
-	/* This has lots more here, which Linux handles with the option block
-	   but I'm too lazy to do the translation into ASCII.  */
-};
-
-struct procfs_args {
-	char __user *devname;
-	int flags;
-	uid_t exroot;
-};
-
-/*
- * We can't actually handle ufs yet, so we translate UFS mounts to
- * ext2fs mounts. I wouldn't mind a UFS filesystem, but the UFS
- * layout is so braindead it's a major headache doing it.
- *
- * Just how long ago was it written? OTOH our UFS driver may be still
- * unhappy with OSF UFS. [CHECKME]
- */
-static int
-osf_ufs_mount(const char __user *dirname,
-	      struct ufs_args __user *args, int flags)
+SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
+		int, flag, void __user *, data)
 {
-	int retval;
-	struct cdfs_args tmp;
+	struct osf_mount_args tmp;
 	struct filename *devname;
-
-	retval = -EFAULT;
-	if (copy_from_user(&tmp, args, sizeof(tmp)))
-		goto out;
-	devname = getname(tmp.devname);
-	retval = PTR_ERR(devname);
-	if (IS_ERR(devname))
-		goto out;
-	retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
-	putname(devname);
- out:
-	return retval;
-}
-
-static int
-osf_cdfs_mount(const char __user *dirname,
-	       struct cdfs_args __user *args, int flags)
-{
+	const char *fstype;
 	int retval;
-	struct cdfs_args tmp;
-	struct filename *devname;
-
-	retval = -EFAULT;
-	if (copy_from_user(&tmp, args, sizeof(tmp)))
-		goto out;
-	devname = getname(tmp.devname);
-	retval = PTR_ERR(devname);
-	if (IS_ERR(devname))
-		goto out;
-	retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
-	putname(devname);
- out:
-	return retval;
-}

arch/alpha/kernel/osf_sys.c SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd, · line 441

Quoted 10 lines
arch/alpha/kernel/osf_sys.c +0 -6
-
-static int
-osf_procfs_mount(const char __user *dirname,
-		 struct procfs_args __user *args, int flags)
-{
-	struct procfs_args tmp;
 
 	if (copy_from_user(&tmp, args, sizeof(tmp)))
 		return -EFAULT;
 

arch/alpha/kernel/osf_sys.c:440:27: error: 'args' undeclared (first use in this function)

Quoted 34 lines
arch/alpha/kernel/osf_sys.c +17 -14
-	return do_mount("", dirname, "proc", flags, NULL);
-}
-
-SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
-		int, flag, void __user *, data)
-{
-	int retval;
-
 	switch (typenr) {
-	case 1:
-		retval = osf_ufs_mount(path, data, flag);
+	case 1: /* ufs */
+		/*
+		 * We can't actually handle ufs yet, so we translate UFS mounts
+		 * to ext2 mounts. I wouldn't mind a UFS filesystem, but the UFS
+		 * layout is so braindead it's a major headache doing it.
+		 *
+		 * Just how long ago was it written? OTOH our UFS driver may be
+		 * still unhappy with OSF UFS. [CHECKME]
+		 */
+		fstype = "ext2";
+		devname = getname(tmp.devname);
 		break;
-	case 6:
-		retval = osf_cdfs_mount(path, data, flag);
+	case 6: /* cdfs */
+		fstype = "iso9660";
+		devname = getname(tmp.devname);
 		break;
-	case 9:
-		retval = osf_procfs_mount(path, data, flag);
+	case 9: /* procfs */
+		fstype = "proc";
+		devname = getname_kernel("");

arch/alpha/kernel/osf_sys.c SYSCALL_DEFINE3(osf_fstatfs64, unsigned long, fd, · line 470

Quoted 10 lines
arch/alpha/kernel/osf_sys.c +4 -1
 		break;
 	default:
-		retval = -EINVAL;
 		printk("osf_mount(%ld, %x)\n", typenr, flag);
+		return -EINVAL;
 	}
 
+	if (IS_ERR(devname))
+		return PTR_ERR(devname);
+	retval = do_mount(devname.name, dirname, fstype, flags, NULL);

arch/alpha/kernel/osf_sys.c:471:34: error:
'dirname' undeclared (first use in this function); did you mean 'devname'?

Quoted 4 lines
arch/alpha/kernel/osf_sys.c +1 -0
+	putname(devname);
 	return retval;
 }
 
#12 lore raw

PATCH 5/5 fs: remove do_mounts

In reply to Christoph Hellwig

There are only two callers left, one of which is is in the alpha-specific OSF/1 compat code. Just open code it in both.

---
 arch/alpha/kernel/osf_sys.c |  7 ++++++-
 fs/namespace.c              | 25 ++++++++-----------------
 include/linux/fs.h          |  2 --
 3 files changed, 14 insertions(+), 20 deletions(-)
arch/alpha/kernel/osf_sys.c +6 -1
index 5fd155b13503b5..8acd5101097576 100644
@@ -434,6 +434,7 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
 	struct osf_mount_args tmp;
 	struct filename *devname;
 	const char *fstype;
+	struct path path;
 	int retval;
 
 	if (copy_from_user(&tmp, args, sizeof(tmp)))
@@ -467,7 +468,11 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
 
 	if (IS_ERR(devname))
 		return PTR_ERR(devname);
-	retval = do_mount(devname.name, dirname, fstype, flags, NULL);
+	retval = user_path_at(AT_FDCWD, dirname, LOOKUP_FOLLOW, &path);
+	if (!retval) {
+		ret = path_mount(devname.name, &path, fstype, flags, NULL);
+		path_put(&path);
+	}
 	putname(devname);
 	return retval;
 }
fs/namespace.c +8 -17
index 12b431b61462b9..2ff373ebeaf27f 100644
@@ -3193,20 +3193,6 @@ int path_mount(const char *dev_name, struct path *path,
 			    data_page);
 }
 
-long do_mount(const char *dev_name, const char __user *dir_name,
-		const char *type_page, unsigned long flags, void *data_page)
-{
-	struct path path;
-	int ret;
-
-	ret = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, &path);
-	if (ret)
-		return ret;
-	ret = path_mount(dev_name, &path, type_page, flags, data_page);
-	path_put(&path);
-	return ret;
-}
-
 static struct ucounts *inc_mnt_namespaces(struct user_namespace *ns)
 {
 	return inc_ucount(ns, current_euid(), UCOUNT_MNT_NAMESPACES);
@@ -3390,10 +3376,11 @@ EXPORT_SYMBOL(mount_subtree);
 SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
 		char __user *, type, unsigned long, flags, void __user *, data)
 {
-	int ret;
+	struct path path;
 	char *kernel_type;
 	char *kernel_dev;
 	void *options;
+	int ret;
 
 	kernel_type = copy_mount_string(type);
 	ret = PTR_ERR(kernel_type);
@@ -3410,8 +3397,12 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
 	if (IS_ERR(options))
 		goto out_data;
 
-	ret = do_mount(kernel_dev, dir_name, kernel_type, flags, options);
-
+	ret = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, &path);
+	if (ret)
+		goto out_options;
+	ret = path_mount(kernel_dev, &path, kernel_type, flags, options);
+	path_put(&path);
+out_options:
 	kfree(options);
 out_data:
 	kfree(kernel_dev);
include/linux/fs.h +0 -2
index 7519ae003a082c..bd9878bdd4bfe9 100644
@@ -2292,8 +2292,6 @@ extern struct vfsmount *kern_mount(struct file_system_type *);
 extern void kern_unmount(struct vfsmount *mnt);
 extern int may_umount_tree(struct vfsmount *);
 extern int may_umount(struct vfsmount *);
-extern long do_mount(const char *, const char __user *,
-		     const char *, unsigned long, void *);
 extern struct vfsmount *collect_mounts(const struct path *);
 extern void drop_collected_mounts(struct vfsmount *);
 extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
Signature · 1 line
2.28.0
#13 lore raw

Re: [PATCH 5/5] fs: remove do_mounts

arch/alpha/kernel/osf_sys.c SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,

Quoted 15 lines · Christoph Hellwig

There are only two callers left, one of which is is in the alpha-specific OSF/1 compat code. Just open code it in both.

---
 arch/alpha/kernel/osf_sys.c |  7 ++++++-
 fs/namespace.c              | 25 ++++++++-----------------
 include/linux/fs.h          |  2 --
 3 files changed, 14 insertions(+), 20 deletions(-)
arch/alpha/kernel/osf_sys.c +0 -0
index 5fd155b13503b5..8acd5101097576 100644
@@ -434,6 +434,7 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
                                                                                             ^^^^

arch/alpha/kernel/osf_sys.c SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path, · line 437

Quoted 4 lines
arch/alpha/kernel/osf_sys.c +1 -0
 	struct osf_mount_args tmp;
 	struct filename *devname;
 	const char *fstype;
+	struct path path;
        ^^^^^^^^^^^^^^^^

Someone didn't bother test building this patch.

arch/alpha/kernel/osf_sys.c: In function '__do_sys_osf_mount':
arch/alpha/kernel/osf_sys.c:437:14: error: 'path' redeclared as different kind of symbol

Guenter

Quoted 82 lines
arch/alpha/kernel/osf_sys.c +5 -1
 	int retval;
 
 	if (copy_from_user(&tmp, args, sizeof(tmp)))
@@ -467,7 +468,11 @@ SYSCALL_DEFINE4(osf_mount, unsigned long, typenr, const char __user *, path,
 
 	if (IS_ERR(devname))
 		return PTR_ERR(devname);
-	retval = do_mount(devname.name, dirname, fstype, flags, NULL);
+	retval = user_path_at(AT_FDCWD, dirname, LOOKUP_FOLLOW, &path);
+	if (!retval) {
+		ret = path_mount(devname.name, &path, fstype, flags, NULL);
+		path_put(&path);
+	}
 	putname(devname);
 	return retval;
 }
fs/namespace.c +8 -17
index 12b431b61462b9..2ff373ebeaf27f 100644
@@ -3193,20 +3193,6 @@ int path_mount(const char *dev_name, struct path *path,
 			    data_page);
 }
 
-long do_mount(const char *dev_name, const char __user *dir_name,
-		const char *type_page, unsigned long flags, void *data_page)
-{
-	struct path path;
-	int ret;
-
-	ret = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, &path);
-	if (ret)
-		return ret;
-	ret = path_mount(dev_name, &path, type_page, flags, data_page);
-	path_put(&path);
-	return ret;
-}
-
 static struct ucounts *inc_mnt_namespaces(struct user_namespace *ns)
 {
 	return inc_ucount(ns, current_euid(), UCOUNT_MNT_NAMESPACES);
@@ -3390,10 +3376,11 @@ EXPORT_SYMBOL(mount_subtree);
 SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
 		char __user *, type, unsigned long, flags, void __user *, data)
 {
-	int ret;
+	struct path path;
 	char *kernel_type;
 	char *kernel_dev;
 	void *options;
+	int ret;
 
 	kernel_type = copy_mount_string(type);
 	ret = PTR_ERR(kernel_type);
@@ -3410,8 +3397,12 @@ SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
 	if (IS_ERR(options))
 		goto out_data;
 
-	ret = do_mount(kernel_dev, dir_name, kernel_type, flags, options);
-
+	ret = user_path_at(AT_FDCWD, dir_name, LOOKUP_FOLLOW, &path);
+	if (ret)
+		goto out_options;
+	ret = path_mount(kernel_dev, &path, kernel_type, flags, options);
+	path_put(&path);
+out_options:
 	kfree(options);
 out_data:
 	kfree(kernel_dev);
include/linux/fs.h +0 -2
index 7519ae003a082c..bd9878bdd4bfe9 100644
@@ -2292,8 +2292,6 @@ extern struct vfsmount *kern_mount(struct file_system_type *);
 extern void kern_unmount(struct vfsmount *mnt);
 extern int may_umount_tree(struct vfsmount *);
 extern int may_umount(struct vfsmount *);
-extern long do_mount(const char *, const char __user *,
-		     const char *, unsigned long, void *);
 extern struct vfsmount *collect_mounts(const struct path *);
 extern void drop_collected_mounts(struct vfsmount *);
 extern int iterate_mounts(int (*)(struct vfsmount *, void *), void *,
maintainer
#14 lore raw

Re: [PATCH 5/5] fs: remove do_mounts

Quoted 4 lines · Guenter Roeck

Someone didn't bother test building this patch.

arch/alpha/kernel/osf_sys.c: In function '__do_sys_osf_mount':
arch/alpha/kernel/osf_sys.c:437:14: error: 'path' redeclared as different kind of symbol

Quite. Matter of fact, there's another problem (path_mount() that needs to be moved from fs/internal.h for that) and IMO this is simply not worth bothering with. I don't see any benefits in the last commit in there; the next-to-last one has some point, and it's not hard to fix, but since it clearly got no testing whatsoever... Christoph, if you want it back, resend it later, *after* having tested it. qemu-system-alpha works well enough to boot the last released debian/alpha.

For now I'm dropping the last two commits from that branch.