Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2229650iof; Tue, 7 Jun 2022 23:54:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxRtfTe26x4zBdAbQ01LwoNXInlsEPbX4ltV6qEySEHQwQB8P4A2LXgsr/5+5/k35r7Yg8o X-Received: by 2002:a17:902:c951:b0:166:4f65:cff2 with SMTP id i17-20020a170902c95100b001664f65cff2mr27349969pla.7.1654671278098; Tue, 07 Jun 2022 23:54:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654671278; cv=none; d=google.com; s=arc-20160816; b=N7M/rkj87JDpxMs1NVUvRutM6RdO3Fy6rRFsytuy00t0XpbgSDhn92ZscxkAb0mslO UPn26cfTUGg32e1ev6ZlVMZ58+vgseFsBDDFTZ/8vDCs0X/aH7DNojMFnb+7KQ7J7fdX wIYpH8C9pgZraR3Z35CKa2oNjvmb+UAOrDBUjY8bA0BoLSQnGX23AmroILsO+ynP5RCd s996Wf03b59fnWw30ZpLI0r90sVckU61tLcojLFOxTmCkAn+Ltme5tcjNdY85AKa5PFX 1mSgLmk2jadSdo0JUZcUXPDlTRU21zoPQ1m7JGd0I+0Xh9txuNV3abheHjQnx/pjIgTS ZqNQ== 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=RWtuGzDqXGg8BPwvNxzIGjvp1mLK9OGd7q15pavMkA4=; b=KXs/SPuf8sJ5h3Icl3ykHUhJQDdv5OxW9XCdeJRDvYgg7bF7rsmy+9xoJ4JBXcTxFA MNKW6uDo739jqmbgmNYlR6BHIJck863y13Snnm2jV5zUQn5HiHbLVlVPT/8YHbq916qy tIgvoIUmKyWkPCJcTc9HDWRGSv1ubz5FjnN3hCgMv/BZnjifk4HePiSjCqV7nrK9dKMZ wjmCBWgfbMgr7CHJ89qHmBxRVENsxqfosTb4lsBWLYCzBt3eX9I8WwxfZWCbqRpF5UZq YgCXwNvtvvSgIVOVmWll9BQgrASwbJFa1+P5cZgw+QYEKO88i3lOn7fh5RJkj/givbyk Ch+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Qri32ebX; 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 f9-20020a635549000000b003fc06718029si26565766pgm.324.2022.06.07.23.54.25; Tue, 07 Jun 2022 23:54:38 -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=Qri32ebX; 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 S1349773AbiFGSIU (ORCPT + 99 others); Tue, 7 Jun 2022 14:08:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40372 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348413AbiFGRst (ORCPT ); Tue, 7 Jun 2022 13:48:49 -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 3FCB31157F7; Tue, 7 Jun 2022 10:37:05 -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 BD54BCE23E2; Tue, 7 Jun 2022 17:36:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B80AEC36B04; Tue, 7 Jun 2022 17:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623415; bh=fpAJU8/iPB4K4ACuHGmuYZDZKbmw+g26GaUydW1SeHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qri32ebX99dhSnKc46sdHmIy5vNjzL31loRk6nKYr1eUQaW9c/YbZypzP5SAoqINd r2d+wDjIlz9T1Zq7z7TNxwajlj6srN8LV9NeFnPeoUPO/gLtKgVdZuu3WVl++fRJTA UKbgEhSdol/6v7bb3RWBfBwOq/QkGE43Wb/b90og= 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.10 408/452] carl9170: tx: fix an incorrect use of list iterator Date: Tue, 7 Jun 2022 19:04:25 +0200 Message-Id: <20220607164920.717099002@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=-8.3 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,T_SCC_BODY_TEXT_LINE 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: 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 @@ -1557,6 +1557,9 @@ static struct carl9170_vif_info *carl917 goto out; } } while (ar->beacon_enabled && i--); + + /* no entry found in list */ + return NULL; } out: