Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9036906pxu; Mon, 28 Dec 2020 05:05:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJySy80cz0kKQfnc3dBbymxDuZGPrT8bi2ncPapMbt9HcQF7AQl1NN7yA3z/WM+SZmWNJEOc X-Received: by 2002:a17:906:17d5:: with SMTP id u21mr26128214eje.109.1609160738372; Mon, 28 Dec 2020 05:05:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160738; cv=none; d=google.com; s=arc-20160816; b=NTIwsrFo87FD1Gukoshjlq8eHj4CkCqWE3iv3UokPCoyh4SLh5jqMBaITsbo2f0BAH IMrSxU/ck1EqXXA1AC//dQrvrpPZy3aQdBAJYyfkCQZHlP3S2dptxw4HjPm/lo3jGkGC n/zqNYIq7D8QmSa253Jw2uSQIiubz6q53qWLa/UujoGE75QcZpwSh6Me3YUAjZ7b0eEG FMSiUuUceAAi8kv4ifkxvhRcFKZbUGh/WeIUxBcmoxlkrlx5v53r3bCziY6TVRfrjo4r /WC4OxKlBSiuFIFIxFgPlK7ov//FuP/hltTa65Qgw4zXAgcIWbkuTe0DxS+8H5/dsICZ scTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nEQ6rETxxekZMQPaT0jeLVLtx5516Rxjo4bYeGumgCI=; b=YC7p2/EyJCnm8jncnC6FnHdkOrLEYsDFBjT5/N4BrFK5jqy3viKr8TQgP2wiQ2lkUQ FG+NZbxaCXUOiVeUEy4yf6qZ02p+5HQVE+spFzgSMAPqC1giTgxPqSWDT5buiElvmLH8 iklq6McecmwH2crSfR/GFUg1s2F8lTAtdWh02mnXT/EjlO3Ejz5+lvk18oXO3wlo8EXr ZfJK2jNJCVXc5qmMqeULnPXWNXJkK7zzqkcWoFHmtt4BjyLY8iHi0jCH1EfTdlZMs63L W0PxZz5nVZ84qocCQVuIdbaecIj5xoi7N21/KALXakaDRIw6o93Vs0cz1/hGzLkHbi2u u55Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OQdPq7vo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bf21si20983984edb.369.2020.12.28.05.05.14; Mon, 28 Dec 2020 05:05:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OQdPq7vo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729904AbgL1NB4 (ORCPT + 99 others); Mon, 28 Dec 2020 08:01:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:57886 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729789AbgL1NB2 (ORCPT ); Mon, 28 Dec 2020 08:01:28 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0ABCC22B2A; Mon, 28 Dec 2020 13:00:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160447; bh=C1HU05v2WrIhDgrXB/EuS5sq9eP3kYw95gyL9K81B7s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OQdPq7voyIPUxZlbXo/QT7jQ9yTD+6n0JVYys4f28fVfPyNePF44VUGdkNNd1RwRR RMxsvuHHoISeLyGvemUsYOs1UIFARrUsgqNNhtoQpPzRUL5Q2tw+JJZUyiihsIP1Ki 6D8IyhsRh9dOdCGdEs1TAAgcr9nAy9cKSbBsdOh0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+df7dc146ebdd6435eea3@syzkaller.appspotmail.com, Takashi Iwai Subject: [PATCH 4.9 024/175] ALSA: pcm: oss: Fix potential out-of-bounds shift Date: Mon, 28 Dec 2020 13:47:57 +0100 Message-Id: <20201228124854.428034957@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit 175b8d89fe292796811fdee87fa39799a5b6b87a upstream. syzbot spotted a potential out-of-bounds shift in the PCM OSS layer where it calculates the buffer size with the arbitrary shift value given via an ioctl. Add a range check for avoiding the undefined behavior. As the value can be treated by a signed integer, the max shift should be 30. Reported-by: syzbot+df7dc146ebdd6435eea3@syzkaller.appspotmail.com Cc: Link: https://lore.kernel.org/r/20201209084552.17109-2-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/oss/pcm_oss.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/sound/core/oss/pcm_oss.c +++ b/sound/core/oss/pcm_oss.c @@ -2001,11 +2001,15 @@ static int snd_pcm_oss_set_subdivide(str static int snd_pcm_oss_set_fragment1(struct snd_pcm_substream *substream, unsigned int val) { struct snd_pcm_runtime *runtime; + int fragshift; runtime = substream->runtime; if (runtime->oss.subdivision || runtime->oss.fragshift) return -EINVAL; - runtime->oss.fragshift = val & 0xffff; + fragshift = val & 0xffff; + if (fragshift >= 31) + return -EINVAL; + runtime->oss.fragshift = fragshift; runtime->oss.maxfrags = (val >> 16) & 0xffff; if (runtime->oss.fragshift < 4) /* < 16 */ runtime->oss.fragshift = 4;