ALSA: pcm: Return -EBUSY for OSS ioctls changing busy streams
commit3724f9c7dd1e7373d5db4098b1e17a48b2fe2421
authorTakashi Iwai <tiwai@suse.de>
Fri, 23 Mar 2018 07:03:26 +0000 (23 08:03 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 24 Apr 2018 07:34:15 +0000 (24 09:34 +0200)
tree38acf729277ab6b9d705c91be60c1e2969a781c8
parent159a13647f3fafa26809b939bd9a5f0a54c87118
ALSA: pcm: Return -EBUSY for OSS ioctls changing busy streams

commit 40cab6e88cb0b6c56d3f30b7491a20e803f948f6 upstream.

OSS PCM stream management isn't modal but it allows ioctls issued at
any time for changing the parameters.  In the previous hardening
patch ("ALSA: pcm: Avoid potential races between OSS ioctls and
read/write"), we covered these races and prevent the corruption by
protecting the concurrent accesses via params_lock mutex.  However,
this means that some ioctls that try to change the stream parameter
(e.g. channels or format) would be blocked until the read/write
finishes, and it may take really long.

Basically changing the parameter while reading/writing is an invalid
operation, hence it's even more user-friendly from the API POV if it
returns -EBUSY in such a situation.

This patch adds such checks in the relevant ioctls with the addition
of read/write access refcount.

Cc: <stable@vger.kernel.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
include/sound/pcm_oss.h
sound/core/oss/pcm_oss.c