Skip to content

Commit

Permalink
ASoC: soc-dapm: fix two incorrect uses of list iterator
Browse files Browse the repository at this point in the history
commit f730a46 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: 163cac0 ("ASoC: Factor out DAPM sequence execution")
Signed-off-by: Xiaomeng Tong <xiam0nd.tong@gmail.com>
Link: https://lore.kernel.org/r/20220329012134.9375-1-xiam0nd.tong@gmail.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Xiaomeng Tong authored and gregkh committed Apr 27, 2022
1 parent 54e6180 commit 43a2a37
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions sound/soc/soc-dapm.c
Expand Up @@ -1683,8 +1683,7 @@ static void dapm_seq_run(struct snd_soc_card *card,
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,
Expand All @@ -1696,8 +1695,7 @@ static void dapm_seq_run(struct snd_soc_card *card,

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,
Expand Down

0 comments on commit 43a2a37

Please sign in to comment.