Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4413298ioa; Wed, 27 Apr 2022 03:22:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmtXulpbZ9YEuT1zRCqwZqOL9PMKQ4kpsjjvNuUaSjJNnHfF8RbFo4ulAmh9ACt4ioiftS X-Received: by 2002:a17:902:7049:b0:156:285a:2d64 with SMTP id h9-20020a170902704900b00156285a2d64mr28340311plt.63.1651054970760; Wed, 27 Apr 2022 03:22:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651054970; cv=none; d=google.com; s=arc-20160816; b=qov0GXja4a0Lo+3jgQPnbJtMnDp1ThX8Os6FBDWfQyAFTHxNvs/A9Nh20DGRw090Ls kfvvsYuJavQvqcTlVlyEvQOdxS7xrO1LTvQM3/6gBHN5RLAUFJxAQIdX7CVsZzL3VQ9C YAcVsScLLDYeWXBpLwkRr7WQaUH6WNMOZzg2+PLH3QX4/qGRIhqFDXsEeDZglVIquim6 XrsNLjiPcdkHUCqf1RGjw2i1djna3z7Aca2B3chp9vbcZOjWtEKJw9301AeTSAaHOmB6 +C8J8K0vg18w+xJCS7vGrRArp7xdynNQoWrrYBuUioSo16LEH4QYTHFAiHjiPamEb5e/ IbFg== 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=5beXZL3FqGzFjdZZ1w5p/QDlohOEBfZdDVBb6A7nWI0=; b=B5pC84DTXhRvzVTub8Gkh60QWXiCj2ic3ZXITAvGZFdkyN9SWjr0+Vp6HQ+NcK1DL9 U+6xDM80CSjI7zgPjKRzOzsYBpPUpTBNsXlMhQYp1NFphkTjC+2XPwQlOuVEDX3AmYEy Z0B6lg9Gb+nJ6wH+zvYYo++8mgeUHKRQli+q5QmFlLkE1V5BrT0tS/VngbNBuZrTAnnG kNxofFthJSVSHMXQIMcNBlLnTKk7lH++9SyIxC0QoB5Q6cy5R54FPgzm6+oIpvjNc3Po ulNPzriQlLmAhqC/igGA5rPmiZI//pq45YkkYxTjlCeI3l3S+2kJTnxqGxJERooTgs1W FH6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lQyrba4K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id x26-20020a056a00189a00b004fa7288d199si1101889pfh.55.2022.04.27.03.22.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:22:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lQyrba4K; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 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 4F3623766B5; Wed, 27 Apr 2022 02:41:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348517AbiDZJkE (ORCPT + 99 others); Tue, 26 Apr 2022 05:40:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51566 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346103AbiDZJGp (ORCPT ); Tue, 26 Apr 2022 05:06:45 -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 A2A3C1725D7; Tue, 26 Apr 2022 01:48:10 -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 5E5C6B81A2F; Tue, 26 Apr 2022 08:48:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BF2D4C385A0; Tue, 26 Apr 2022 08:48:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650962888; bh=bIfzGYBIqeeKpYwQ1scAh406vQ8IUBMdWs3kvctj9c0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lQyrba4KH/nOmjrKXyJlImON4uE8lkdii7FjQ8XQFr9DWD7C3G3uwjXG0ZWKYak9S 9aaZazDtRewsKaJuvu7isUFHvO8PD8AsIwu0NKPY/zqOY0Bq/NUfFsAHK4ShjXfa6U efltEFrftHxv+mZd+1VmpgzVyWHiTHCA3KzmMdKQ= 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.17 122/146] ASoC: soc-dapm: fix two incorrect uses of list iterator Date: Tue, 26 Apr 2022 10:21:57 +0200 Message-Id: <20220426081753.486113876@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081750.051179617@linuxfoundation.org> References: <20220426081750.051179617@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=-2.5 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 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 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 @@ -1687,8 +1687,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, @@ -1700,8 +1699,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,