Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4451792imw; Tue, 19 Jul 2022 06:55:30 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uZ7WewaUKbi+HWOvneaEenxvbacWsN30FryqALTRx1YzY1ZVsIrIc2LRntUzoSwa9MGOkT X-Received: by 2002:a05:6402:5189:b0:43a:c55c:cf00 with SMTP id q9-20020a056402518900b0043ac55ccf00mr43740031edd.390.1658238930777; Tue, 19 Jul 2022 06:55:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238930; cv=none; d=google.com; s=arc-20160816; b=G/Q0bx7cQi+FMC/GY7H0Kbb7kxSjNIrh6RG3EQIRH4mOc+TYEraa9BEYN6LTO8vmc+ 1Ep9/xrypWDZn52ViYFS8/4rlK521a9QcJsOvdVnZR0RzQ3KW/wDRfXkoJ1l8QO05b0r SPYgSzweCaMMM6OmkLv9TP1IXtXQM9+DR1ph12AlwUtT7ifq9ERSUqywS/NbTPL68yGu gP80/0mRbbpzN52Z8dScTZfUbJTAs3rt1OW0xB0y6Dmzc3qFFhQoYwAD6TaCYw4M5YZh tn7/ks8M0kh/WB6gxrAkfs5ZGTsKXg6LUYsXxx/X7Bha+t7iTeM4rs4y18IvDceDfMgo kTrg== 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=dbMFBKvjK06HqzRGRKkBHwHtUb9SGTJpOi5HFihW93g=; b=adJ6GcAovLGfT4jlo08PpPZ1WJ5s6M4+8VxvzVpSmDIrI8zw8Gn4XTZNj+Z4bGgkSG HsLkG0aMHXspO+JM3q2hvyZ4eHMJjpcSkCsyRe0gSs6rJgOVcKr4Aq3C/k27l6jnVCLr aB9EcHS0ztDaA3JWjwMiT1kQZxzgcJTBsQ+Wef/IvVwUigbk8p2ScmvAQGwRegjXmuyh Es8bfBiJ6G7TXlNKI83ZicsBgOQKxFgCWGs8qqk4ztksreK9cjla0SNFDb4EpQvFTto7 LY8mnip6i52i1N5H5MfgL1XamcqwSTyV9QPhmo1Z//iFEH56X1oDuCOUNAB7qCSHJPY2 ZLUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fTKqVGny; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a170906150800b0072b2141a200si17222022ejd.401.2022.07.19.06.55.05; Tue, 19 Jul 2022 06:55:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=fTKqVGny; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S234750AbiGSMag (ORCPT + 99 others); Tue, 19 Jul 2022 08:30:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240494AbiGSM3f (ORCPT ); Tue, 19 Jul 2022 08:29:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9EC3691CB; Tue, 19 Jul 2022 05:11:16 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 44AC6B81B82; Tue, 19 Jul 2022 12:11:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 964F7C341CF; Tue, 19 Jul 2022 12:11:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232674; bh=Xm0MwoDW/hV6tsQcoq3CJwBjGnfYANhsNhn7svWmwSM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fTKqVGnyofBZNQ5wHyQIeMDaJELnjyetFKgGTPwV23U2ReUAfr4kbrbxlc8rSClgp kBoOUc8byOJei/BOuAldeZYGVLH6+mOxRi5H9KY4Q/jcVF+9MpJZz6a5bERJybO+EQ IUZzPadJzizd8dqg+8su+0FbqiRvMbjpTAyBLSgE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Juergen Gross , Jan Beulich , Paul Durrant , Jakub Kicinski Subject: [PATCH 5.15 008/167] xen/netback: avoid entering xenvif_rx_next_skb() with an empty rx queue Date: Tue, 19 Jul 2022 13:52:20 +0200 Message-Id: <20220719114657.512129756@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Juergen Gross commit 94e8100678889ab428e68acadf042de723f094b9 upstream. 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 0000000000000080 [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, BIOS 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: 00000000000000f7 [40072.538430] RDX: 0000000000000000 RSI: 0000000000000006 RDI: ffffc90043d43df8 [40072.538531] RBP: 000000000000003f R08: 000077ff80000000 R09: 0000000000000008 [40072.538644] R10: 0000000000007ff0 R11: 00000000000008f6 R12: ffffc90043ce2708 [40072.538745] R13: 0000000000000000 R14: ffffc90043d43ed0 R15: ffff88043ea748c0 [40072.538861] FS: 0000000000000000(0000) GS:ffff880484600000(0000) knlGS:0000000000000000 [40072.538988] CS: e033 DS: 0000 ES: 0000 CR0: 0000000080050033 [40072.539088] CR2: 0000000000000080 CR3: 0000000407ac8000 CR4: 0000000000040660 [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. Cc: stable@vger.kernel.org Fixes: 98f6d57ced73 ("xen-netback: process guest rx packets in batches") Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich Reviewed-by: Paul Durrant Link: https://lore.kernel.org/r/20220713135322.19616-1-jgross@suse.com Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/xen-netback/rx.c | 1 + 1 file changed, 1 insertion(+) --- a/drivers/net/xen-netback/rx.c +++ b/drivers/net/xen-netback/rx.c @@ -495,6 +495,7 @@ void xenvif_rx_action(struct xenvif_queu queue->rx_copy.completed = &completed_skbs; while (xenvif_rx_ring_slots_available(queue) && + !skb_queue_empty(&queue->rx_queue) && work_done < RX_BATCH_SIZE) { xenvif_rx_skb(queue); work_done++;