Skip to content

Commit 37d4183

Browse files
jtlaytonjfvogel
authored andcommitted
sunrpc: increase UNX_MAXNODENAME from 32 to __NEW_UTS_LEN bytes
The current limit of 32 bytes artificially limits the name string that we end up stuffing into NFSv4.x client ID blobs. If you have multiple hosts with long hostnames that only differ near the end, then this can cause NFSv4 client ID collisions. Linux nodenames are actually limited to __NEW_UTS_LEN bytes (64), so use that as the limit instead. Also, use XDR_QUADLEN to specify the slack length, just for clarity and in case someone in the future changes this to something not evenly divisible by 4. Reported-by: Michael Skralivetsky <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Trond Myklebust <[email protected]> Orabug: 28660177 (cherry picked from commit 24a9a96) Signed-off-by: Calum Mackay <[email protected]> Reviewed-by: Srinivas Eeda <[email protected]> Reviewed-by: John Sobecki <[email protected]> Tested-by: Joe Jin <[email protected]>
1 parent 60ca151 commit 37d4183

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

include/linux/sunrpc/auth.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@
1818
#include <linux/atomic.h>
1919
#include <linux/rcupdate.h>
2020
#include <linux/uidgid.h>
21+
#include <linux/utsname.h>
2122

22-
/* size of the nodename buffer */
23-
#define UNX_MAXNODENAME 32
23+
/*
24+
* Size of the nodename buffer. RFC1831 specifies a hard limit of 255 bytes,
25+
* but Linux hostnames are actually limited to __NEW_UTS_LEN bytes.
26+
*/
27+
#define UNX_MAXNODENAME __NEW_UTS_LEN
2428

2529
struct rpcsec_gss_info;
2630

net/sunrpc/auth_unix.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct unx_cred {
2323
};
2424
#define uc_uid uc_base.cr_uid
2525

26-
#define UNX_WRITESLACK (21 + (UNX_MAXNODENAME >> 2))
26+
#define UNX_WRITESLACK (21 + XDR_QUADLEN(UNX_MAXNODENAME))
2727

2828
#if IS_ENABLED(CONFIG_SUNRPC_DEBUG)
2929
# define RPCDBG_FACILITY RPCDBG_AUTH

0 commit comments

Comments
 (0)