Whamcloud - gitweb
LU-18106 obdclass: Fix evict-by-nid for long NIDs 81/56281/2
authorChris Horn <chris.horn@hpe.com>
Fri, 6 Sep 2024 15:27:21 +0000 (09:27 -0600)
committerOleg Drokin <green@whamcloud.com>
Thu, 12 Sep 2024 05:53:23 +0000 (05:53 +0000)
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 <chris.horn@hpe.com>
Change-Id: I9ca15a89f0d41a6ca355a690a7f9fb25a80d8f82
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/56281
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/mdt/mdt_lproc.c
lustre/obdclass/lprocfs_status_server.c

index e950d5c..fc335ef 100644 (file)
@@ -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);
index c657f90..ae88ccd 100644 (file)
@@ -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))) {