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 704DBA0C43; Fri, 27 Aug 2021 07:16:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EC319406B4; Fri, 27 Aug 2021 07:16:21 +0200 (CEST) Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by mails.dpdk.org (Postfix) with ESMTP id D75EA4067C for ; Fri, 27 Aug 2021 07:16:20 +0200 (CEST) Received: by mail-pl1-f180.google.com with SMTP id q21so3226202plq.3 for ; Thu, 26 Aug 2021 22:16:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=smartx-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AqUsobMiwdMoMuSYO1T24XkR1nh23gn+DbjHsJlMBrA=; b=QL05qtfRBBn5HmUAiuo8DxVfJq8qCUOgnc9zOHF4mnOvGMdV9rd4jQWRXdChDRLCMY xVqEGmEJqWFagL7ckjrxioMHM5FgOYTY0VA1DEJDwdHwzQHeYPGG6phADf43ZFuK7Qou 31VyX9/EuH62u2OvUISCTpyXPcyVqIR236EGc53Tj5QBuyTg+D2d/Kwphd7+XtIhjtry fdxUydgk/4hHK/TV1DGfIS1aH33rxOYO76btexBMw+FuiDcY9i71c5X9KsOmYwMozcCm nIVZ5YVauId0Ge5oODSQsXcNRtfo/rJHKQTPlNuUPzGq9X9K0N2SODc3n2y+0Cl3dO6p rwug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=AqUsobMiwdMoMuSYO1T24XkR1nh23gn+DbjHsJlMBrA=; b=rg5HhKJTDNEZDxKD5xd6kEe/WgLk02IWeE+HmdA2Bz3ZulvgM+ilkO05rz7f2z2I94 4ANQU/sWhGwraopDHVZW+rGAaSQwg5nQawCy+odb7rPv6Gc/hdjEXXl0i8XcG6/NVeAF sDIkPVp0NlBHOjBYqLrRusXdwL9cSJuhEfFZ4qyXBrcc3mkOoyY7A7nUw2sXcHrfPhER F1AH40etxIgOrFaPZ7sEIb7cx0F5S5C76Avqae9A7tgWVTcA+4vShEJQs4hKC6UwjIgx p0I0ktJjzKWKu/ytd9ToyqI31Oj/GpLVR3HnQ0r6UUmsSkEmQXtxHP4qi14oWifJQCT8 MVcA== X-Gm-Message-State: AOAM532nXce14u5xR1roMIaYwlEnSHtWIVCPJryO6cajKWNwIAImyT/g 411fwRW7wq1fTx9M9lHUraVCRcno7+1icg41Kf8= X-Google-Smtp-Source: ABdhPJwAoOvBcUbHl3BtM9XjNaN/oO1wBJURYDYREa9Ll8hUdsg7i0gQ1Su3S3Zp2xHLhULE8OG7mQ== X-Received: by 2002:a17:902:70cb:b0:132:6a68:af90 with SMTP id l11-20020a17090270cb00b001326a68af90mr7042690plt.56.1630041379900; Thu, 26 Aug 2021 22:16:19 -0700 (PDT) Received: from 64-217.. (n218250051201.netvigator.com. [218.250.51.201]) by smtp.gmail.com with ESMTPSA id p24sm5602889pgm.54.2021.08.26.22.16.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Aug 2021 22:16:19 -0700 (PDT) From: Li Feng To: Maxime Coquelin , Chenbo Xia Cc: dev@dpdk.org, Li Feng Date: Fri, 27 Aug 2021 13:12:41 +0800 Message-Id: <20210827051241.2448098-1-fengli@smartx.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v1] vhost: add sanity check for resubmiting reqs in split ring 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" When getting reqs from the avail ring, the id may exceed inflight queue size. Then the dpdk will crash forever. Signed-off-by: Li Feng --- lib/vhost/vhost_user.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/vhost/vhost_user.c b/lib/vhost/vhost_user.c index 29a4c9af60..f09d0f6a48 100644 --- a/lib/vhost/vhost_user.c +++ b/lib/vhost/vhost_user.c @@ -1823,8 +1823,14 @@ vhost_check_queue_inflights_split(struct virtio_net *dev, last_io = inflight_split->last_inflight_io; if (inflight_split->used_idx != used->idx) { - inflight_split->desc[last_io].inflight = 0; - rte_atomic_thread_fence(__ATOMIC_SEQ_CST); + if (unlikely(last_io >= inflight_split->desc_num)) { + VHOST_LOG_CONFIG(ERR, "last_inflight_io '%"PRIu16"' exceeds inflight " + "queue size (%"PRIu16").\n", last_io, + inflight_split->desc_num); + } else { + inflight_split->desc[last_io].inflight = 0; + rte_atomic_thread_fence(__ATOMIC_SEQ_CST); + } inflight_split->used_idx = used->idx; } -- 2.31.1