Received: by 10.223.185.116 with SMTP id b49csp684442wrg; Wed, 21 Feb 2018 05:21:48 -0800 (PST) X-Google-Smtp-Source: AH8x225M3fVld1CBQFfZSaX9wdGaopDB0R+lknUfdWsNuUrBFbsKSmh4iABaaT6jjwFhpFCXvmKq X-Received: by 2002:a17:902:8a98:: with SMTP id p24-v6mr3128099plo.147.1519219308667; Wed, 21 Feb 2018 05:21:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519219308; cv=none; d=google.com; s=arc-20160816; b=fDoUuss4Ghr591vvUwnU4W5uxDySWkod0NuIt84ZiN3PeoyU/q9yeK1TvTGBwGu8nt +8wqBDHKE7zIgcZ8dKsnzBpCRUbCD5ko5ZL0tUhWTy3SXrqrjoRtcz2j1TwxOp8aNkpr LLH5sQX2VDtTUBkOWk7i88iEbM4mw6+s5rFvGKmB+0hNfPX7c0s/L5DIjl5cLBEk9rdW TUDe0/UAkL6CGrpS+s+FDba6T3cFvi4n1ACisMQATskCw8JcnrMQnti8GEXFYqQw4teJ Z2pqQUYOy1z6uCTsLqmoPnoRNlGWztsIFsblHG12aoPzUHHnoFJoMl4Gm8vSgjxe5vlY LWNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nzNqnKhQ9IrLzCaNwzq8AKBY5uAhgI6tv5Z7tc4VhkM=; b=sRNs0IlpC9YB68jUNLzfa3T/5ax9PVmnHa/JJsAczAF01BwR4IPl00quDkqU4fDHaQ GCJZyaxTB4+/oE7WaP9GJbFIcQbuigtci65gRW82zmAwwgeXkqToVRks/+YJqZsSySyV n4QI+qkj9YqiN0KtxfRvJkpIiL8u7dj9woZMsNTOGSljul2ZN4ODVVJ5FNR0Mi8s9fDl buIGz9fnGWQt5wAC+9TPmPcm3wXq1NJfaC19rak4OL/hjpM4HOs7K4FVXHz1+c6CbCxO 3E8q8gSrv0pKFOTte7wqkzUrMGNDzZXY8BPIvIw97UB60Vzwt2yqq1duRXIvlIWU/Qdm SM1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k3si918092pff.157.2018.02.21.05.21.34; Wed, 21 Feb 2018 05:21:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933885AbeBUMqS (ORCPT + 99 others); Wed, 21 Feb 2018 07:46:18 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:59356 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754362AbeBUMqO (ORCPT ); Wed, 21 Feb 2018 07:46:14 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 0AE2D123A; Wed, 21 Feb 2018 12:46:13 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Takashi Iwai Subject: [PATCH 4.4 08/33] ALSA: seq: Fix regression by incorrect ioctl_mutex usages Date: Wed, 21 Feb 2018 13:44:51 +0100 Message-Id: <20180221124410.117039630@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180221124409.564661689@linuxfoundation.org> References: <20180221124409.564661689@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai 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 Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- 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