From: Anatoly Burakov Date: Mon, 29 Apr 2019 14:22:50 +0000 (+0100) Subject: ipc: harden message receive X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7b51d1b162914e37bcc511a11efcfbabb44b2eb3;hp=535113907f23134375b18f40b6642a963ec50141;p=dpdk.git ipc: harden message receive Currently, IPC does not check received messages for invalid data and passes them to user code unchanged. This may result in buffer overruns on reading message data. Fix this by checking the message length and fd number on receive, and discard any messages that are not valid. Fixes: bacaa2754017 ("eal: add channel for multi-process communication") Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov --- diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index 8586474a24..6ffd476861 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -285,7 +285,15 @@ read_msg(struct mp_msg_internal *m, struct sockaddr_un *s) break; } } - + /* sanity-check the response */ + if (m->msg.num_fds < 0 || m->msg.num_fds > RTE_MP_MAX_FD_NUM) { + RTE_LOG(ERR, EAL, "invalid number of fd's received\n"); + return -1; + } + if (m->msg.len_param < 0 || m->msg.len_param > RTE_MP_MAX_PARAM_LEN) { + RTE_LOG(ERR, EAL, "invalid received data length\n"); + return -1; + } return 0; }