Patch "ALSA: seq: oss: Avoid mutex lock for a long-time ioctl" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ALSA: seq: oss: Avoid mutex lock for a long-time ioctl

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     alsa-seq-oss-avoid-mutex-lock-for-a-long-time-ioctl.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit e90d6ff171ae80d173b8e58fe18e22eb222ef50f
Author: Takashi Iwai <tiwai@xxxxxxx>
Date:   Tue Sep 22 10:38:56 2020 +0200

    ALSA: seq: oss: Avoid mutex lock for a long-time ioctl
    
    [ Upstream commit 2759caad2600d503c3b0ed800e7e03d2cd7a4c05 ]
    
    Recently we applied a fix to cover the whole OSS sequencer ioctls with
    the mutex for dealing with the possible races.  This works fine in
    general, but in theory, this may lead to unexpectedly long stall if an
    ioctl like SNDCTL_SEQ_SYNC is issued and an event with the far future
    timestamp was queued.
    
    For fixing such a potential stall, this patch changes the mutex lock
    applied conditionally excluding such an ioctl command.  Also, change
    the mutex_lock() with the interruptible version for user to allow
    escaping from the big-hammer mutex.
    
    Fixes: 80982c7e834e ("ALSA: seq: oss: Serialize ioctls")
    Suggested-by: Pavel Machek <pavel@xxxxxx>
    Link: https://lore.kernel.org/r/20200922083856.28572-1-tiwai@xxxxxxx
    Signed-off-by: Takashi Iwai <tiwai@xxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/sound/core/seq/oss/seq_oss.c b/sound/core/seq/oss/seq_oss.c
index ed5bca0db3e73..f4a9d9972330b 100644
--- a/sound/core/seq/oss/seq_oss.c
+++ b/sound/core/seq/oss/seq_oss.c
@@ -187,9 +187,12 @@ odev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 	if (snd_BUG_ON(!dp))
 		return -ENXIO;
 
-	mutex_lock(&register_mutex);
+	if (cmd != SNDCTL_SEQ_SYNC &&
+	    mutex_lock_interruptible(&register_mutex))
+		return -ERESTARTSYS;
 	rc = snd_seq_oss_ioctl(dp, cmd, arg);
-	mutex_unlock(&register_mutex);
+	if (cmd != SNDCTL_SEQ_SYNC)
+		mutex_unlock(&register_mutex);
 	return rc;
 }
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux