Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp3898589ioa; Tue, 26 Apr 2022 11:57:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCRF+vRMPbldWvLo5kWGq0YbSQwxqPAJMQ5O3wLGYiaQ7klGD8PYreYUPGyqAX3S+fkHNW X-Received: by 2002:a17:907:c11:b0:6f0:1b1a:65bd with SMTP id ga17-20020a1709070c1100b006f01b1a65bdmr22408187ejc.268.1650999427193; Tue, 26 Apr 2022 11:57:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650999427; cv=none; d=google.com; s=arc-20160816; b=crswms98U59LIoOVsD+M3gK2Id7Bzu/vybejgGbGuCb00XMC7zsULiWfJ6s6iowOzk bg5qsZbXKQl8Bt29LGPnME9gVWu926GfmyRkyChEqH5jNA7f9VYhbCuCv0oKEoNd/aLa I8rrEjweCZ+Fq9SBV5SRXQtEe9A3JzhvA8utiGaAss4H8U44l09hiIkew3YubokwxatW byMc/EcIuzHabk8VP0ZGqmY0gqfOoBEHFEk1RVtbHMgsNfKLRODfTpvPrFzfKjpD/fjB xx94HSRuTUFc3rpK73zp2aB+Tu9h0UOW2/7oicOZGPQM6bX+mu8AVn1dVu1GANETCcqM RkrA== 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=+hhTuBCyfD0QLimgEfggNel/uNTBhZJGOWn+oqR3Dws=; b=MRiR9yzyZs4c6LSfjIAzgIAySXRaWtzCQYPGvZSX70KGiDQYTAT9g+Jt4oWlbtP6fZ /GgrUG/fFHCBLzpXDqJSeo+uNDbNVsvRKJtgut3w7gFgitMzJLvCpdYwMbWOmz0QLFRA PkQVbpJm7rWEInFbu6obq63OEbX9swIJsMayszkurh5lg4R7l/b2EwQQN/lRQJIJEZqj 6AVQZkDE08kGNG5hqaZzzR2BtL+JlBJkiPHgYtR+OApN0xTpLZi+CHFGOOiIh8oPAHNk mnLojZcE3kpt7jT+xw69cABpIz4rdGLRMPdI6HKwAaLW16D5R9WjVueHHLnOJZK10Va4 Ls1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kN5AeDPQ; 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 s6-20020a1709062ec600b006df76385e22si16567707eji.706.2022.04.26.11.56.43; Tue, 26 Apr 2022 11:57:07 -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=kN5AeDPQ; 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 S1347959AbiDZJPC (ORCPT + 99 others); Tue, 26 Apr 2022 05:15:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55562 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345813AbiDZIw3 (ORCPT ); Tue, 26 Apr 2022 04:52:29 -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 599B4D64DD; Tue, 26 Apr 2022 01:41:01 -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 8907CCE1BBB; Tue, 26 Apr 2022 08:40:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 745ECC385A0; Tue, 26 Apr 2022 08:40:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962456; bh=BYqfI8ZIYsspdxUeiglQ4TrkrQOzO7vjnIDW9rFWqmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kN5AeDPQCeOVxdHVFnnpmHMleyEyUQxeXcXhkDUXs+LKAmNLBxDK7iY2HMj3S2Awu ei85DmzghTMvmz9QAF0VQrR7SGfr6dlev1gDtgJzMVbrFSk9Jx1m7Yo8fPOuNiSPZi xXRKbLhzRNMbnwMNch+IHPfRAB76TqI8iDtlByq8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Mark Brown Subject: [PATCH 5.15 103/124] ASoC: soc-dapm: fix two incorrect uses of list iterator Date: Tue, 26 Apr 2022 10:21:44 +0200 Message-Id: <20220426081750.225761259@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081747.286685339@linuxfoundation.org> References: <20220426081747.286685339@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=-7.7 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 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 f730a46b931d894816af34a0ff8e4ad51565b39f upstream. These two bug are here: list_for_each_entry_safe_continue(w, n, list, power_list); list_for_each_entry_safe_continue(w, n, list, power_list); After the list_for_each_entry_safe_continue() exits, the list iterator will always be a bogus pointer which point to an invalid struct objdect containing HEAD member. The funciton poniter 'w->event' will be a invalid value which can lead to a control-flow hijack if the 'w' can be controlled. The original intention was to continue the outer list_for_each_entry_safe() loop with the same entry if w->event is NULL, but misunderstanding the meaning of list_for_each_entry_safe_continue(). So just add a 'continue;' to fix the bug. Cc: stable@vger.kernel.org Fixes: 163cac061c973 ("ASoC: Factor out DAPM sequence execution") Signed-off-by: Xiaomeng Tong Link: https://lore.kernel.org/r/20220329012134.9375-1-xiam0nd.tong@gmail.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- sound/soc/soc-dapm.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -1685,8 +1685,7 @@ static void dapm_seq_run(struct snd_soc_ switch (w->id) { case snd_soc_dapm_pre: if (!w->event) - list_for_each_entry_safe_continue(w, n, list, - power_list); + continue; if (event == SND_SOC_DAPM_STREAM_START) ret = w->event(w, @@ -1698,8 +1697,7 @@ static void dapm_seq_run(struct snd_soc_ case snd_soc_dapm_post: if (!w->event) - list_for_each_entry_safe_continue(w, n, list, - power_list); + continue; if (event == SND_SOC_DAPM_STREAM_START) ret = w->event(w,