Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp445804iog; Mon, 13 Jun 2022 06:08:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwB/HFkptPM657xOcwdlcCZKUj0+8IGWEo6SnRV0KTEtb4TWVw/1KRwRXv6H/gELZKlJmMF X-Received: by 2002:a05:6402:3484:b0:42e:1f3b:4a4c with SMTP id v4-20020a056402348400b0042e1f3b4a4cmr60253088edc.326.1655125590696; Mon, 13 Jun 2022 06:06:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125590; cv=none; d=google.com; s=arc-20160816; b=IjVOoaA2uJBmOGYs9fAyXtFpoT+wxPrmwltScXoCFDa/IttAkA4ODxYd7Y00yGf8Sl +eGF4PDBrYu46BvD1BqePyaR5JeQQgWqFjD0IrauEnjFejf9cVaO/9P8Kt8Sv7opIQmh HTp+YqXiYGMWrYajLXsxBDplOJ6/eb8ssbwR8NSDMIMAeXLOKJkaHINrLHfrDbrGzENJ 6v+rjOwbVTkuGG6e2F2IGarbnG5nxsegATnp9F73wMwNYuz1AB+GIvLJv+gf/jkqY5k8 Yr6slikev3wO/tMGD53C4X1tFexCWRTJO87bK8y69JYHGb7tJ/0An6GNuzFPnTERbdwL NAYg== 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=8E8dhcEpOMFvoMtMkwMMvk6OhWDcyCegs+8GEKLbUKc=; b=cy2x7goFZh/oU1sEiXA+tTdKrHseD2Il4jV9cHhpYUMTPp4j9+jrX415UKl+sv87af OQZbUpCh97dvrr/FU6UOZ32HA6Ex/tIKlHxwcvh5JWQuI6xuTp0sCCpPMuM9zgeKZ8TW bJlmTtZdOnjkRdByiEdFYjhEVisJqNuGI19yB6OEHKqarJqrybil4T6fmxwv+7RvLHVw oCn5euUyuBaK9EH+HUOWn17fYp1Jg6+d/pT5VNE+QpclGIRgZC2Xt8PmXz1IB/HRpF3O Ts1dvuFo0sKb5+SBKgyGvZ1dhGAQ0LzGAgTFCyFK9WvH+BAadqkopvqWj4b0SH+riqVe qKRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0isQX4r+; 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 dt8-20020a170906b78800b006fed9376071si6126925ejb.13.2022.06.13.06.05.51; Mon, 13 Jun 2022 06:06:30 -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=0isQX4r+; 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 S243957AbiFMKZr (ORCPT + 99 others); Mon, 13 Jun 2022 06:25:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244900AbiFMKYO (ORCPT ); Mon, 13 Jun 2022 06:24:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEC00CE1A; Mon, 13 Jun 2022 03:18:29 -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 4BBAC60AE8; Mon, 13 Jun 2022 10:18:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CFF3C34114; Mon, 13 Jun 2022 10:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115508; bh=UyTGTZOw/Ev9o5JpBoq+FIzadi3yCuLzcQ0l8Ah+elw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0isQX4r+tZC/VYf74EQrBNT6ngrhJ0o2IA3boPY3GFNT+waVjId/DTsxen3sNgLWs pGvPixGHyinEgMAy0LnAs3gFzCEYUyJ9k+W2yPMLmPANFUqfaMH1bvD/6KaNfTkfao N5lb3ID8rRf6Mojc0NvVaB77OnzMt4x+Ml8L+1oI= 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 4.9 101/167] carl9170: tx: fix an incorrect use of list iterator Date: Mon, 13 Jun 2022 12:09:35 +0200 Message-Id: <20220613094904.473609077@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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 @@ -1554,6 +1554,9 @@ static struct carl9170_vif_info *carl917 goto out; } } while (ar->beacon_enabled && i--); + + /* no entry found in list */ + return NULL; } out: