From nobody Sat May 4 11:14:42 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1612249798; cv=none; d=zohomail.com; s=zohoarc; b=FLm1hnNykrGpsJ++jggCuez0+wANYqMYnkHoxlmOWFBnpimN6axo5+Gqj2EkrYOMuUUv/6bQSw7U80IksFI+kvhJiRgAiJ7RgKQwkqwm39jN/Zv42kxbP5gs1nFRdHn2Mn7seP3buZv5744eIcS9fk71p43azUCFWcg1qoHdf4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612249798; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=1tpaqvOitmoTdUOKCltTkXQMrQMduhfR/V/K0TJ91jk=; b=Gn4iz/Dbs7EM4JWJKQ1J2LjDkxBYtJfDm7oBdmfvah2lMEU+BxNX7zdp4RcWMWWBh5CMyFJl6kVe9CO9A+jDhG3FIT6fePlbGwHrSXJ59Wmd7tJYD5WVJO4nzM6Tvbh2c9K01/AywOa8aBSl73v2EglrWSw1eZTOV4B1197zPzI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1612249798833341.64409197513567; Mon, 1 Feb 2021 23:09:58 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.80368.146990 (Exim 4.92) (envelope-from ) id 1l6pom-0008Ef-8t; Tue, 02 Feb 2021 07:09:44 +0000 Received: by outflank-mailman (output) from mailman id 80368.146990; Tue, 02 Feb 2021 07:09:44 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l6pom-0008EY-5G; Tue, 02 Feb 2021 07:09:44 +0000 Received: by outflank-mailman (input) for mailman id 80368; Tue, 02 Feb 2021 07:09:42 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1l6pok-0008EL-Ro for xen-devel@lists.xenproject.org; Tue, 02 Feb 2021 07:09:42 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4fcbd9d4-3e3a-4c79-9329-a3a3f6d62f12; Tue, 02 Feb 2021 07:09:42 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 46D2EACB7; Tue, 2 Feb 2021 07:09:41 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 4fcbd9d4-3e3a-4c79-9329-a3a3f6d62f12 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1612249781; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=1tpaqvOitmoTdUOKCltTkXQMrQMduhfR/V/K0TJ91jk=; b=pbaIptIDBcZvfobat6HNoXje6mR3kf8+MuWpibPjXaHBmoQvt3LBZ1S4k+WfN+6v3yXqqG CnLh7G8uXWy5d/2yQhTslehE4QmbeheYR1UmRM7pfxMgd1ZiuvafUH6s9i4k7bnpbVZHHm wGiaWxu3itzFTHNe0z01xg0UqKte3eQ= From: Juergen Gross To: xen-devel@lists.xenproject.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Wei Liu , Paul Durrant , "David S. Miller" , Jakub Kicinski , Igor Druzhinin , stable@vger.kernel.org Subject: [PATCH] xen/netback: avoid race in xenvif_rx_ring_slots_available() Date: Tue, 2 Feb 2021 08:09:38 +0100 Message-Id: <20210202070938.7863-1-jgross@suse.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" 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") Cc: stable@vger.kernel.org Signed-off-by: Juergen Gross Acked-by: Wei Liu --- 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 b8febe1d1bfd..accc991d153f 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 xenvi= f_queue *queue) RING_IDX prod, cons; struct sk_buff *skb; int needed; + unsigned long flags; + + spin_lock_irqsave(&queue->rx_queue.lock, flags); =20 skb =3D skb_peek(&queue->rx_queue); - if (!skb) + if (!skb) { + spin_unlock_irqrestore(&queue->rx_queue.lock, flags); return false; + } =20 needed =3D 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++; =20 + spin_unlock_irqrestore(&queue->rx_queue.lock, flags); + do { prod =3D queue->rx.sring->req_prod; cons =3D queue->rx.req_cons; --=20 2.26.2