Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2194071iof; Tue, 7 Jun 2022 22:48:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMJ4VAXbALhMQ9f2spnvYidvpZPmE+72kxYNPq76rZWZ+a08irUitQyulqrnOvPhOH+swC X-Received: by 2002:a17:90a:6fc2:b0:1e3:2c21:c29f with SMTP id e60-20020a17090a6fc200b001e32c21c29fmr48686265pjk.191.1654667312154; Tue, 07 Jun 2022 22:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654667312; cv=none; d=google.com; s=arc-20160816; b=L6y+IUenMf506SktfVK9IaJ/OjxptAozqRlhx4aoQPhIf7t7fAC0COn2KkHgb69bzp WvgG90e8QmKQG730l7GhN7xuw/412apxU5G2R9EK5Pis1fKN5Z0EzoaPXbmRA79aQBTj bIO3xJ3grrVacNgH+lxOJXhV6Asps22jY1Lt81doLA9pHL+CP17FET+BWK/JXfm8PBo6 26Scc7fmiR+AD1IObFMWpgk/ERbYtdL9dfdGv6IVsXZpAYsgF1hT8KRDmWQ/4KYhp4VI fyyTE5UKqivnvmf46aF5vZmKQoQQpRKRYeI9cx6rU450jsn7WGfSBRFQN2zYtmr7EaXJ GwEA== 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=lPhLxZZGs3XrcyHYKcRNSEPjnzj3P6jTx39dE65TgkN4ewy6di7DDPyyiimBkOmjUJ 1szItKocXVYo2ltK5TcvMLY8dpYUq5lyvpxRytdwhfJx9J7G1DtnbTSiWytKjevMFmZi +UpDaBdmmDxcsDTQrXQ1Y/Qs0HsGClm4uGcL5aSj3kJjpoYmMjT51Ak/uuwu+8I43KgL VXyWs3q3Xr0314DCsUiICD3s7/86yQvFcjkA2H7nJxpaVGSJ4pCGmUBT/cJJzf2sV1Z/ YNSm8pJyf5edTwwfZrurq2sRlrDQvgW/k1GdrAxqovsN937FjbD4jvzUovuyv13y2sOv mHrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dsFEVWyS; 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 w138-20020a627b90000000b0051873a68dd2si25856934pfc.252.2022.06.07.22.48.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:48:32 -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=dsFEVWyS; 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 25F114A1D42; Tue, 7 Jun 2022 22:13:51 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1388426AbiFHAcI (ORCPT + 99 others); Tue, 7 Jun 2022 20:32:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1383212AbiFGWat (ORCPT ); Tue, 7 Jun 2022 18:30:49 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0341C276229; Tue, 7 Jun 2022 12:24:09 -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 9CD29B823CE; Tue, 7 Jun 2022 19:24:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17D4AC385A5; Tue, 7 Jun 2022 19:24:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629846; bh=0S9p/Qfh+P5mPbXnyjJNMevBaHDXD81NAZ26hH/OqEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dsFEVWyS1JBNBnvmTY9t8yIOdgNefBJKK8VSC1R+jDQB3tyNGp+VSZzCTkH782bvF uLN3Rq8P0qulLbIANfmChS7MqWN+Ji7djVjmMtHumQ9ePnvUCvJarNZ5PXgUgkXzRG zerLH6TUdp4JGeUuEe9nDvddV1h3IVrFcHlXurRU= 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.18 837/879] carl9170: tx: fix an incorrect use of list iterator Date: Tue, 7 Jun 2022 19:05:55 +0200 Message-Id: <20220607165027.150029301@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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: