Skip to contentSkip to conversation

Fix umount.nfs

PATCH In review Chuck Lever 2 participants 5 messages Apr 17, 2009 – Apr 20, 2009 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Fix umount.nfs

Hi Steve-

This short series addresses a couple of problems found with umount.nfs. See RH bugzilla 492598.

After this series is applied, umount.nfs will send UMNT requests from a privileged source port. This appears to match the behavior of umount.nfs before nfs-utils 1.1.5, and is required when the "secure" export option is used on the server.

A minor problem with the value returned by nfs_mount_protocol() is also addressed. This might affect umount.nfs and NFSv2/v3 version/protocol fallback by sending MNT and UMNT requests using the wrong transport protocol.

---

Chuck Lever (3):
umount.nfs: Fix return value of nfs_mount_protocol() umount.nfs: Use a privileged port when sending UMNT requests
support: Provide an API for creating a privileged RPC client

 support/include/nfsrpc.h |   11 +++-
 support/nfs/rpc_socket.c |  140 ++++++++++++++++++++++++++++++++++++++++++++--
 utils/mount/network.c    |    4 +
 3 files changed, 145 insertions(+), 10 deletions(-)
Signature · 1 line
Chuck Lever <[email protected]>

A message that is not in the archive (sent off-list or not yet received): 20090417201021.14555.93852.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org

#2 lore raw

PATCH 1/3 support: Provide an API for creating a privileged RPC client

We needed to guarantee that some RPC programs, such as PMAP, got an unprivileged port, to prevent exhausting the local privileged port space sending RPC requests that don't need such privileges. nfs_get_rpcclient() provides that feature.

However, some RPC programs, such as MNT and UMNT, require a privileged port. So, let's provide an additional API for this that also supports IPv6 and setting a destination port.

---

 support/include/nfsrpc.h |   11 +++-
 support/nfs/rpc_socket.c |  140 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 143 insertions(+), 8 deletions(-)
support/include/nfsrpc.h +10 -1
index 097debb..543c35b 100644
@@ -24,6 +24,7 @@
 #define __NFS_UTILS_NFSRPC_H
 
 #include <rpc/types.h>
+#include <rpc/clnt.h>
 
 /*
  * Conventional RPC program numbers
@@ -54,7 +55,7 @@
 extern rpcprog_t	nfs_getrpcbyname(const rpcprog_t, const char *table[]);
 
 /*
- * Acquire an RPC CLIENT *
+ * Acquire an RPC CLIENT * with an ephemeral source port
  */
 extern CLIENT		*nfs_get_rpcclient(const struct sockaddr *,
 				const socklen_t, const unsigned short,
@@ -62,6 +63,14 @@ extern CLIENT		*nfs_get_rpcclient(const struct sockaddr *,
 				struct timeval *);
 
 /*
+ * Acquire an RPC CLIENT * with a privileged source port
+ */
+extern CLIENT		*nfs_get_priv_rpcclient( const struct sockaddr *,
+				const socklen_t, const unsigned short,
+				const rpcprog_t, const rpcvers_t,
+				struct timeval *);
+
+/*
  * Convert a socket address to a universal address
  */
 extern char		*nfs_sockaddr2universal(const struct sockaddr *,
support/nfs/rpc_socket.c +133 -7

184 lines not on this page · raw message

#3 lore raw

PATCH 2/3 umount.nfs: Use a privileged port when sending UMNT requests

In reply to a message not in the archive

Turns out we do actually need to use a privileged port for UMNT. The Linux rpc.mountd complains if an ephemeral source port is used:

  Apr 17 15:52:19 ingres mountd[2061]: refused unmount request from
    192.168.0.59 for /export (/export): illegal port 60932

---

 utils/mount/network.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
utils/mount/network.c +1 -1
index bcd0c0f..234e7f3 100644
@@ -869,7 +869,7 @@ int nfs_advise_umount(const struct sockaddr *sap, const socklen_t salen,
 	memcpy(saddr, sap, salen);
 	nfs_set_port(saddr, mnt_pmap.pm_port);
 
-	client = nfs_get_rpcclient(saddr, salen, mnt_pmap.pm_prot,
+	client = nfs_get_priv_rpcclient(saddr, salen, mnt_pmap.pm_prot,
 					mnt_pmap.pm_prog, mnt_pmap.pm_vers,
 					&timeout);
 	if (client == NULL)
#4 lore raw

PATCH 3/3 umount.nfs: Fix return value of nfs_mount_protocol()

In reply to a message not in the archive

Fix a copy-paste error introduced in nfs_mount_protocol(). It should return an IPPROTO_ number, not an NFS version number.

---

 utils/mount/network.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
utils/mount/network.c +1 -1
index 234e7f3..72f4b84 100644
@@ -1337,7 +1337,7 @@ static unsigned short nfs_mount_protocol(struct mount_options *options)
 			return IPPROTO_UDP;
 	}
 
-	return nfs_nfs_version(options);
+	return nfs_nfs_protocol(options);
 }
 
 /*
#5 lore raw
In reply to a message not in the archive
Quoted 23 lines · Chuck Lever

Hi Steve-

This short series addresses a couple of problems found with umount.nfs. See RH bugzilla 492598.

After this series is applied, umount.nfs will send UMNT requests from a privileged source port. This appears to match the behavior of umount.nfs before nfs-utils 1.1.5, and is required when the "secure" export option is used on the server.

A minor problem with the value returned by nfs_mount_protocol() is also addressed. This might affect umount.nfs and NFSv2/v3 version/protocol fallback by sending MNT and UMNT requests using the wrong transport protocol.

---

Chuck Lever (3):
umount.nfs: Fix return value of nfs_mount_protocol() umount.nfs: Use a privileged port when sending UMNT requests
support: Provide an API for creating a privileged RPC client

Quoted 5 lines
 support/include/nfsrpc.h |   11 +++-
 support/nfs/rpc_socket.c |  140 ++++++++++++++++++++++++++++++++++++++++++++--
 utils/mount/network.c    |    4 +
 3 files changed, 145 insertions(+), 10 deletions(-)

All three patched tested and committed.

steved.