Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2873436pxu; Sat, 19 Dec 2020 04:59:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJzpF3O54LvYcG4Inpn8GkKFu2CAlZoOfoijLKb8+1h7LbfxAZn8/pTBxY1tZNISmWEru3NA X-Received: by 2002:a17:906:aeda:: with SMTP id me26mr8217785ejb.11.1608382788163; Sat, 19 Dec 2020 04:59:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608382788; cv=none; d=google.com; s=arc-20160816; b=hBedxxDyQcklVEZ4Sc+LJu2+WVPO4+ypltZ1ix/8KY8uZnwgaHGRKp6r1CUycxfYuy Vy037fsIXmRdlU8XufRL/aMlZ+XkKCSDztxfy40NUG6Pl05HZt3BuNo6Sjnv9xVQRrer IcdSem0xB+cW/7D3Rl/kwL0NZuwTE3lCtR9hMpnVrUIZHFI0DcC4/3/u9cKG0P7f2p52 8e5cE48f2f6HQeI6WGWtrG9M2XUNFzQI37qflc8L5/51tt+GH2gsVR/k6DTWbB9v4nFp LHJfZrXYLJdwoo93Obo5K6WFEXaOs2B7bKjqhQvtuct8s74OepLFBXvPjok2lQseFub0 LJuw== 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=TTeaK7UIkMmkF0YYazzTWYsuCNpXNOdb3HRYsiGsMIRSgQOdBWp+Nz5cjXbapYPPiG YzayJIqvaUY99tK4blnEZSJzbyWHz9mgQ3cWFUHMxsUES8vPbJvAD1lARsDKJOXiMlql bvQNH8od7r9liObklIXhqMmGmsYL0fiFnmnx+chnAfa713EhfTErwGerCRLBKDVCuZUt KWVy+KQ/qSuzpye5ybyCTA1c0MTq5KZhWMEtCDwsa6V7igP8MnoWOm+KGs1669fadVJ6 P0CliWMRnGx4cN6ymHXJ/q6ggGkWIQ6fTkVHtBq/rJMzhaFvKEGwMYTzLz1/QPy+B38G FfyQ== 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 o16si4217688eds.116.2020.12.19.04.59.25; Sat, 19 Dec 2020 04:59:48 -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 S1727347AbgLSM54 (ORCPT + 99 others); Sat, 19 Dec 2020 07:57:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:44170 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727200AbgLSM5g (ORCPT ); Sat, 19 Dec 2020 07:57:36 -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.10 15/16] ALSA: pcm: oss: Fix potential out-of-bounds shift Date: Sat, 19 Dec 2020 13:57:22 +0100 Message-Id: <20201219125339.822396243@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201219125339.066340030@linuxfoundation.org> References: <20201219125339.066340030@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;