From patchwork Tue Sep 11 11:05:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 146432 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp3505573ljw; Tue, 11 Sep 2018 04:05:50 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda2VJrZjkurnSbFG+NR9dvOS6eHcBXCVje4lFBUibY/lOHXxgN+GbUd6AXyKbSCyjvlcOaV X-Received: by 2002:adf:bacf:: with SMTP id w15-v6mr19408157wrg.203.1536663949994; Tue, 11 Sep 2018 04:05:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536663949; cv=none; d=google.com; s=arc-20160816; b=uwHUI4Po+BfEMAyWX9L+3JlV+5GWc6SMVqVCKvAyv52h9jER7pEljpoNJpTETWIcCB YJlfuPVPPARcw0Rf7RDbSoZrQqdt2FuitUP1S3op0lGd8RaNMQCIGpakcNhtWOQ8nWwl fohbrPWUEs800EKNkgcAxVYjkoyyOJmYFNwVF8e1qiBa5D04hTb1B5CXbBC4AanRxFHE SwR8OE3hzGGaj5TGcP95KY0ja2qrOu9CPwmECjeiOSFWortnGwIp2qGnehSzZSUq4Wn/ JrfKzCQpGNa+XpJZQkmS6HB4l8o4JxVQ9xB8BOxZ/eWPyAmu+XOgJQHfPyK6LP/zTHbP 9cdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:date:message-id:in-reply-to:to:from :dkim-signature:delivered-to; bh=9QJxGrFugJ8t9dRRyeISYJ9WTPk39nR0Xkss63u0MrI=; b=htRRZ0KLsPbBk0ieTvg/hKTg7E3aWkBaX2YlwpBdzh06+4Z2Mzk5f17m0adbmXnOD7 o5ySZ8SGCtBK87Pv/Wuy9y6avpNg50ysgrmhAcMMwCZt9tQtnPCBt5WG6GxaIgPOykhd 8rq9o/BJwS3/bBXTMRj0taUd0ndH4XTbdqzDSKLY+pRXwqozPuDUVlL4o23rConL9bvx /s3ge0t1zxTkPRDBb9RJxwnUSd7me/6ZFBH0HPZujW3KpFnunspz5DGGn9C9mxPWZWyY rYdk4jNwwrgA6PBm2PPo/41f7jLS+a3Ki3+PUC1jRwqCXIaLVfebw2kF1VazHshfg4uQ x28g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=qXmdH0ye; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from alsa0.perex.cz (alsa0.perex.cz. [77.48.224.243]) by mx.google.com with ESMTP id v14-v6si17184176wrr.116.2018.09.11.04.05.49; Tue, 11 Sep 2018 04:05:49 -0700 (PDT) Received-SPF: pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) client-ip=77.48.224.243; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sirena.org.uk header.s=20170815-heliosphere header.b=qXmdH0ye; spf=pass (google.com: domain of alsa-devel-bounces@alsa-project.org designates 77.48.224.243 as permitted sender) smtp.mailfrom=alsa-devel-bounces@alsa-project.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 27C5B267795; Tue, 11 Sep 2018 13:05:48 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id D49BC267806; Tue, 11 Sep 2018 13:05:45 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail1.perex.cz X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=disabled version=3.4.0 Received: from heliosphere.sirena.org.uk (heliosphere.sirena.org.uk [172.104.155.198]) by alsa0.perex.cz (Postfix) with ESMTP id E8CE12676EB for ; Tue, 11 Sep 2018 13:05:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sirena.org.uk; s=20170815-heliosphere; h=Date:Message-Id:In-Reply-To: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:References: List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner: List-Archive; bh=RpXAKNEPcANM0R8ZGDZnxNWoXz/l0LFsVFIF98oOQ04=; b=qXmdH0yej/G8 R6hrwU9HiLSA6XPDEOLboYqyDNlPhGlC0kBZN9Eh+/urPSHYlghmWA+LZh3nogLZ8eCUNkQemSFac RtsHpcLnTU1EQ9PNmrBiKhylD0aqiLFvbDxusWUqgbpakVMnmsDAzBXO93zbE84dZ8lRKyMQkn0tD XRrJ0=; Received: from cpc102320-sgyl38-2-0-cust46.18-2.cable.virginm.net ([82.37.168.47] helo=debutante.sirena.org.uk) by heliosphere.sirena.org.uk with esmtpa (Exim 4.89) (envelope-from ) id 1fzgUG-0004k4-MQ; Tue, 11 Sep 2018 11:05:40 +0000 Received: by debutante.sirena.org.uk (Postfix, from userid 1000) id 56AC11121AF8; Tue, 11 Sep 2018 12:05:40 +0100 (BST) From: Mark Brown To: Rohit kumar In-Reply-To: <1536658161-31656-1-git-send-email-rohitkr@codeaurora.org> Message-Id: <20180911110540.56AC11121AF8@debutante.sirena.org.uk> Date: Tue, 11 Sep 2018 12:05:40 +0100 (BST) Cc: rohkumar@qti.qualcomm.com, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org Subject: [alsa-devel] Applied "ASoC: Fix UBSAN warning at snd_soc_get/put_volsw_sx()" to the asoc tree X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org The patch ASoC: Fix UBSAN warning at snd_soc_get/put_volsw_sx() has been applied to the asoc tree at https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark >From ae7d1247d8673ebfd686b17e759d4be391165368 Mon Sep 17 00:00:00 2001 From: Rohit kumar Date: Tue, 11 Sep 2018 14:59:21 +0530 Subject: [PATCH] ASoC: Fix UBSAN warning at snd_soc_get/put_volsw_sx() In functions snd_soc_get_volsw_sx() or snd_soc_put_volsw_sx(), if the result of (min + max) is negative, then fls() returns signed integer with value as 32. This leads to signed integer overflow as complete operation is considered as signed integer. UBSAN: Undefined behaviour in sound/soc/soc-ops.c:382:50 signed integer overflow: -2147483648 - 1 cannot be represented in type 'int' Call trace: [] __dump_stack lib/dump_stack.c:15 [inline] [] dump_stack+0xec/0x158 lib/dump_stack.c:51 [] ubsan_epilogue+0x18/0x50 lib/ubsan.c:164 [] handle_overflow+0xf8/0x130 lib/ubsan.c:195 [] __ubsan_handle_sub_overflow+0x34/0x44 lib/ubsan.c:211 [] snd_soc_get_volsw_sx+0x1a8/0x1f8 sound/soc/soc-ops.c:382 Typecast the operation to unsigned int to fix the issue. Signed-off-by: Rohit kumar Signed-off-by: Mark Brown --- sound/soc/soc-ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) -- 2.19.0.rc2 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org http://mailman.alsa-project.org/mailman/listinfo/alsa-devel diff --git a/sound/soc/soc-ops.c b/sound/soc/soc-ops.c index 592efb370c44..f4dc3d445aae 100644 --- a/sound/soc/soc-ops.c +++ b/sound/soc/soc-ops.c @@ -373,7 +373,7 @@ int snd_soc_get_volsw_sx(struct snd_kcontrol *kcontrol, unsigned int rshift = mc->rshift; int max = mc->max; int min = mc->min; - unsigned int mask = (1 << (fls(min + max) - 1)) - 1; + unsigned int mask = (1U << (fls(min + max) - 1)) - 1; unsigned int val; int ret; @@ -418,7 +418,7 @@ int snd_soc_put_volsw_sx(struct snd_kcontrol *kcontrol, unsigned int rshift = mc->rshift; int max = mc->max; int min = mc->min; - unsigned int mask = (1 << (fls(min + max) - 1)) - 1; + unsigned int mask = (1U << (fls(min + max) - 1)) - 1; int err = 0; unsigned int val, val_mask, val2 = 0;