Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4399193ioa; Wed, 27 Apr 2022 03:02:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy4oea3ENNGDGFEw4x6nFZFhGlNgsfhTzX3NF6Vw6HwbQ+l37SL2l1b52epuCqbflBmDggD X-Received: by 2002:a17:90b:4cd2:b0:1d9:7a88:402f with SMTP id nd18-20020a17090b4cd200b001d97a88402fmr16242723pjb.151.1651053753053; Wed, 27 Apr 2022 03:02:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651053753; cv=none; d=google.com; s=arc-20160816; b=oa5wDGR4GRMgAuuMTNMNiaftc0U00bwHrPT78sKsBCALUGSIvgX1p6w2ja9h05P46h CdppALSr3VyK596r6g8PYntqLclyzRGaQ5wj0JwKCJlPiVBPtn0IxGLmzJp02ucIIUW7 TCTZY8VyuHDTApwjuTV8ICyDHzVYXKKAzkLU7xOULM+BkImzK5/75iwuMWpa0W0/hZZu /pJEFEH0t486xLgSSqPVdYY10ozgNzwbVOKGZhjsJZvdqmo0dQEnQDLVADKDrGYKbDtH Z9NxfALnhrfDe+5m0Fx5+gPVtdh3vfpmU/+4xIss4P8b5bpOH2jW7WJT0DdWhoINa9RC JRCw== 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=zIP7QTfOF912F9vdHqIJlsz7odkpnr6u7It9nbcSrWc=; b=FoVgElmvGclZCBHlXPX7XRk1WmYvtSGmdBKXqIfYyJL9Ddn2RPUf3V/D7EJI9izygO i5AO1vHSstmAJ7kdi10PiuN0acryTqTLxBqjHzIjm3zmvge+CO66zfbSq+xpxZ6cXkmT EjrrTos1sg11QS+oQ+2CphdeiHQnmGQK6Z15nDAZnMFmLyLoVWWj+hPivGmX5G5M0ipT vD8ELQQnW6twNXQWLw1IeCMqT49Bfk7PhUVL9KRu9XcXaQOt13XzsjsrNJvVKMMgoa+R N0n6BichaVvQhU3hHYCa0AqkLGxgKdKORjKLg1Cd0A9gnQH8vT2nRk59jCkYUe+KCFMp OnSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="bV/9MPN5"; 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 m11-20020a634c4b000000b003c149025e65si1061284pgl.197.2022.04.27.03.02.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:02:33 -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="bV/9MPN5"; 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 7BCDB2DB5C2; Wed, 27 Apr 2022 02:29:00 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345299AbiDZIkR (ORCPT + 99 others); Tue, 26 Apr 2022 04:40:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60308 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345019AbiDZIfO (ORCPT ); Tue, 26 Apr 2022 04:35:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8857E3A5FE; Tue, 26 Apr 2022 01:28:31 -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 22892617EB; Tue, 26 Apr 2022 08:28:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 246EFC385A0; Tue, 26 Apr 2022 08:28:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1650961710; bh=rvD413YDWinJu95LA5qjGrVuTs33M0xttuur9tqA9ks=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bV/9MPN5aM7RNab9ZB6J14i7ZzL/vhQN8P+5U5PVyNeeFmPXZAznoyWiG0XETbi49 MaySrbwEWqiUtzK8QYWoj6aBkXbXpLT2dbme/RSd92vwKtUnILrdq9DQMPjyoVneRX CmQNXQzjA79GcHEarG77rrcUru+ZynPZooAD8RCA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xiaomeng Tong , Mark Brown Subject: [PATCH 4.19 35/53] ASoC: soc-dapm: fix two incorrect uses of list iterator Date: Tue, 26 Apr 2022 10:21:15 +0200 Message-Id: <20220426081736.677475672@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220426081735.651926456@linuxfoundation.org> References: <20220426081735.651926456@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 @@ -1635,8 +1635,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, @@ -1648,8 +1647,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,