Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp676216img; Fri, 22 Mar 2019 06:23:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhE7ICQ/sBzDLCTW/28Mrr2xgxp3uO8XsPex+MuO4IheQXvqBH2rKJPAyh3W460DJ3HcBI X-Received: by 2002:aa7:92da:: with SMTP id k26mr9207733pfa.216.1553261001248; Fri, 22 Mar 2019 06:23:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553261001; cv=none; d=google.com; s=arc-20160816; b=BEpkCHRZrm5o0RIIyeVQC4rE11Nfcf4vp0S80m0usKMPll6iS19a24PJhumsNCM4tC jsKXTa2dHdgxIZGsOjHdMY9r2DLgLGetHW0RA6bOmFagJa+R9ScPiQ7SKHK0JdBKtfy8 hdqNyYcG1ER3FxV05C/R4mBl2v4rg5M4J25hvUjpJNf9SuGbLrYiQxY9ljDEC/r7mnDi CEI4Nkq2eVepzLSJ69JT54wEvzOHY565xQKVtdERdgcLozVl+0eNihrssUCA0Vc0mwDe iqH1XitRbu/l5EL3P83K7A6zXUsPrlt0NxaeIUNKerLxiNUK27cThu7/J0NCzaPz8Cue 0LDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZYCD3U/LNRcbvC7KORSMuVkpQHLt9NNvDdF7mM9L21U=; b=HngjeJ0DjEAPAmqhvUtHXaz7Bnr/qK6IffepyJSj0bhxEZOzz4WQMLi8jRlDzr9bHE CQfWPDC2u1RuwqT8X8dAyxv1rqY8TKHUcWMdMhqkUAUZWajkckNZWC+b4ceCSjypDnML hxtUG/L9VmFfDAJFqzDkski4io1n/x/6cP4wJcOfU6rucSXD0GKmZG/qgrcm9a+xQKcq 2ommXmq3BFdFowcWjtmIanXe3DZK2zHfEWZFUBcA1vZN0LgfzwZFk/6kQ+AhX7PqHgQn B9apnbDogGBLb7wNOYY4pTKwV/zprD0bilHH/ZqOATIDxmH7Hxy1tCyDFXpp9jzwNR4f TLvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EBnriZ1W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t69si6854954pfa.7.2019.03.22.06.23.03; Fri, 22 Mar 2019 06:23:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=EBnriZ1W; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728475AbfCVNU5 (ORCPT + 99 others); Fri, 22 Mar 2019 09:20:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:47214 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728451AbfCVLUt (ORCPT ); Fri, 22 Mar 2019 07:20:49 -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 1F4FE21916; Fri, 22 Mar 2019 11:20:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553253648; bh=J3HqjFZ72iKIw6xQL5DarYOww9fuRRyNMJsLEP5x3FM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EBnriZ1WvwtSfKN7p4H9mcc7bWH/B9ueoTn23Ksxn6AyVt/4IF1Tm+NFfDqvo+Chc YSUhAmPnPdsD+wUnWXSwkzEzVXGa5JNHVfr4G33kDBXBJtx7t5mmT2yVCTAD43USiC cHe1baOSM+8P8nQOkuvLi4I7YhzAd5OZDiQHsE24= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mark Brown , Sasha Levin Subject: [PATCH 3.18 029/134] ALSA: compress: prevent potential divide by zero bugs Date: Fri, 22 Mar 2019 12:14:02 +0100 Message-Id: <20190322111211.879359487@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111210.465931067@linuxfoundation.org> References: <20190322111210.465931067@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 678e2b44c8e3fec3afc7202f1996a4500a50be93 ] The problem is seen in the q6asm_dai_compr_set_params() function: ret = q6asm_map_memory_regions(dir, prtd->audio_client, prtd->phys, (prtd->pcm_size / prtd->periods), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ prtd->periods); In this code prtd->pcm_size is the buffer_size and prtd->periods comes from params->buffer.fragments. If we allow the number of fragments to be zero then it results in a divide by zero bug. One possible fix would be to use prtd->pcm_count directly instead of using the division to re-calculate it. But I decided that it doesn't really make sense to allow zero fragments. Signed-off-by: Dan Carpenter Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/core/compress_offload.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/core/compress_offload.c b/sound/core/compress_offload.c index 53cd5d69293e9..307344452b5c0 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -500,7 +500,8 @@ static int snd_compress_check_input(struct snd_compr_params *params) { /* first let's check the buffer parameter's */ if (params->buffer.fragment_size == 0 || - params->buffer.fragments > INT_MAX / params->buffer.fragment_size) + params->buffer.fragments > INT_MAX / params->buffer.fragment_size || + params->buffer.fragments == 0) return -EINVAL; /* now codec parameters */ -- 2.19.1