Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2146747iof; Tue, 7 Jun 2022 21:18:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJqNK/BH7RXjyBaX0LIM4NREB1KhZvnWLnCYGbKGKHnaWytDCE1s9ma0lM+xzXoqK+/pkC X-Received: by 2002:aa7:9103:0:b0:519:3150:6b3f with SMTP id 3-20020aa79103000000b0051931506b3fmr32728401pfh.67.1654661918313; Tue, 07 Jun 2022 21:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661918; cv=none; d=google.com; s=arc-20160816; b=dKbeH91ESD5yN16+ZIBKXaZAg1H3rRsSkvXL2Drv1nfAP6qUQF0sQ7CZpspw3Vvxjk OlbueX0s8q2d0cCawhDeJvMIw5d53JP69pFdZPaXCwEohmBjLnTnn6gMcWK0JKTM1hxQ EVRe3g8kHXukz/hxGiDk3dCUj6UNXmpyzZT8jiVz4O5UOCoFSpDUE+7SPE392nlsWS9r ZmTyOmlqdezI83a45EHqqti+kXiUMyoVk2tI3CX5YxpIsxwmsb/N6dtinsxxu8mPYP1S ByH+E9wveiO9RVENm1OFWZ51fMu332/sU7oWZRpp1h/aqZLvJ8ok04u38zY69zqCD0tF dGqA== 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=yTFlGE/sSkxCQbZK/hgai546ooW/FKvAK/GzojJc23Y=; b=Am9UxwfeFUNIpGL1LHLaWLVEuvNMbjrhWssOcNRwXfCxMaNH+lMMWRzXdgMobEamIZ l8M+lujv8HZtzgcHptwq81dOMVgaaqlBDik+qlWBnZ7TcoPB1nEaNI9FwxztD2K2c2I/ yVl+cRmaiRYn2sXBNsNsa4C/nDBb8y8e67e+xTgfIm98N3lI5YP89A2r8fyhjz/tTXm+ Nlchwe0h50Q2z/5hFzINnAUTWcAU/cWLrd3doDJc5J8NjrjW2Z6IJTT/nCP7MdDPYyFb oIMUlffw5s3NXN5zMVBgnzpS4bvcS3yGBIIshVHr1W1H62XVc6lO+MTImUKJNmcM4eHx m2Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zMFGNeqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id l63-20020a638842000000b003fdda84798bsi8205723pgd.117.2022.06.07.21.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:18:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zMFGNeqL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 3503435AAEE; Tue, 7 Jun 2022 20:49:37 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349723AbiFGSHq (ORCPT + 99 others); Tue, 7 Jun 2022 14:07:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40874 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349143AbiFGRqr (ORCPT ); Tue, 7 Jun 2022 13:46:47 -0400 Received: from sin.source.kernel.org (sin.source.kernel.org [IPv6:2604:1380:40e1:4800::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 697EA114684; Tue, 7 Jun 2022 10:36:53 -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 sin.source.kernel.org (Postfix) with ESMTPS id 42171CE23E3; Tue, 7 Jun 2022 17:36:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59475C34115; Tue, 7 Jun 2022 17:36:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623409; bh=4v+cu7e+Xt75WklgaATgEEarc6UDXVoriEbxTMfiz7c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zMFGNeqLA6tpS6M4g9x+QOJBiwWE2Lb6D0LKLbc+f/iIG5yfVr1Cp9kM5h938h45E FI4Js1BqefiPN1VsEksUJdDyRtv9X+90ehEkeH2ihQblKPYZrLSF8HYcvuRiDkectU u8DZwRcSJz5VXudqJYyLUdtLvzj+6IE3iHDZ1TVo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, pa@panix.com, Alexander Wetzel , Kalle Valo Subject: [PATCH 5.10 406/452] rtl818x: Prevent using not initialized queues Date: Tue, 7 Jun 2022 19:04:23 +0200 Message-Id: <20220607164920.657605345@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@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=-3.1 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=unavailable 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: Alexander Wetzel commit 746285cf81dc19502ab238249d75f5990bd2d231 upstream. Using not existing queues can panic the kernel with rtl8180/rtl8185 cards. Ignore the skb priority for those cards, they only have one tx queue. Pierre Asselin (pa@panix.com) reported the kernel crash in the Gentoo forum: https://forums.gentoo.org/viewtopic-t-1147832-postdays-0-postorder-asc-start-25.html He also confirmed that this patch fixes the issue. In summary this happened: After updating wpa_supplicant from 2.9 to 2.10 the kernel crashed with a "divide error: 0000" when connecting to an AP. Control port tx now tries to use IEEE80211_AC_VO for the priority, which wpa_supplicants starts to use in 2.10. Since only the rtl8187se part of the driver supports QoS, the priority of the skb is set to IEEE80211_AC_BE (2) by mac80211 for rtl8180/rtl8185 cards. rtl8180 is then unconditionally reading out the priority and finally crashes on drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c line 544 without this patch: idx = (ring->idx + skb_queue_len(&ring->queue)) % ring->entries "ring->entries" is zero for rtl8180/rtl8185 cards, tx_ring[2] never got initialized. Cc: stable@vger.kernel.org Reported-by: pa@panix.com Tested-by: pa@panix.com Signed-off-by: Alexander Wetzel Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220422145228.7567-1-alexander@wetzel-home.de Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c +++ b/drivers/net/wireless/realtek/rtl818x/rtl8180/dev.c @@ -460,8 +460,10 @@ static void rtl8180_tx(struct ieee80211_ struct rtl8180_priv *priv = dev->priv; struct rtl8180_tx_ring *ring; struct rtl8180_tx_desc *entry; + unsigned int prio = 0; unsigned long flags; - unsigned int idx, prio, hw_prio; + unsigned int idx, hw_prio; + dma_addr_t mapping; u32 tx_flags; u8 rc_flags; @@ -470,7 +472,9 @@ static void rtl8180_tx(struct ieee80211_ /* do arithmetic and then convert to le16 */ u16 frame_duration = 0; - prio = skb_get_queue_mapping(skb); + /* rtl8180/rtl8185 only has one useable tx queue */ + if (dev->queues > IEEE80211_AC_BK) + prio = skb_get_queue_mapping(skb); ring = &priv->tx_ring[prio]; mapping = dma_map_single(&priv->pdev->dev, skb->data, skb->len,