From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 9CB55A00BE for ; Thu, 10 Mar 2022 14:00:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C3BA41144; Thu, 10 Mar 2022 14:00:27 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 4563F4113E for ; Thu, 10 Mar 2022 14:00:26 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646917225; 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: in-reply-to:in-reply-to:references:references; bh=XrgshKqB/hcuYxWqbGKqJFwn9j1fFeXLlm2zIbCcnzQ=; b=UFk9kqWiaMwoekofGHBCqRiy7stXNgqC2KBdnj56jZ3BNppYUf5ANBvMqCBd1ihn4vb/hq fc0L85l7U9isPnLgBjRQmbYQS4bwVqezqlfvlDskiavySgareCBWaYwFI/VQPRIF5nJqOd tgM8UjhjS/8liLVYnZ5BnQ/Xy3OJcjI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-445-nyq-IDDzOfqOYamhjb1isQ-1; Thu, 10 Mar 2022 08:00:22 -0500 X-MC-Unique: nyq-IDDzOfqOYamhjb1isQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A29EB1006AA5; Thu, 10 Mar 2022 13:00:21 +0000 (UTC) Received: from [10.39.208.21] (unknown [10.39.208.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A1E6317A94; Thu, 10 Mar 2022 13:00:15 +0000 (UTC) Message-ID: <6f056e81-07c9-d20f-47a2-f76fc51322c8@redhat.com> Date: Thu, 10 Mar 2022 14:00:14 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 2/2] vhost: fix FD leak with inflight messages To: David Marchand , dev@dpdk.org Cc: chenbo.xia@intel.com, stable@dpdk.org References: <20220310125059.30562-1-david.marchand@redhat.com> <20220310125059.30562-2-david.marchand@redhat.com> From: Maxime Coquelin In-Reply-To: <20220310125059.30562-2-david.marchand@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On 3/10/22 13:50, David Marchand wrote: > Even if unlikely, a buggy vhost-user master might attach fds to inflight > messages. Add checks like for other types of vhost-user messages. > > Fixes: d87f1a1cb7b6 ("vhost: support inflight info sharing") > Cc: stable@dpdk.org > > Signed-off-by: David Marchand > --- > lib/vhost/vhost_user.c | 6 ++++++ > 1 file changed, 6 insertions(+) > > diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c > index 1ec4357bee..1d390677fa 100644 > --- a/lib/vhost/vhost_user.c > +++ b/lib/vhost/vhost_user.c > @@ -1602,6 +1602,9 @@ vhost_user_get_inflight_fd(struct virtio_net **pdev, > int numa_node = SOCKET_ID_ANY; > void *addr; > > + if (validate_msg_fds(dev, ctx, 0) != 0) > + return RTE_VHOST_MSG_RESULT_ERR; > + > if (ctx->msg.size != sizeof(ctx->msg.payload.inflight)) { > VHOST_LOG_CONFIG(ERR, "(%s) invalid get_inflight_fd message size is %d\n", > dev->ifname, ctx->msg.size); > @@ -1699,6 +1702,9 @@ vhost_user_set_inflight_fd(struct virtio_net **pdev, > int fd, i; > int numa_node = SOCKET_ID_ANY; > > + if (validate_msg_fds(dev, ctx, 1) != 0) > + return RTE_VHOST_MSG_RESULT_ERR; > + > fd = ctx->fds[0]; > if (ctx->msg.size != sizeof(ctx->msg.payload.inflight) || fd < 0) { > VHOST_LOG_CONFIG(ERR, "(%s) invalid set_inflight_fd message size is %d,fd is %d\n", Reviewed-by: Maxime Coquelin Thanks, Maxime