Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2874634pxu; Sat, 19 Dec 2020 05:01:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJwouxzeJgPH/jWlBWlx8XsYmVKulOnRCa6WiOyEyuVTmoibhaxjzxfEOUOXeHzxqKuM8j49 X-Received: by 2002:a50:d60f:: with SMTP id x15mr8634341edi.224.1608382896742; Sat, 19 Dec 2020 05:01:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608382896; cv=none; d=google.com; s=arc-20160816; b=BVrEby7G22WLUrxlUm4WlZXwipbC2yUGx53WntPKDhW+R12qIhFImBk1bJcHlEYDnz mCi4i78oMs5VInFYldNbpe3mV71EYqSObMjFmTM+yUz7luXB2kv4GEEfaY8cmigxK2e/ 6i0HbEql+7nGf5C3a6yWB28g69+sY5DXWntP4rmiTlKiqGXyEnsN9K5Y7+yjxB2KXizQ iEi98PJqOpRp9oWvUgTgiLMlP4b/GPESbxkQndHrzXp4k40HiBtm+mUgByEm2W2TkRbY 3TJMMqfsB04I2ojmg2OBIjqkBG7IpiVasN8y3RkG8O9EXLJiH/s3J6pnhHFwqK53CNCX LBYQ== 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; bh=nevPvejhxBGXzBkCBEH/ihtrpCKifiqZALJdFv3Q+Y0=; b=nBGnaV+Prodpz0yUNc78BleTR8tsfwxX2Us2o2GWtLfCzVo99TT0cr6If3BKaBSPXW IPDS5mHBEiwD/e2gEKrDf37ApBAqLBuwQyIFxuLXJodnmyJPotk5UwqtlL3536Bf9C2g 4AvCJbqYnObG2WJE2vklt7dKy9t4yifutVWmZZNqDQFijpE7g9j7tfZWRlxjgR4SJ9sI tvo2o0d9T8GaF5cBdZ2X7HTZFiRFL0NSxtqd1y1FjUIi3NLNMXTIjpUQeUy3wTm2vjCW OqjIuyYyBfptCsQ1qk5VbgOBwSP7CsPbw11paF+3N4kJC8iCyq0+F2eSee6P1rD7+EY7 e7UQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (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 t6si7836710edq.353.2020.12.19.05.01.14; Sat, 19 Dec 2020 05:01:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728164AbgLSM75 (ORCPT + 99 others); Sat, 19 Dec 2020 07:59:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:46570 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728229AbgLSM7e (ORCPT ); Sat, 19 Dec 2020 07:59:34 -0500 From: Greg Kroah-Hartman Authentication-Results: mail.kernel.org; dkim=permerror (bad message/signature format) To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+df7dc146ebdd6435eea3@syzkaller.appspotmail.com, Takashi Iwai Subject: [PATCH 5.9 44/49] ALSA: pcm: oss: Fix potential out-of-bounds shift Date: Sat, 19 Dec 2020 13:58:48 +0100 Message-Id: <20201219125346.823690385@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201219125344.671832095@linuxfoundation.org> References: <20201219125344.671832095@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 @@ -1935,11 +1935,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;