From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH v3] net/virtio: fix of untrusted scalar value Date: Wed, 27 Sep 2017 17:25:17 +0800 Message-ID: <20170927092517.GI2251@yliu-home> References: <20170920132556.5310-1-danielx.t.mrzyglod@intel.com> <20170922152149.16876-1-danielx.t.mrzyglod@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org, jianfeng.tan@intel.com, stable@dpdk.org To: Daniel Mrzyglod Return-path: Received: from mail-pf0-f169.google.com (mail-pf0-f169.google.com [209.85.192.169]) by dpdk.org (Postfix) with ESMTP id 06E482C01 for ; Wed, 27 Sep 2017 11:25:26 +0200 (CEST) Received: by mail-pf0-f169.google.com with SMTP id x78so6964579pff.10 for ; Wed, 27 Sep 2017 02:25:25 -0700 (PDT) Content-Disposition: inline In-Reply-To: <20170922152149.16876-1-danielx.t.mrzyglod@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Sep 22, 2017 at 05:21:49PM +0200, Daniel Mrzyglod wrote: > The unscrutinized value may be incorrectly assumed to be within a certain > range by later operations. > > In vhost_user_read: An unscrutinized value from an untrusted source used > in a trusted context - the value of sz_payload may be harmfull and we need > limit them to the max value of payload. > > Coverity issue: 139601 > > Fixes: 6a84c37e3975 ("net/virtio-user: add vhost-user adapter layer") > Cc: jianfeng.tan@intel.com > Cc: stable@dpdk.org > > Signed-off-by: Daniel Mrzyglod FYI, you should put the Ack from Jianfeng here, so that it will be there when I apply your patch. Otherwise, I have to add it back manually. But never mind, I have done it this time. So, applied to dpdk-next-virtio. Thanks. --yliu > --- > v3: > * there were wrong v2 email adress for stable dpdk mailinglist > * fix compilation errors > > v2: > * Add Cc for stable in gitlog massage > * Add Coverity line > * v1 was acked by Acked-by: Jianfeng Tan > > > drivers/net/virtio/virtio_user/vhost_user.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/drivers/net/virtio/virtio_user/vhost_user.c b/drivers/net/virtio/virtio_user/vhost_user.c > index 4ad7b21..97bd832 100644 > --- a/drivers/net/virtio/virtio_user/vhost_user.c > +++ b/drivers/net/virtio/virtio_user/vhost_user.c > @@ -130,6 +130,10 @@ vhost_user_read(int fd, struct vhost_user_msg *msg) > } > > sz_payload = msg->size; > + > + if ((size_t)sz_payload > sizeof(msg->payload)) > + goto fail; > + > if (sz_payload) { > ret = recv(fd, (void *)((char *)msg + sz_hdr), sz_payload, 0); > if (ret < sz_payload) { > -- > 2.7.4