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 0CC5CA0524; Tue, 1 Jun 2021 09:45:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DB4A941173; Tue, 1 Jun 2021 09:40:34 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mails.dpdk.org (Postfix) with ESMTP id AE99D41199 for ; Tue, 1 Jun 2021 09:40:32 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622533231; 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=mJlUzPb0emCP1HwWxV9UrlAbbLNOVkj+X1QwV9yI0V0=; b=dr8CyCMuKm+sFsg9rMulvrMQFLsrsSvm/hnsmFREJeJWtpcST3N3EUm69AqT2egNHxv4ID gyYUpNYq4P6I8mChSRvU9UP6gkFauso8T30dWd5t8+9w72VRVdnItHBWMWA/12vK9WItb4 kEB5nwa8kuMwAnuhcGwKTjL7+qxNG0Y= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-HfDlq1OOMEK-R6Bsco5f1A-1; Tue, 01 Jun 2021 03:40:29 -0400 X-MC-Unique: HfDlq1OOMEK-R6Bsco5f1A-1 Received: by mail-wm1-f70.google.com with SMTP id n127-20020a1c27850000b02901717a27c785so786835wmn.9 for ; Tue, 01 Jun 2021 00:40:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=mJlUzPb0emCP1HwWxV9UrlAbbLNOVkj+X1QwV9yI0V0=; b=V83SXuurUAI9WJTJHIlN56BJA6nyo+buGaka+honwYc3d1SH2y/TbgoI+Jea1SlDrt sEI6pB8LGWucqX80A9o6hyYVUBIdq60MlF1k7CjcmWy/2/+mlIMqz5FWwDG/rVJfn7mi nIgs/SLUgjx5chhERHaLy9uCH5Vqa8iDyL9ankJYiuE0zE53M1S0OSBDZLA6ySqQj/oy X4GzafNZBJCNGIN2TG8R6pzCzjZJedVAbZrPsMzebi5rJ8RJbgLDZcuJFtT9lHlXCapo 0W4Rw9B6QcL4wkQJFcXwdcqZRG/wkv9qBmiyiHolMPJXLiLoG3TcqRrLJ/1n8l9uEnO7 IexQ== X-Gm-Message-State: AOAM532Fnn530vCZj/dNkXmpcsGy0hCU3mwbJ41nmQQSXNPACit6QCv2 TR6kIgSrAYEn304MAqlAUDYEClF2eeFW6U0TGuWbIv5mzweTsyHg0qfb/RDJRQHxa9WCV/JQVEz 8qDA= X-Received: by 2002:a5d:59a4:: with SMTP id p4mr27009827wrr.248.1622533228715; Tue, 01 Jun 2021 00:40:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxwSGJlp1TeC6sY+xo13wCQom9xTQT+7ngUEYbF8NogTJUhYiYXosghYybTGvORn8RjG23MDg== X-Received: by 2002:a5d:59a4:: with SMTP id p4mr27009805wrr.248.1622533228495; Tue, 01 Jun 2021 00:40:28 -0700 (PDT) Received: from [192.168.1.205] (219-230-83-45.ftth.cust.kwaoo.net. [45.83.230.219]) by smtp.gmail.com with ESMTPSA id b8sm2191216wrx.15.2021.06.01.00.40.26 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 01 Jun 2021 00:40:26 -0700 (PDT) To: Thierry Herbelot , dev@dpdk.org Cc: Thomas Monjalon , stable@dpdk.org, Maxime Coquelin , Chenbo Xia References: <20210524085812.15916-1-thierry.herbelot@6wind.com> <20210524090821.17780-1-thierry.herbelot@6wind.com> From: Maxime Coquelin Message-ID: <5539804e-1d57-2e15-1882-0dda7d7adcea@redhat.com> Date: Tue, 1 Jun 2021 09:40:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20210524090821.17780-1-thierry.herbelot@6wind.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=mcoqueli@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH v2] vhost/vhost_crypto: do not use possibly NULL Pointers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 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" Hi Thierry, On 5/24/21 11:08 AM, Thierry Herbelot wrote: > Use vc_req only after it was checked not to be NULL. > > Fixes: 2d962bb736521 ("vhost/crypto: fix possible TOCTOU attack") > Cc: stable@dpdk.org > Cc: Maxime Coquelin > Cc: Chenbo Xia > > Signed-off-by: Thierry Herbelot > -- > V2: fix copy/paste typo > --- > lib/vhost/vhost_crypto.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/lib/vhost/vhost_crypto.c b/lib/vhost/vhost_crypto.c > index 6689c52df239..926b5c0bd94a 100644 > --- a/lib/vhost/vhost_crypto.c > +++ b/lib/vhost/vhost_crypto.c > @@ -1337,13 +1337,15 @@ vhost_crypto_finalize_one_request(struct rte_crypto_op *op, > struct rte_mbuf *m_src = op->sym->m_src; > struct rte_mbuf *m_dst = op->sym->m_dst; > struct vhost_crypto_data_req *vc_req = rte_mbuf_to_priv(m_src); > - struct vhost_virtqueue *vq = vc_req->vq; > - uint16_t used_idx = vc_req->desc_idx, desc_idx; > + struct vhost_virtqueue *vq; > + uint16_t used_idx, desc_idx; > > if (unlikely(!vc_req)) { > VC_LOG_ERR("Failed to retrieve vc_req"); > return NULL; > } > + vq = vc_req->vq; > + used_idx = vc_req->desc_idx; > > if (old_vq && (vq != old_vq)) > return vq; > Reviewed-by: Maxime Coquelin Thanks, Maxime