From: Chris Horn Date: Fri, 6 Sep 2024 15:27:21 +0000 (-0600) Subject: LU-18106 obdclass: Fix evict-by-nid for long NIDs X-Git-Tag: 2.15.91~21 X-Git-Url: https://git.whamcloud.com/gitweb?a=commitdiff_plain;h=f38bb8e7b8b4fe35f1274626dfaf4a3e7785e10c;p=fs%2Flustre-release.git LU-18106 obdclass: Fix evict-by-nid for long NIDs LNet NIDs can be up to LNET_NIDSTR_SIZE (64) bytes (including the NUL byte), but we are only copying UUID_MAX + 3 (43) bytes of the userspace buffer. NIDs larger than this would get truncated, no matching export found, and thus no eviction. Fix it by copying LNET_NIDSTR_SIZE - 1 bytes. Test-Parameters: trivial Test-Parameters: testlist=conf-sanity env=ONLY=91,FORCE_LARGE_NID=true,LOAD_MODULES_REMOTE=true Signed-off-by: Chris Horn Change-Id: I9ca15a89f0d41a6ca355a690a7f9fb25a80d8f82 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56281 Reviewed-by: James Simmons Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin Tested-by: jenkins Tested-by: Maloo --- diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index e950d5c..fc335ef 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -415,7 +415,7 @@ static int mdt_site_stats_seq_show(struct seq_file *m, void *data) } LPROC_SEQ_FOPS_RO(mdt_site_stats); -#define BUFLEN (UUID_MAX + 4) +#define BUFLEN LNET_NIDSTR_SIZE static ssize_t lprocfs_mds_evict_client_seq_write(struct file *file, const char __user *buf, @@ -435,7 +435,7 @@ lprocfs_mds_evict_client_seq_write(struct file *file, const char __user *buf, /* * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1 * bytes into kbuf, to ensure that the string is NUL-terminated. - * UUID_MAX should include a trailing NUL already. + * LNET_NIDSTR_SIZE includes space for a trailing NUL already. */ if (copy_from_user(kbuf, buf, min_t(unsigned long, BUFLEN - 1, count))) GOTO(out, rc = -EFAULT); diff --git a/lustre/obdclass/lprocfs_status_server.c b/lustre/obdclass/lprocfs_status_server.c index c657f90..ae88ccd 100644 --- a/lustre/obdclass/lprocfs_status_server.c +++ b/lustre/obdclass/lprocfs_status_server.c @@ -116,7 +116,7 @@ int lprocfs_recovery_stale_clients_seq_show(struct seq_file *m, void *data) EXPORT_SYMBOL(lprocfs_recovery_stale_clients_seq_show); #ifdef CONFIG_PROC_FS -#define BUFLEN (UUID_MAX + 5) +#define BUFLEN LNET_NIDSTR_SIZE ssize_t lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer, @@ -133,7 +133,7 @@ lprocfs_evict_client_seq_write(struct file *file, const char __user *buffer, /* * OBD_ALLOC() will zero kbuf, but we only copy BUFLEN - 1 * bytes into kbuf, to ensure that the string is NUL-terminated. - * UUID_MAX should include a trailing NUL already. + * LNET_NIDSTR_SIZE includes space for a trailing NUL already. */ if (copy_from_user(kbuf, buffer, min_t(unsigned long, BUFLEN - 1, count))) {