Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp200181imj; Thu, 14 Feb 2019 18:32:33 -0800 (PST) X-Google-Smtp-Source: AHgI3IY4Ui/3NxCfKRP5elycPTqXuR+8rJes/AjpMTwsmX/DPEqoiZsIMGKHFS/2enbJpN90A+U2 X-Received: by 2002:a65:5844:: with SMTP id s4mr3041541pgr.77.1550197953913; Thu, 14 Feb 2019 18:32:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550197953; cv=none; d=google.com; s=arc-20160816; b=iEyWQnqNQ1W0I908TTaMIw54lmal/8egegChfYwDBSKoil8A5FZ7JiRlxKwWKmZ/Eg 2ProCVw0r7tblLrowwPfvgs/CfwR+KgHX9cfy9FS9G5u4vKjRNzzyrHnDN+/dW3FYasw lVAxpGXKNnBnDi5DmnJl4iCy4gnDEiSiMS057oMawVUZ57ISFhCL+un0UQtONrXA1+SK fz+d+EhlGt/5JSpzT87tMceJYvUJqdMnZVGu07o7N/NEOhH+w7jU/ZiRYSamhepL7azn q+WJ6m0kpUb4cLAqnhv3pwq9fY6yIbspSYeemB0uIYEPeLjUVCZK9V/BKTOZ8FyHGYSS gGHw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mqP2bypg+wUdjuCjjq0naMX9w8x/uH+vqz/IB9nt7os=; b=jrrHZR8kEFO9uyxSp6JQMod3DpNoQ1oTKt1/+MrVyvlZyWNGi/QgiaK2qxy5tV1VJo tdrmrmGx3aRUR443oIWNx4lhEEvne2vnqZ375AVv4fwngOz+8KsNQFWp5acDQyCLCr9C hl3VaK5rDTq4rAK++ogYk+OczYWijhXy4pEBtyYuSPJcu28iBuWYpitUNJpH8sQjidHb BPyxmNeJWGtrDHPDVPMCl3B2uu8oHALPd69Lsg7Iq5ead8JRxsAzQGeoKSbrp+2tzXJQ jNvQ/Eswf8LY8G7A9ZI09o2fUcdWw4DttcP3n+Vok55g4+GWwwQGTXnfqCI9xXDmDfAd zhFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=enHJZF8y; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r9si4090976pgn.471.2019.02.14.18.32.18; Thu, 14 Feb 2019 18:32:33 -0800 (PST) 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=enHJZF8y; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406018AbfBOCPz (ORCPT + 99 others); Thu, 14 Feb 2019 21:15:55 -0500 Received: from mail.kernel.org ([198.145.29.99]:55460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405953AbfBOCPv (ORCPT ); Thu, 14 Feb 2019 21:15:51 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5864D21934; Fri, 15 Feb 2019 02:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196951; bh=csy7O3Nzx+6UCQKxhkSdu+lQ2sAk7ulItMiT4vKj8ns=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=enHJZF8yeei0/2ijpHywB6KKMopSFRZ4b7nwq6AXEnr+9kehEU49wjZSOBZKCeSTE eEFI/IBGSdiG2C1lTfIHGC8dtlf2Bj7nj2XXNbT9v2uleVZVyiyssgmmjoubM5aiGC r2PRKvSgxBJNoFgcWvYKFLydyAVPLm/3D/d9wSJQ= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 3.18 03/16] ALSA: compress: prevent potential divide by zero bugs Date: Thu, 14 Feb 2019 21:15:33 -0500 Message-Id: <20190215021546.179605-3-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215021546.179605-1-sashal@kernel.org> References: <20190215021546.179605-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dan Carpenter [ 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 53cd5d69293e..307344452b5c 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