Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2879284pxu; Sat, 19 Dec 2020 05:07:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJy7HMY5DC/nm0XVjUkOAIuFbS+ykc0ElsI+tddW5C6SkO2KVdp7vnY5pzzF3XdaRTrqmXo+ X-Received: by 2002:a17:907:a8a:: with SMTP id by10mr8238668ejc.423.1608383275656; Sat, 19 Dec 2020 05:07:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608383275; cv=none; d=google.com; s=arc-20160816; b=X1c68RMpVrEb6bGPOVtISDTolVAHU49RUlrk2CG6jFrTjukzUuSquoXZq25UDHKAse GUturcy2am2IuTjHahiSgq0E57w/CvlZwLMPXAy7BcJR8nob7B7JccDhjHAsRnxTt6rq b2lOIdQTMHjuCAvmdL9eOZIK0NzpDBWzpLHjgx1W8XmibRVhtSETn6F11Tl9Eq3kNPc0 IqnLwtRDdYW2+CWtelrg9Cw92eg6rUg6gLob8pwFqOQ2jie3uTzFZtiyFxLgqI9tbH6Y FGkKISyoXQFf9a3vPNTpIj7eD3v2RxtJFHctTYjhe40iLw2dDxNxkGoEWyxZ0WVQjmMb QPug== 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=JLowhJHuWZsgPdThRlfXQSFY3GK1P0ORs+zfUjlkIcw=; b=Ao+xrxKOgXllgKYFOt1JKajQFpm0Q7CJsr2SkDggFCwOQzLdzbMLc6KCc3Ium54ij6 18qPeIpDhHUckq8oQXXmuM/3BN2J+V0lAKeqKBr1YPy16L09dbFs/q1cxENZ6Kg12bdA YX1CcCBrYQzPvADakAw1jxg5F1dgLqgrdl0gsfTKRNK7itK40t+Wq6/6xA9zP8JQb9Na RbvqeQhxcar7ksMbznsVZ0U0vBT/GExfViTyTGEYQFbYgzY5mk22XGsqasYdA7DLaSOU +j3LF2KuXOM/VIW+RytPwv33GISPdEJ2AHwYM3uPrvLRVmTClceAHivbuglZ9n8wXCWn t7Vw== 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 e15si7783029edr.313.2020.12.19.05.07.33; Sat, 19 Dec 2020 05:07:55 -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 S1727282AbgLSNGL (ORCPT + 99 others); Sat, 19 Dec 2020 08:06:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:51364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726948AbgLSNEB (ORCPT ); Sat, 19 Dec 2020 08:04:01 -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.4 28/34] ALSA: pcm: oss: Fix potential out-of-bounds shift Date: Sat, 19 Dec 2020 14:03:25 +0100 Message-Id: <20201219125342.779367828@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201219125341.384025953@linuxfoundation.org> References: <20201219125341.384025953@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 @@ -1934,11 +1934,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;