]> git.baikalelectronics.ru Git - kernel.git/commit
ALSA: control: fix a redundant-copy issue
authorWenwen Wang <wang6495@umn.edu>
Sat, 5 May 2018 18:38:03 +0000 (13:38 -0500)
committerTakashi Iwai <tiwai@suse.de>
Sun, 13 May 2018 07:27:57 +0000 (09:27 +0200)
commit9d5d43847e5e3eb85549a528f6685f0ffb5cc5b4
tree4418713da8b30d43c62f3470e2b262c27d7e7dad
parent7d10b8c1e3c729ef37a1489c66d868f28b76be91
ALSA: control: fix a redundant-copy issue

In snd_ctl_elem_add_compat(), the fields of the struct 'data' need to be
copied from the corresponding fields of the struct 'data32' in userspace.
This is achieved by invoking copy_from_user() and get_user() functions. The
problem here is that the 'type' field is copied twice. One is by
copy_from_user() and one is by get_user(). Given that the 'type' field is
not used between the two copies, the second copy is *completely* redundant
and should be removed for better performance and cleanup. Also, these two
copies can cause inconsistent data: as the struct 'data32' resides in
userspace and a malicious userspace process can race to change the 'type'
field between the two copies to cause inconsistent data. Depending on how
the data is used in the future, such an inconsistency may cause potential
security risks.

For above reasons, we should take out the second copy.

Signed-off-by: Wenwen Wang <wang6495@umn.edu>
Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/control_compat.c