From: "Gong, Sishuai" <sishuai@purdue.edu>
To: "perex@perex.cz" <perex@perex.cz>, "tiwai@suse.com" <tiwai@suse.com>
Cc: "alsa-devel@alsa-project.org" <alsa-devel@alsa-project.org>
Subject: [Problem] A data race in snd_ctl_elem_add()
Date: Thu, 15 Apr 2021 01:47:14 +0000 [thread overview]
Message-ID: <FEEBF384-44BE-42CF-8FB3-93470933F64F@purdue.edu> (raw)
Hi,
We found a data race in sound/core/control.c in linux-5.12-rc3 and we are able to reproduce it under x86.
In general, we found when 2 kernel threads are both running snd_ctl_elem_add(),
one may read a stale value of card->user_ctl_count, as shown below.
Currently, we haven’t found any explicit errors due to this data race, but it looks the reader threads
may operate in an inconsistent state, where card->user_ctl_count + 1 is actually bigger
than MAX_USER_CONTROLS, so we want to point it out.
Thread 1 Thread 2
//snd_ctl_elem_add() //snd_ctl_elem_add()
if (card->user_ctl_count + 1 > MAX_USER_CONTROLS)
return -ENOMEM;
card->user_ctl_count++;
unlock:
up_write(&card->controls_rwsem);
return err;
Thanks,
Sishuai
next reply other threads:[~2021-04-15 7:58 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-15 1:47 Gong, Sishuai [this message]
2021-04-15 8:55 ` [Problem] A data race in snd_ctl_elem_add() Takashi Iwai
2021-04-15 14:28 ` Gong, Sishuai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=FEEBF384-44BE-42CF-8FB3-93470933F64F@purdue.edu \
--to=sishuai@purdue.edu \
--cc=alsa-devel@alsa-project.org \
--cc=perex@perex.cz \
--cc=tiwai@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.