From 728c58d60faef288eb7d05d8809fa2b1a55ade89 Mon Sep 17 00:00:00 2001 From: Emoly Liu Date: Thu, 29 Aug 2019 14:15:15 +0800 Subject: [PATCH] LU-12613 ptlrpc: check buffer length in lustre_msg_string() Check buffer length in lustre_msg_string() in case of any invalid access. Change-Id: I286000db16384938a594bd8d104e5f3d0fff585a Reported-by: Alibaba Cloud Signed-off-by: Emoly Liu Reviewed-on: https://review.whamcloud.com/35932 Reviewed-by: Andreas Dilger Reviewed-by: Hongchao Zhang Reviewed-by: Yunye Ry Tested-by: jenkins Tested-by: Maloo --- lustre/ptlrpc/pack_generic.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lustre/ptlrpc/pack_generic.c b/lustre/ptlrpc/pack_generic.c index f59e47b..3c4c3a0 100644 --- a/lustre/ptlrpc/pack_generic.c +++ b/lustre/ptlrpc/pack_generic.c @@ -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) { -- 1.8.3.1