From nobody Sat May 18 18:58:05 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=1657698541; cv=none; d=zohomail.com; s=zohoarc; b=gltPfSjXVoLqk/M3MbQVXvcTsXoMLesAVEedPASdO0292koHIxW3h0HIO7yGewE0bt0LalgVxHj7/2VArFH1+AtWUvObUXlf8AsyR/3SXHpP5dD99tGVzHnMkkfLY1gwOJuEdXGQBfgGySS9agdcBeopnYfn0hjRIwfg7MNub3g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1657698541; 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=0CGUbRqbAXCelWKPuWFUYe6GAN1O07JgHKbKoC7xYHQ=; b=aWR1QanUJHdTCJWONjszpjHcF85w9oaGV2VxNmnHSPC7tHha6cW59oObl4eCYClvQaYlNapKc/zkE0iUtgtDQF5oRauG29T+SwMoxVxrDFmZTzpyYIXsaV7i/kTgG4tQE7La0YXr4XfIljUNLxe86Aiq7dEhSRb4OD8kQywAPqc= 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) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16576985414154.0959456579047355; Wed, 13 Jul 2022 00:49:01 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.366253.596957 (Exim 4.92) (envelope-from ) id 1oBX6l-0006vN-2A; Wed, 13 Jul 2022 07:48:31 +0000 Received: by outflank-mailman (output) from mailman id 366253.596957; Wed, 13 Jul 2022 07:48:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBX6k-0006vG-Vl; Wed, 13 Jul 2022 07:48:30 +0000 Received: by outflank-mailman (input) for mailman id 366253; Wed, 13 Jul 2022 07:48:29 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oBX6j-0006vA-11 for xen-devel@lists.xenproject.org; Wed, 13 Jul 2022 07:48:29 +0000 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2e5a5069-0280-11ed-bd2d-47488cf2e6aa; Wed, 13 Jul 2022 09:48:27 +0200 (CEST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4A5DB1FF64; Wed, 13 Jul 2022 07:48:27 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id EC05313AAD; Wed, 13 Jul 2022 07:48:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id ueYpOMp4zmKUJQAAMHmgww (envelope-from ); Wed, 13 Jul 2022 07:48:26 +0000 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: 2e5a5069-0280-11ed-bd2d-47488cf2e6aa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1657698507; 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=0CGUbRqbAXCelWKPuWFUYe6GAN1O07JgHKbKoC7xYHQ=; b=Y3ZpLT2lCpW1dP6yPmM2DmZPeTqeyduPSIW9j7irvcpEF7hscExLoibMTUTOBjlVYa6RAN MAaMEJuj4PpJQ4LNdRt3ptF4g7VnicAhhhBm76Zc3eTHt/e4GiPFYnOVq6BvrNbHoVFjJD 0e6RHrT4QQt2etZ/ByOKjGOcAQDVyeM= 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" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH] xen/netback: handle empty rx queue in xenvif_rx_next_skb() Date: Wed, 13 Jul 2022 09:48:23 +0200 Message-Id: <20220713074823.5679-1-jgross@suse.com> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) X-ZM-MESSAGEID: 1657698542267100001 Content-Type: text/plain; charset="utf-8" xenvif_rx_next_skb() is expecting the rx queue not being empty, but in case the loop in xenvif_rx_action() is doing multiple iterations, the availability of another skb in the rx queue is not being checked. This can lead to crashes: [40072.537261] BUG: unable to handle kernel NULL pointer dereference at 000= 0000000000080 [40072.537407] IP: xenvif_rx_skb+0x23/0x590 [xen_netback] [40072.537534] PGD 0 P4D 0 [40072.537644] Oops: 0000 [#1] SMP NOPTI [40072.537749] CPU: 0 PID: 12505 Comm: v1-c40247-q2-gu Not tainted 4.12.14-= 122.121-default #1 SLE12-SP5 [40072.537867] Hardware name: HP ProLiant DL580 Gen9/ProLiant DL580 Gen9, B= IOS U17 11/23/2021 [40072.537999] task: ffff880433b38100 task.stack: ffffc90043d40000 [40072.538112] RIP: e030:xenvif_rx_skb+0x23/0x590 [xen_netback] [40072.538217] RSP: e02b:ffffc90043d43de0 EFLAGS: 00010246 [40072.538319] RAX: 0000000000000000 RBX: ffffc90043cd7cd0 RCX: 00000000000= 000f7 [40072.538430] RDX: 0000000000000000 RSI: 0000000000000006 RDI: ffffc90043d= 43df8 [40072.538531] RBP: 000000000000003f R08: 000077ff80000000 R09: 00000000000= 00008 [40072.538644] R10: 0000000000007ff0 R11: 00000000000008f6 R12: ffffc90043c= e2708 [40072.538745] R13: 0000000000000000 R14: ffffc90043d43ed0 R15: ffff88043ea= 748c0 [40072.538861] FS: 0000000000000000(0000) GS:ffff880484600000(0000) knlGS:0= 000000000000000 [40072.538988] CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033 [40072.539088] CR2: 0000000000000080 CR3: 0000000407ac8000 CR4: 00000000000= 40660 [40072.539211] Call Trace: [40072.539319] xenvif_rx_action+0x71/0x90 [xen_netback] [40072.539429] xenvif_kthread_guest_rx+0x14a/0x29c [xen_netback] Fix that by stopping the loop in case the rx queue becomes empty. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant --- drivers/net/xen-netback/rx.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c index dbac4c03d21a..a0335407be42 100644 --- a/drivers/net/xen-netback/rx.c +++ b/drivers/net/xen-netback/rx.c @@ -495,6 +495,7 @@ void xenvif_rx_action(struct xenvif_queue *queue) queue->rx_copy.completed =3D &completed_skbs; =20 while (xenvif_rx_ring_slots_available(queue) && + !skb_queue_empty(&queue->rx_queue) && work_done < RX_BATCH_SIZE) { xenvif_rx_skb(queue); work_done++; --=20 2.35.3