Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp605025pxb; Tue, 5 Apr 2022 15:42:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwjP01HCWH//VCy9Ysr6rNld0Z9kEGOAnu4G41dvQEm4B/IWtStfVaUIyBtGypNKVZF6OLS X-Received: by 2002:a05:6a00:16cd:b0:4e1:366:7ee8 with SMTP id l13-20020a056a0016cd00b004e103667ee8mr5717826pfc.9.1649198535802; Tue, 05 Apr 2022 15:42:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649198535; cv=none; d=google.com; s=arc-20160816; b=sS3EF6X0OWtZC5RSqDBVzRaTg3FvqtWeq/14hPbBbU4UHMtHFn/GGOLIp65g1qTZC6 If6jclFFrkaWV4iihzauSqK47tpjKbhLuFJLlrVzNWrjzmYEW+tGiKGCXFOsstpBgQ8O v/UH8HWzIMaT/HLgBK+VlKdLXMx72LRbA8bKq8ZAdG4cVfxnpx14Q8sXO6a+vyDXvV81 9/dAv29askqyjOHdTeErzdXJ5dJLJp+UgJ7qxS9uPkTF7743z5oZepFqecvmvyMsdupH bFi/OiN96j5RKLt1IYm3PUQC3MwjIriyvl9br8r0fp9NIG2azSoFV0DnXv7KIgo4ZkVn KXCA== 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=arHpzwT3mRCel7s0IZc1gWOrBzflz1fbyQ1SlQ/YjD4=; b=NVwuHwNTb5nJ0Dmf/mmrjHZfcofaKv5xvC7bgPfXdyRbEeDU6z+gR5pvEONXBDdyoT KCUmFW2Ob8n9euCPLzqsHr0Z4hdEaovd7/4a8hq9paMKuyMXYs6xBhzsilWnpyp00InC 5HGZZa/q/eRN60hemmCkUNywRXLMhIqgU0/xgxIuwunuxwRP8ZDsIZOnhIxUbyJz1aqa yyGVZUTzzCqKv9dkCGJ2JMRRcwoKAFuwY7mGc3XbIhVxq8p9A8TlQK0hcHVn8irZGF0N 0i1jLMyN6Q9G0HW2pm9yqwh+tZkM7jSrR8YZxonLE0x4uWpUDjK6LdaYwctbc6ySSqAd 8arQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JfKnyrsy; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q2-20020a635042000000b0039919e96afdsi7829796pgl.455.2022.04.05.15.42.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 15:42:15 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JfKnyrsy; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C36043983A; Tue, 5 Apr 2022 15:23:05 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1377300AbiDEOEb (ORCPT + 99 others); Tue, 5 Apr 2022 10:04:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235949AbiDEJbC (ORCPT ); Tue, 5 Apr 2022 05:31:02 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FB1FDC9; Tue, 5 Apr 2022 02:18:08 -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 C0EB1615E4; Tue, 5 Apr 2022 09:18:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF3CAC385A2; Tue, 5 Apr 2022 09:18:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150287; bh=Po5jLrWVJ+xIKtQ51vyR2df5Kkp8zgB79iNNPxTe+7A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JfKnyrsyTlWhe8Cq0tvKwsD9/LhgZ8AJgyUJZppVxFAlRirlAASE8ofBISA0VSnaV 8mzfbgliRvIS9EkbgyphjhkwxJue2/PUzrQIKeuZmWd+Hc+NJ4YHo5HN2D2PwBuORZ hiVjK8P2w76IIlcC41PLNN/XiPczm1D2kgWk+7mw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Maciej Fijalkowski , Alexei Starovoitov Subject: [PATCH 5.16 1005/1017] ice: xsk: Fix indexing in ice_tx_xsk_pool() Date: Tue, 5 Apr 2022 09:31:58 +0200 Message-Id: <20220405070424.033475739@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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: Maciej Fijalkowski commit 1ac2524de7b366633fc336db6c94062768d0ab03 upstream. Ice driver tries to always create XDP rings array to be num_possible_cpus() sized, regardless of user's queue count setting that can be changed via ethtool -L for example. Currently, ice_tx_xsk_pool() calculates the qid by decrementing the ring->q_index by the count of XDP queues, but ring->q_index is set to 'i + vsi->alloc_txq'. When user did ethtool -L $IFACE combined 1, alloc_txq is 1, but vsi->num_xdp_txq is still num_possible_cpus(). Then, ice_tx_xsk_pool() will do OOB access and in the final result ring would not get xsk_pool pointer assigned. Then, each ice_xsk_wakeup() call will fail with error and it will not be possible to get into NAPI and do the processing from driver side. Fix this by decrementing vsi->alloc_txq instead of vsi->num_xdp_txq from ring-q_index in ice_tx_xsk_pool() so the calculation is reflected to the setting of ring->q_index. Fixes: 22bf877e528f ("ice: introduce XDP_TX fallback path") Signed-off-by: Maciej Fijalkowski Signed-off-by: Alexei Starovoitov Link: https://lore.kernel.org/bpf/20220328142123.170157-5-maciej.fijalkowski@intel.com Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/intel/ice/ice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/net/ethernet/intel/ice/ice.h +++ b/drivers/net/ethernet/intel/ice/ice.h @@ -709,7 +709,7 @@ static inline struct xsk_buff_pool *ice_ struct ice_vsi *vsi = ring->vsi; u16 qid; - qid = ring->q_index - vsi->num_xdp_txq; + qid = ring->q_index - vsi->alloc_txq; if (!ice_is_xdp_ena_vsi(vsi) || !test_bit(qid, vsi->af_xdp_zc_qps)) return NULL;