All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages
@ 2018-02-19 16:16 Takashi Iwai
  2018-02-19 16:44 ` Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 4.4-stable tree gregkh
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Takashi Iwai @ 2018-02-19 16:16 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Andres Bertens, ben, stable

This is the revised backport of the upstream commit
b3defb791b26ea0683a93a4f49c77ec45ec96f10

We had another backport (e.g. 623e5c8ae32b in 4.4.115), but it applies
the new mutex also to the code paths that are invoked via faked
kernel-to-kernel ioctls.  As reported recently, this leads to a
deadlock at suspend (or other scenarios triggering the kernel
sequencer client).

This patch addresses the issue by taking the mutex only in the code
paths invoked by user-space, just like the original fix patch does.

Reported-and-tested-by: Andres Bertens <abertensu@yahoo.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---

Tagged as 4.4.x, but should be applied to other older kernels, too.

 sound/core/seq/seq_clientmgr.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmgr.c
index 7bb9fe7a2c8e..dacc62fe5a58 100644
--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -2196,7 +2196,6 @@ static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd,
 			    void __user *arg)
 {
 	struct seq_ioctl_table *p;
-	int ret;
 
 	switch (cmd) {
 	case SNDRV_SEQ_IOCTL_PVERSION:
@@ -2210,12 +2209,8 @@ static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd,
 	if (! arg)
 		return -EFAULT;
 	for (p = ioctl_tables; p->cmd; p++) {
-		if (p->cmd == cmd) {
-			mutex_lock(&client->ioctl_mutex);
-			ret = p->func(client, arg);
-			mutex_unlock(&client->ioctl_mutex);
-			return ret;
-		}
+		if (p->cmd == cmd)
+			return p->func(client, arg);
 	}
 	pr_debug("ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n",
 		   cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));
@@ -2226,11 +2221,15 @@ static int snd_seq_do_ioctl(struct snd_seq_client *client, unsigned int cmd,
 static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct snd_seq_client *client = file->private_data;
+	long ret;
 
 	if (snd_BUG_ON(!client))
 		return -ENXIO;
 		
-	return snd_seq_do_ioctl(client, cmd, (void __user *) arg);
+	mutex_lock(&client->ioctl_mutex);
+	ret = snd_seq_do_ioctl(client, cmd, (void __user *) arg);
+	mutex_unlock(&client->ioctl_mutex);
+	return ret;
 }
 
 #ifdef CONFIG_COMPAT
-- 
2.16.1

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 4.4-stable tree
  2018-02-19 16:16 [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Takashi Iwai
@ 2018-02-19 16:44 ` gregkh
  2018-02-19 16:44 ` [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Greg Kroah-Hartman
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: gregkh @ 2018-02-19 16:44 UTC (permalink / raw)
  To: tiwai, abertensu, gregkh; +Cc: stable, stable-commits


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

    ALSA: seq: Fix regression by incorrect ioctl_mutex usages

to the 4.4-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-fix-regression-by-incorrect-ioctl_mutex-usages.patch
and it can be found in the queue-4.4 subdirectory.

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


>From tiwai@suse.de  Mon Feb 19 17:39:59 2018
From: Takashi Iwai <tiwai@suse.de>
Date: Mon, 19 Feb 2018 17:16:01 +0100
Subject: ALSA: seq: Fix regression by incorrect ioctl_mutex usages
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andres Bertens <abertensu@yahoo.com>, ben@decadent.org.uk, stable@vger.kernel.org
Message-ID: <20180219161601.24110-1-tiwai@suse.de>

From: Takashi Iwai <tiwai@suse.de>

This is the revised backport of the upstream commit
b3defb791b26ea0683a93a4f49c77ec45ec96f10

We had another backport (e.g. 623e5c8ae32b in 4.4.115), but it applies
the new mutex also to the code paths that are invoked via faked
kernel-to-kernel ioctls.  As reported recently, this leads to a
deadlock at suspend (or other scenarios triggering the kernel
sequencer client).

This patch addresses the issue by taking the mutex only in the code
paths invoked by user-space, just like the original fix patch does.

Reported-and-tested-by: Andres Bertens <abertensu@yahoo.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---

Tagged as 4.4.x, but should be applied to other older kernels, too.

 sound/core/seq/seq_clientmgr.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -2196,7 +2196,6 @@ static int snd_seq_do_ioctl(struct snd_s
 			    void __user *arg)
 {
 	struct seq_ioctl_table *p;
-	int ret;
 
 	switch (cmd) {
 	case SNDRV_SEQ_IOCTL_PVERSION:
@@ -2210,12 +2209,8 @@ static int snd_seq_do_ioctl(struct snd_s
 	if (! arg)
 		return -EFAULT;
 	for (p = ioctl_tables; p->cmd; p++) {
-		if (p->cmd == cmd) {
-			mutex_lock(&client->ioctl_mutex);
-			ret = p->func(client, arg);
-			mutex_unlock(&client->ioctl_mutex);
-			return ret;
-		}
+		if (p->cmd == cmd)
+			return p->func(client, arg);
 	}
 	pr_debug("ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n",
 		   cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));
@@ -2226,11 +2221,15 @@ static int snd_seq_do_ioctl(struct snd_s
 static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct snd_seq_client *client = file->private_data;
+	long ret;
 
 	if (snd_BUG_ON(!client))
 		return -ENXIO;
 		
-	return snd_seq_do_ioctl(client, cmd, (void __user *) arg);
+	mutex_lock(&client->ioctl_mutex);
+	ret = snd_seq_do_ioctl(client, cmd, (void __user *) arg);
+	mutex_unlock(&client->ioctl_mutex);
+	return ret;
 }
 
 #ifdef CONFIG_COMPAT


Patches currently in stable-queue which might be from tiwai@suse.de are

queue-4.4/alsa-seq-fix-regression-by-incorrect-ioctl_mutex-usages.patch

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages
  2018-02-19 16:16 [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Takashi Iwai
  2018-02-19 16:44 ` Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 4.4-stable tree gregkh
@ 2018-02-19 16:44 ` Greg Kroah-Hartman
  2018-02-19 16:47 ` Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 3.18-stable tree gregkh
  2018-02-20 17:59 ` [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Ben Hutchings
  3 siblings, 0 replies; 5+ messages in thread
From: Greg Kroah-Hartman @ 2018-02-19 16:44 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Andres Bertens, ben, stable

On Mon, Feb 19, 2018 at 05:16:01PM +0100, Takashi Iwai wrote:
> This is the revised backport of the upstream commit
> b3defb791b26ea0683a93a4f49c77ec45ec96f10
> 
> We had another backport (e.g. 623e5c8ae32b in 4.4.115), but it applies
> the new mutex also to the code paths that are invoked via faked
> kernel-to-kernel ioctls.  As reported recently, this leads to a
> deadlock at suspend (or other scenarios triggering the kernel
> sequencer client).
> 
> This patch addresses the issue by taking the mutex only in the code
> paths invoked by user-space, just like the original fix patch does.
> 
> Reported-and-tested-by: Andres Bertens <abertensu@yahoo.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> 
> Tagged as 4.4.x, but should be applied to other older kernels, too.
> 
>  sound/core/seq/seq_clientmgr.c | 15 +++++++--------
>  1 file changed, 7 insertions(+), 8 deletions(-)

Thanks for this, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 3.18-stable tree
  2018-02-19 16:16 [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Takashi Iwai
  2018-02-19 16:44 ` Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 4.4-stable tree gregkh
  2018-02-19 16:44 ` [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Greg Kroah-Hartman
@ 2018-02-19 16:47 ` gregkh
  2018-02-20 17:59 ` [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Ben Hutchings
  3 siblings, 0 replies; 5+ messages in thread
From: gregkh @ 2018-02-19 16:47 UTC (permalink / raw)
  To: tiwai, abertensu, gregkh; +Cc: stable, stable-commits


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

    ALSA: seq: Fix regression by incorrect ioctl_mutex usages

to the 3.18-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-fix-regression-by-incorrect-ioctl_mutex-usages.patch
and it can be found in the queue-3.18 subdirectory.

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


>From tiwai@suse.de  Mon Feb 19 17:39:59 2018
From: Takashi Iwai <tiwai@suse.de>
Date: Mon, 19 Feb 2018 17:16:01 +0100
Subject: ALSA: seq: Fix regression by incorrect ioctl_mutex usages
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Andres Bertens <abertensu@yahoo.com>, ben@decadent.org.uk, stable@vger.kernel.org
Message-ID: <20180219161601.24110-1-tiwai@suse.de>

From: Takashi Iwai <tiwai@suse.de>

This is the revised backport of the upstream commit
b3defb791b26ea0683a93a4f49c77ec45ec96f10

We had another backport (e.g. 623e5c8ae32b in 4.4.115), but it applies
the new mutex also to the code paths that are invoked via faked
kernel-to-kernel ioctls.  As reported recently, this leads to a
deadlock at suspend (or other scenarios triggering the kernel
sequencer client).

This patch addresses the issue by taking the mutex only in the code
paths invoked by user-space, just like the original fix patch does.

Reported-and-tested-by: Andres Bertens <abertensu@yahoo.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---

Tagged as 4.4.x, but should be applied to other older kernels, too.

 sound/core/seq/seq_clientmgr.c |   15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

--- a/sound/core/seq/seq_clientmgr.c
+++ b/sound/core/seq/seq_clientmgr.c
@@ -2201,7 +2201,6 @@ static int snd_seq_do_ioctl(struct snd_s
 			    void __user *arg)
 {
 	struct seq_ioctl_table *p;
-	int ret;
 
 	switch (cmd) {
 	case SNDRV_SEQ_IOCTL_PVERSION:
@@ -2215,12 +2214,8 @@ static int snd_seq_do_ioctl(struct snd_s
 	if (! arg)
 		return -EFAULT;
 	for (p = ioctl_tables; p->cmd; p++) {
-		if (p->cmd == cmd) {
-			mutex_lock(&client->ioctl_mutex);
-			ret = p->func(client, arg);
-			mutex_unlock(&client->ioctl_mutex);
-			return ret;
-		}
+		if (p->cmd == cmd)
+			return p->func(client, arg);
 	}
 	pr_debug("ALSA: seq unknown ioctl() 0x%x (type='%c', number=0x%02x)\n",
 		   cmd, _IOC_TYPE(cmd), _IOC_NR(cmd));
@@ -2231,11 +2226,15 @@ static int snd_seq_do_ioctl(struct snd_s
 static long snd_seq_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 {
 	struct snd_seq_client *client = file->private_data;
+	long ret;
 
 	if (snd_BUG_ON(!client))
 		return -ENXIO;
 		
-	return snd_seq_do_ioctl(client, cmd, (void __user *) arg);
+	mutex_lock(&client->ioctl_mutex);
+	ret = snd_seq_do_ioctl(client, cmd, (void __user *) arg);
+	mutex_unlock(&client->ioctl_mutex);
+	return ret;
 }
 
 #ifdef CONFIG_COMPAT


Patches currently in stable-queue which might be from tiwai@suse.de are

queue-3.18/alsa-seq-fix-regression-by-incorrect-ioctl_mutex-usages.patch

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages
  2018-02-19 16:16 [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Takashi Iwai
                   ` (2 preceding siblings ...)
  2018-02-19 16:47 ` Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 3.18-stable tree gregkh
@ 2018-02-20 17:59 ` Ben Hutchings
  3 siblings, 0 replies; 5+ messages in thread
From: Ben Hutchings @ 2018-02-20 17:59 UTC (permalink / raw)
  To: Takashi Iwai, Greg Kroah-Hartman; +Cc: Andres Bertens, stable

[-- Attachment #1: Type: text/plain, Size: 954 bytes --]

On Mon, 2018-02-19 at 17:16 +0100, Takashi Iwai wrote:
> This is the revised backport of the upstream commit
> b3defb791b26ea0683a93a4f49c77ec45ec96f10
> 
> We had another backport (e.g. 623e5c8ae32b in 4.4.115), but it applies
> the new mutex also to the code paths that are invoked via faked
> kernel-to-kernel ioctls.  As reported recently, this leads to a
> deadlock at suspend (or other scenarios triggering the kernel
> sequencer client).
> 
> This patch addresses the issue by taking the mutex only in the code
> paths invoked by user-space, just like the original fix patch does.
> 
> Reported-and-tested-by: Andres Bertens <abertensu@yahoo.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> 
> Tagged as 4.4.x, but should be applied to other older kernels, too.
[...]

Thanks, I've queued this up for 3.2 and 3.16.

Ben.

-- 
Ben Hutchings
If you seem to know what you are doing, you'll be given more to do.


[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-02-20 17:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-19 16:16 [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Takashi Iwai
2018-02-19 16:44 ` Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 4.4-stable tree gregkh
2018-02-19 16:44 ` [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Greg Kroah-Hartman
2018-02-19 16:47 ` Patch "ALSA: seq: Fix regression by incorrect ioctl_mutex usages" has been added to the 3.18-stable tree gregkh
2018-02-20 17:59 ` [PATCH v4.4.x] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Ben Hutchings

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.