Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4367365imw; Tue, 19 Jul 2022 05:27:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uIYQFDQuqSbmAMsTLjxuLftyibQooE75OGzmn6E+pN2onx5/HYEvAJ0837zYxBfPVoy+F4 X-Received: by 2002:a17:907:3daa:b0:72b:7656:d4d2 with SMTP id he42-20020a1709073daa00b0072b7656d4d2mr30441595ejc.166.1658233630144; Tue, 19 Jul 2022 05:27:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658233630; cv=none; d=google.com; s=arc-20160816; b=aIouHWLH5Gxl+qmXhYoH+8fpcpfDKZx8gU/N0C4JOuHDtkU+RrVeBIY+gLHF40DWoC Lv4fcAhZljEGizF2Is/mGJosrvTj0U76aCXrboNrZ7YBh9coaNBFFHe32HCdEhx+miN9 iQSGMCuZLEWaEs9kAUCE3W8/bbAhBvtY6zEpT903eUt8xWcJoYw2A4SIDO4fCo2gAs9R 4a3NQpGW522uj/g/LuMlwCD0+qqjP7sSeGIzBPGhX+fv37zMDojF2bjqwEr6DOA1cyZ7 XlBfNUS0q5X2gwB1pksS3B55VGYAztfsKXjfRacKEemkaEohdKq2Qj4t5SRJKDXdRfTO N7mg== 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=AU6Arlp5Lo/KebzpiCeGNLrEUYPUbhcEzmoPakvU2vo=; b=nPZcUExwbYGDCzmkS2tUhEkOYBH6VuytfSg4jxmEhEJclntuE6HBBE5qae/V0MJSFP HyerajED1Fg9IBxV+cLye3QXbaK7MhDF2BcE6qxHKEDsEcrWSx2NN5CYPVS1HJJT8+qn 1Q74zY99XCh3gAlo5TbhTNuVSjPKNTVcvF+fcUwNNrbgHJA+n9nS6R5h7kNHcySrCMUw VtuSNX21S6QLPs0YA2ZKA0UQUHWXLTV9WCoY8fT+4IOGUMj7SEKE2gOssGlaNDMGQz/F dNy1ACfL20OgHH5ubjPn4Nc9eP5Ls9LzdJMYJn0F5k32nsjcdE3dXy/wFquRRdGyDNgM FWyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PX8rixR0; 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 t12-20020aa7d4cc000000b0043ad1d1d68asi16680721edr.335.2022.07.19.05.26.45; Tue, 19 Jul 2022 05:27:10 -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=PX8rixR0; 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 S237560AbiGSL6h (ORCPT + 99 others); Tue, 19 Jul 2022 07:58:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237644AbiGSL57 (ORCPT ); Tue, 19 Jul 2022 07:57:59 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5AE0B45F6D; Tue, 19 Jul 2022 04:56:59 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 7042061697; Tue, 19 Jul 2022 11:56:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 502F7C341CB; Tue, 19 Jul 2022 11:56:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658231817; bh=5K400RCghF5zqReCilMHPXz2UVxcHIGAjqGAIynvirY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PX8rixR0nWCviAbIwt2U8Eudw5vb2jMp3FwpoAiK/IPysyEXEkndqZgorw4X0VdOG 0NM76puE22uQ3lBtG8g4BywIQctYlhkmBk866s2tto+N8MbqkKYnX62+DiXzNKa9JJ x7tkp3WNJBgXBZW8CFu8nxboOPNzNdLEpXUjHlMU= 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 4.9 03/28] xen/netback: avoid entering xenvif_rx_next_skb() with an empty rx queue Date: Tue, 19 Jul 2022 13:53:41 +0200 Message-Id: <20220719114456.893357746@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114455.701304968@linuxfoundation.org> References: <20220719114455.701304968@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 @@ -482,6 +482,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++;