Received: by 10.223.185.116 with SMTP id b49csp6420284wrg; Wed, 28 Feb 2018 09:06:38 -0800 (PST) X-Google-Smtp-Source: AH8x2257pGvdtKiA+ii53kZsggUyKDg1xnWZVWUC6Nbv7oNnxDXAeXGeHoi7DfyArwCWDYGrtZOg X-Received: by 10.101.93.17 with SMTP id e17mr14770001pgr.281.1519837598462; Wed, 28 Feb 2018 09:06:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519837598; cv=none; d=google.com; s=arc-20160816; b=gwFdLZzUdz1DA8TkYbH3uJT2QnB0HAGtP2pjwyd4gtd9GPNr+vheCFszcKWbhhr0pj Ra1jTK88ZzTJOq16WbQZqGNfFs2Hh6ds/dusOqw1Xdsjkgbz4MCIdmgV73wqujyuiVrf 9n0qpoIcGDBn/tGLbouDn+TQNmCUz4aDsyc1buwfD68CIuIiIk35KK5Kji/6c0l3PqJI auDJXB61Fm67HrFjnIoTGdQTpIA2gor9gs3uPXWQN0TNDjQCct04kPDOdx5wqygp7YMl kW27YJZxr5hRYEdekY27i2ZFvy2XU3dyasJprppJ3jNrnzUgGCO/MTHL08yYrmX79RDK 2X+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=4JGIp8YMxMalE4PbpdQTmcPjG0k/XEPm8k+CnoO7mcM=; b=NHhSzNawEqPwqnW4VsLSru7vndsP9QooUXFQ4eRP+LGURAfDtXPS4wgzu1b8Ipsj6s 0EV4zq3vBGA3Su33ppBeC9TaqcoQXO7yYPAI8EfTQIzBK24M2qsJpDv2slWWm5/ZQKJz En813ogb+L+MZZ+z/YV+Z5sDGVe9Iqy3+ntPQBsF3eCN+S+Bbpl7BR+GkUameA/EfCbJ ykPjPDZy5wbXdFiuqpKYLo3Rslxa4vzHIHhnd5J1wGN8SDPEhnQlqpFZAOypMZFC+2Y5 ULos02NXGD3ljsqMVf/A4qROilMKfsrxff7TEhkO7aOZE7tmj7IItnlC9Cex+jtjl7L5 GOhQ== 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 t11-v6si1542315plz.214.2018.02.28.09.06.22; Wed, 28 Feb 2018 09:06:38 -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 S933638AbeB1Pva (ORCPT + 99 others); Wed, 28 Feb 2018 10:51:30 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:34333 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933272AbeB1Pv1 (ORCPT ); Wed, 28 Feb 2018 10:51:27 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1er3Yr-0006kw-Ao; Wed, 28 Feb 2018 15:22:29 +0000 Received: from ben by deadeye with local (Exim 4.90_1) (envelope-from ) id 1er3Yi-0000Am-5e; Wed, 28 Feb 2018 15:22:20 +0000 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, syzbot+6f11c7e2a1b91d466432@syzkaller.appspotmail.com, "Takashi Iwai" Date: Wed, 28 Feb 2018 15:20:18 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 155/254] ALSA: pcm: Remove incorrect snd_BUG_ON() usages In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.55-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai commit fe08f34d066f4404934a509b6806db1a4f700c86 upstream. syzkaller triggered kernel warnings through PCM OSS emulation at closing a stream: WARNING: CPU: 0 PID: 3502 at sound/core/pcm_lib.c:1635 snd_pcm_hw_param_first+0x289/0x690 sound/core/pcm_lib.c:1635 Call Trace: .... snd_pcm_hw_param_near.constprop.27+0x78d/0x9a0 sound/core/oss/pcm_oss.c:457 snd_pcm_oss_change_params+0x17d3/0x3720 sound/core/oss/pcm_oss.c:969 snd_pcm_oss_make_ready+0xaa/0x130 sound/core/oss/pcm_oss.c:1128 snd_pcm_oss_sync+0x257/0x830 sound/core/oss/pcm_oss.c:1638 snd_pcm_oss_release+0x20b/0x280 sound/core/oss/pcm_oss.c:2431 __fput+0x327/0x7e0 fs/file_table.c:210 .... This happens while it tries to open and set up the aloop device concurrently. The warning above (invoked from snd_BUG_ON() macro) is to detect the unexpected logical error where snd_pcm_hw_refine() call shouldn't fail. The theory is true for the case where the hw_params config rules are static. But for an aloop device, the hw_params rule condition does vary dynamically depending on the connected target; when another device is opened and changes the parameters, the device connected in another side is also affected, and it caused the error from snd_pcm_hw_refine(). That is, the simplest "solution" for this is to remove the incorrect assumption of static rules, and treat such an error as a normal error path. As there are a couple of other places using snd_BUG_ON() incorrectly, this patch removes these spurious snd_BUG_ON() calls. Reported-by: syzbot+6f11c7e2a1b91d466432@syzkaller.appspotmail.com Signed-off-by: Takashi Iwai Signed-off-by: Ben Hutchings --- sound/core/oss/pcm_oss.c | 1 - sound/core/pcm_lib.c | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -465,7 +465,6 @@ static int snd_pcm_hw_param_near(struct v = snd_pcm_hw_param_last(pcm, params, var, dir); else v = snd_pcm_hw_param_first(pcm, params, var, dir); - snd_BUG_ON(v < 0); return v; } --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -1631,7 +1631,7 @@ int snd_pcm_hw_param_first(struct snd_pc return changed; if (params->rmask) { int err = snd_pcm_hw_refine(pcm, params); - if (snd_BUG_ON(err < 0)) + if (err < 0) return err; } return snd_pcm_hw_param_value(params, var, dir); @@ -1678,7 +1678,7 @@ int snd_pcm_hw_param_last(struct snd_pcm return changed; if (params->rmask) { int err = snd_pcm_hw_refine(pcm, params); - if (snd_BUG_ON(err < 0)) + if (err < 0) return err; } return snd_pcm_hw_param_value(params, var, dir);