Whamcloud - gitweb
LU-12613 ptlrpc: check buffer length in lustre_msg_string() 32/35932/7
authorEmoly Liu <emoly@whamcloud.com>
Thu, 29 Aug 2019 06:15:15 +0000 (14:15 +0800)
committerOleg Drokin <green@whamcloud.com>
Mon, 16 Sep 2019 23:00:44 +0000 (23:00 +0000)
Check buffer length in lustre_msg_string() in case of any invalid
access.

Change-Id: I286000db16384938a594bd8d104e5f3d0fff585a
Reported-by: Alibaba Cloud <yunye.ry@alibaba-inc.com>
Signed-off-by: Emoly Liu <emoly@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/35932
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Hongchao Zhang <hongchao@whamcloud.com>
Reviewed-by: Yunye Ry <yunye.ry@alibaba-inc.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
lustre/ptlrpc/pack_generic.c

index f59e47b..3c4c3a0 100644 (file)
@@ -762,6 +762,11 @@ char *lustre_msg_string(struct lustre_msg *m, __u32 index, __u32 max_len)
                         "msg %p buffer[%d] len %d\n", m, index, blen);
                 return NULL;
         }
+       if (blen > PTLRPC_MAX_BUFLEN) {
+               CERROR("buffer length of msg %p buffer[%d] is invalid(%d)\n",
+                      m, index, blen);
+               return NULL;
+       }
 
         if (max_len == 0) {
                 if (slen != blen - 1) {