Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2150229iof; Tue, 7 Jun 2022 21:25:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhs9lNGqs/zgrCBx1qEpVGskpHmKMKLMsHsC5gBTix1GetoXXB4dUM/mlQpDAb2pxTfRKW X-Received: by 2002:a17:90a:4414:b0:1df:9b8f:c3cc with SMTP id s20-20020a17090a441400b001df9b8fc3ccmr70251654pjg.56.1654662331019; Tue, 07 Jun 2022 21:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654662331; cv=none; d=google.com; s=arc-20160816; b=zxMJE5Y1nDsEDqVhMEo0IjvxzE2zpmmMpH6MxkIsZqOmKXOHhHhRaNqam6VLesNrVo uAp4kRX8vZNzUyrx0dWo4Za4hmSGduDiDF8ubYlrWQA+6evCEfAy3lSbdZaLpdaXsCZo FrXQTluJAIza1gIuEsPzn9+iZTvgU6JEBNnvm951dilVdMzo2jAEVZmidAxHX2n17Nwb OraZOB2ajvw70iZZxpCgDRFDc5Yfz7zqsvOoWmLiqU5aK7q/u9A84xaRqFTNrT0uqvXl Ucd6SNE11oFkEjtlREio+zjrYYrZ1O2Clzf8MM1b/jIkQmwj7YMve4+evDZGRPx8/DUO 8lMw== 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=lqSf6ee9xHruMdBzMXwQoURVsKzVgFFKjKdd9fGb09s=; b=RfR1FIHMZLVDvIfZcE+oGVvKgDiznvMKG/dGCD8HzwnLaM7DPSZAYwCyCqSBfsyDk9 661QzBChGfDHDiAxJVtDpi+wFVvOWy7KCg8B8f8+GcocTk+6HS3avYem42GvqMVRxLkR o1oxoKO85q2vW/9adHdeZFOnYnUjero3MObnhMZzl/h9eOa6Ia0f+k51ELsCRPKc31Aa J+GjICdL4ptqkzgWnBNGcsXIgRL+nFmyYWRIi0JzgLLoKFwNjmXsc5K4MbG+wggBlF/s WMd4R7RhaFTLmZJmAoseggCARTAIGo7JaHohRD6KHiv5NGJjiSSbtAGgUH1Hr5qKeSyg NrrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=IWtlj9i9; 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 b14-20020a056a000cce00b0050cf84f4e8fsi5727358pfv.29.2022.06.07.21.25.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:25:31 -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=IWtlj9i9; 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 457AF427C98; Tue, 7 Jun 2022 21:00:34 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1381233AbiFGVrP (ORCPT + 99 others); Tue, 7 Jun 2022 17:47:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358435AbiFGUxB (ORCPT ); Tue, 7 Jun 2022 16:53:01 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A18026CABE; Tue, 7 Jun 2022 11:43:42 -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 DF8C2B82182; Tue, 7 Jun 2022 18:43:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45C40C385A2; Tue, 7 Jun 2022 18:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654627419; bh=0S9p/Qfh+P5mPbXnyjJNMevBaHDXD81NAZ26hH/OqEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IWtlj9i9VpdXhh7af7tjwXJcvFFRFtBJpwBTQkTN9x3UX1cjmN5Pl/JJTBa3oNcft g9UABNmVO6yYfgeDgHb8nkiEXB8r1w9uiKSENDRLAMmi3zjVMBwbfAHO4v3gM1aXYH mvOvQFHWeG1DoqdyEZgU4i/+BGHxmVw68N/WcUng= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Christian Lamparter , Kalle Valo Subject: [PATCH 5.17 731/772] carl9170: tx: fix an incorrect use of list iterator Date: Tue, 7 Jun 2022 19:05:23 +0200 Message-Id: <20220607165010.579943691@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164948.980838585@linuxfoundation.org> References: <20220607164948.980838585@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: Xiaomeng Tong commit 54a6f29522da3c914da30e50721dedf51046449a upstream. If the previous list_for_each_entry_continue_rcu() don't exit early (no goto hit inside the loop), the iterator 'cvif' after the loop will be a bogus pointer to an invalid structure object containing the HEAD (&ar->vif_list). As a result, the use of 'cvif' after that will lead to a invalid memory access (i.e., 'cvif->id': the invalid pointer dereference when return back to/after the callsite in the carl9170_update_beacon()). The original intention should have been to return the valid 'cvif' when found in list, NULL otherwise. So just return NULL when no entry found, to fix this bug. Cc: stable@vger.kernel.org Fixes: 1f1d9654e183c ("carl9170: refactor carl9170_update_beacon") Signed-off-by: Xiaomeng Tong Acked-by: Christian Lamparter Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/20220328122820.1004-1-xiam0nd.tong@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/net/wireless/ath/carl9170/tx.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/net/wireless/ath/carl9170/tx.c +++ b/drivers/net/wireless/ath/carl9170/tx.c @@ -1558,6 +1558,9 @@ static struct carl9170_vif_info *carl917 goto out; } } while (ar->beacon_enabled && i--); + + /* no entry found in list */ + return NULL; } out: