Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp5066384pxb; Mon, 15 Feb 2021 08:37:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzgn1jB5H45ZH3/FjapzbCYhPuk30qb94iO/6n2ChUT16kEjl43+2J1oUP56hjM3hLDyvpt X-Received: by 2002:a50:8a90:: with SMTP id j16mr16163152edj.334.1613407046528; Mon, 15 Feb 2021 08:37:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613407046; cv=none; d=google.com; s=arc-20160816; b=N1EpYhUPyqfxO4o9HVJl7GHNGhDNobXl/sq+1Hb8gcgiaL+MZoPnrkBCyGPMXwgb/I wPR4VLfhImdWALGwUJnihf7+NMVNG+tBASHP4tlklGyKbBmp03U1tza/5NmLHOfogG1X Ipv/cEk58IAqOj7R/F3/Kgsr9CQjpKU5bD6btKTE80t2DZ70P0aa8qyh9+7Wy3Oo0DJh Cp5+ln1jQJVOD5EGsg75UbQCvXzuqiDT/gxw8M3VnbAq7LW0U9yu5YADR8MBXnLVJA/V UdyEZ3LloGmTVSFp5dsGse2UjRw/JSoFzwcPJ8GXkaMoxiWqLUNjVaqO91lpPx5fN5wR JN7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ta5xTigb9Yej5R7JkTKnuKQhnhaOeFcbqa+fXA4fj7s=; b=ODt9W3Fykdy0a9lLXWwapytCpN+n8tswNO3DZtI6OhqAWAxjqG1xKh9R1Vy636GeNb cPs/EWqsCuM1t+xgxdfo8k6sv2M2Cot0jw8Rert8l6zXiousNuYVgszs/nDVZh2zynhS H6AeA1gPPFF1oB+G3GOoM56WnqxGUe5IS/rvyfOYx0mldoPEH2oq9NegMjYa4PgeS/oK NIE/km/HYtsZc7LrAu8HPN0s3pc71liMIEaeyckdtYUhVvhea6gr2N239AFabfrjz/YC xtJQv2RzHnjQ/3zYRonR6NmpIte1+3poJnmfDwTaAz0VzlwKYf3k1eGkgtohCga6MhCB GTDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="wr1ODP/I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y18si12732768edw.35.2021.02.15.08.37.02; Mon, 15 Feb 2021 08:37:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="wr1ODP/I"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231397AbhBOQgP (ORCPT + 99 others); Mon, 15 Feb 2021 11:36:15 -0500 Received: from mail.kernel.org ([198.145.29.99]:49600 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231462AbhBOPht (ORCPT ); Mon, 15 Feb 2021 10:37:49 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6B5FD64EA1; Mon, 15 Feb 2021 15:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613403189; bh=qgzS7wxRx3dLglzG4utUzIJH1AUFn3MhFa/oV2d+NK0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wr1ODP/I9XVweCS6YC+hxzrFDdP1LhjwSaqKsYBiGV88Uu04BtWXlEgDcPz24LJHi NHvmeCwZqciEgZ4K675zlpQXBGt2BIf9so5Af/SjxrI+uH2Q4tUC2cH4JpB5b70Utc rpwHsyELYwjLDgd49TcasOcNgfVKoyZkHxPJhtAo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Igor Druzhinin , Juergen Gross , Wei Liu , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 061/104] xen/netback: avoid race in xenvif_rx_ring_slots_available() Date: Mon, 15 Feb 2021 16:27:14 +0100 Message-Id: <20210215152721.443983403@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210215152719.459796636@linuxfoundation.org> References: <20210215152719.459796636@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross [ Upstream commit ec7d8e7dd3a59528e305a18e93f1cb98f7faf83b ] Since commit 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding") xenvif_rx_ring_slots_available() is no longer called only from the rx queue kernel thread, so it needs to access the rx queue with the associated queue held. Reported-by: Igor Druzhinin Fixes: 23025393dbeb3b8b3 ("xen/netback: use lateeoi irq binding") Signed-off-by: Juergen Gross Acked-by: Wei Liu Link: https://lore.kernel.org/r/20210202070938.7863-1-jgross@suse.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/xen-netback/rx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c index b8febe1d1bfd3..accc991d153f7 100644 --- a/drivers/net/xen-netback/rx.c +++ b/drivers/net/xen-netback/rx.c @@ -38,10 +38,15 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue) RING_IDX prod, cons; struct sk_buff *skb; int needed; + unsigned long flags; + + spin_lock_irqsave(&queue->rx_queue.lock, flags); skb = skb_peek(&queue->rx_queue); - if (!skb) + if (!skb) { + spin_unlock_irqrestore(&queue->rx_queue.lock, flags); return false; + } needed = DIV_ROUND_UP(skb->len, XEN_PAGE_SIZE); if (skb_is_gso(skb)) @@ -49,6 +54,8 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue) if (skb->sw_hash) needed++; + spin_unlock_irqrestore(&queue->rx_queue.lock, flags); + do { prod = queue->rx.sring->req_prod; cons = queue->rx.req_cons; -- 2.27.0