From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id E120AA0352; Thu, 16 Jan 2020 11:44:57 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id A9F941C20A; Thu, 16 Jan 2020 11:44:57 +0100 (CET) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by dpdk.org (Postfix) with ESMTP id 1EE611C1FB for ; Thu, 16 Jan 2020 11:44:55 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579171494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=KZA6wSyVIilmGMcTTIbNfUmBncELDB1t4NMUS+dai4Y=; b=ZbF5MEOPraCk6iRd2Ae4QCz2gJajylUvemwR77dR6dthCJVDFxNEHHDh4OSA698HhMrzup ysjXuJg3iViw4PylCY7Ra0CmqD6LDqwy0Vr9po8PpcqNq+r0cYCpHgtQPbR/1ZwYRIet9/ 2naPyQd184a0Vs1htAC+2Ssgrr58Oqw= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-BoCcwcuWMNixNeiCjcSiUQ-1; Thu, 16 Jan 2020 05:44:51 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 33284DB21; Thu, 16 Jan 2020 10:44:50 +0000 (UTC) Received: from localhost.localdomain (unknown [10.36.112.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DF5A10016EB; Thu, 16 Jan 2020 10:44:46 +0000 (UTC) From: Maxime Coquelin To: dev@dpdk.org, tiwei.bie@intel.com, zhihong.wang@intel.com Cc: Maxime Coquelin , stable@dpdk.org, Ilja Van Sprundel Date: Thu, 16 Jan 2020 11:44:44 +0100 Message-Id: <20200116104444.3862-1-maxime.coquelin@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-MC-Unique: BoCcwcuWMNixNeiCjcSiUQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Subject: [dpdk-dev] [PATCH] vhost: check vhost message header size read X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch adds a check to ensure the read size of the Vhost-user message header is not smaller than the expected size. Fixes: 8f972312b8f4 ("vhost: support vhost-user") Cc: stable@dpdk.org Reported-by: Ilja Van Sprundel Signed-off-by: Maxime Coquelin --- lib/librte_vhost/vhost_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c index 69b84a8820..0b7d1e288e 100644 --- a/lib/librte_vhost/vhost_user.c +++ b/lib/librte_vhost/vhost_user.c @@ -2440,8 +2440,12 @@ read_vhost_message(int sockfd, struct VhostUserMsg *= msg) =20 =09ret =3D read_fd_message(sockfd, (char *)msg, VHOST_USER_HDR_SIZE, =09=09msg->fds, VHOST_MEMORY_MAX_NREGIONS, &msg->fd_num); -=09if (ret <=3D 0) +=09if (ret <=3D 0) { =09=09return ret; +=09} else if (ret !=3D VHOST_USER_HDR_SIZE) { +=09=09VHOST_LOG_CONFIG(ERR, "Unexpected header size read\n"); +=09=09return -1; +=09} =20 =09if (msg->size) { =09=09if (msg->size > sizeof(msg->payload)) { --=20 2.21.0