From patchwork Mon Jun 1 17:54:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 225009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3EE78C433DF for ; Mon, 1 Jun 2020 18:37:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FC6E2073B for ; Mon, 1 Jun 2020 18:37:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591036633; bh=O84gu8JATb2e8SHlXObL3eCI/z49fjPGgXDZ+gNoxq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=u5aZEwnkTXc6dyKUhXlRxl2dcEzjrCrGBfKOezVuG9B04V3g/vQ3E3rDxN7tk/hud bhyhfOOCHWvsUlHbd+po1RD8FbWcnsNCPELOdWbsXIDlo3QkiGxeK/XGnxLrF3rDXO t8YsyjDGKWj/MminmThA6Lcm1+PaGU8CBZSmAf0Y= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731605AbgFASPk (ORCPT ); Mon, 1 Jun 2020 14:15:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:36052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731603AbgFASPj (ORCPT ); Mon, 1 Jun 2020 14:15:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6F0F2073B; Mon, 1 Jun 2020 18:15:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591035339; bh=O84gu8JATb2e8SHlXObL3eCI/z49fjPGgXDZ+gNoxq8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Sk+jOlYYNyu8ytvRMkOMjkekoX9mgYEvpruH/7ApRvgqp5wUqntlloLw6wuAG67K+ KuO95J+t3eN4di02URukvzzqUq/+5N60sYFxQWrGK/3nwxoTgXkTO8698JhSUm2Jn1 o6TXC2J0akYRALEvgr/zSQwlyQUZ5mmJ4YUBZXB8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Changming Liu , Takashi Iwai , Sasha Levin Subject: [PATCH 5.6 114/177] ALSA: hwdep: fix a left shifting 1 by 31 UB bug Date: Mon, 1 Jun 2020 19:54:12 +0200 Message-Id: <20200601174058.133282954@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174048.468952319@linuxfoundation.org> References: <20200601174048.468952319@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Changming Liu [ Upstream commit fb8cd6481ffd126f35e9e146a0dcf0c4e8899f2e ] The "info.index" variable can be 31 in "1 << info.index". This might trigger an undefined behavior since 1 is signed. Fix this by casting 1 to 1u just to be sure "1u << 31" is defined. Signed-off-by: Changming Liu Cc: Link: https://lore.kernel.org/r/BL0PR06MB4548170B842CB055C9AF695DE5B00@BL0PR06MB4548.namprd06.prod.outlook.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/hwdep.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/core/hwdep.c b/sound/core/hwdep.c index b412d3b3d5ff..21edb8ac95eb 100644 --- a/sound/core/hwdep.c +++ b/sound/core/hwdep.c @@ -216,12 +216,12 @@ static int snd_hwdep_dsp_load(struct snd_hwdep *hw, if (info.index >= 32) return -EINVAL; /* check whether the dsp was already loaded */ - if (hw->dsp_loaded & (1 << info.index)) + if (hw->dsp_loaded & (1u << info.index)) return -EBUSY; err = hw->ops.dsp_load(hw, &info); if (err < 0) return err; - hw->dsp_loaded |= (1 << info.index); + hw->dsp_loaded |= (1u << info.index); return 0; }