Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp208871imj; Thu, 14 Feb 2019 18:44:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IYUPdUct0CWfKdkVEV0mDsRdyhoIIJXqCpLC/fT8imXczg9NFVucsdhaIZF4nkZuesGsncD X-Received: by 2002:a63:6196:: with SMTP id v144mr3101170pgb.137.1550198676117; Thu, 14 Feb 2019 18:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550198676; cv=none; d=google.com; s=arc-20160816; b=sU+jT9s4BfUcY5QFvCAOd3AFb1fVLN1gqs37Wpz7pS583a1o44PS2nATXYzO+LdWlo 9qCYUAcmAmUQzVpo4NJBYYS0Km84oNEp8/myU8CIbCjOp3Meai/Yo80dX1MszgHYDtuE VomHL3VgrOogkrLhlFMznXlPD9SEwVhx+Jbf+YpAHgIVH5BkX8t1nJUCnF1NVeLYIhkW rG3qZEqfe3Bi24omaOJxRtBUaHi1RqAKvyQwMzkyUQmFhssLVRoXyld3X8jYOfjHzxB2 a08aJgRwq6pXNQ2kUeIyakNiD/ZArSh7gWmeFJ1NYNz58uwwWFj43XoXH/28ubzaNsYG Y7Pg== 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=IqxyxaTy13CmCRzb2VH10Ra8OOZOlYfUhKEm8H/QmM8=; b=BiMKZCUIclBx78PbGkV5NgxHC8HP4ddm1Sx2U/DUuhkyPa54pIUtC3Kel5mKJRFWg3 hdSjQ2EahyJbAABFyg1U8BgTXCr4h8CKY4KHrFYJwTCR7OTwmW1Qyq5+3nnmbFwXjBnz yFaA8D4oxp62tmRMxtzqjktQVb89fns2ibbc2cLJrf0XWV1weHEpNBFX2RZuca90VLJh qBsfQpfgon4Kn8KG3LgISpQUWgWcpvWlszTxa7vYIxCawjZDfbTXCu/SpUH59O5f45Hx 6pGsCllNIRM4r08XBK4LKATxqffxEkYefbOM5Su0eKPJsCzoOQt22MI3NizDyjjJw52G +0Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=xLRKSoax; 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 o12si4062919pgn.145.2019.02.14.18.44.20; Thu, 14 Feb 2019 18:44:36 -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=xLRKSoax; 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 S1732775AbfBOCnO (ORCPT + 99 others); Thu, 14 Feb 2019 21:43:14 -0500 Received: from mail.kernel.org ([198.145.29.99]:49238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731383AbfBOCJD (ORCPT ); Thu, 14 Feb 2019 21:09:03 -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 08F74206BA; Fri, 15 Feb 2019 02:09:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550196542; bh=ja27/XNLSwFGJAZ7KS2QJyKkg2+V3Zx9H8eoyoL0xxc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xLRKSoaxXz7sEYAgHIgyNktID/CeVcHtXwWLxgf7mlksQPxgf23FOPxBmYhY3nXZ1 BGUuUupIyonqLg9yGwlQnkFLpIpq7Y0t1Lgx3PQWPlUPZfT8GGDQIVhRrM+w52V64A WfkpCyNHmmr+Rdp5kOroFPog+RNi2yJg6zLRexBg= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dan Carpenter , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 4.20 03/77] ALSA: compress: prevent potential divide by zero bugs Date: Thu, 14 Feb 2019 21:07:41 -0500 Message-Id: <20190215020855.176727-3-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190215020855.176727-1-sashal@kernel.org> References: <20190215020855.176727-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 26b5e245b074..8b78ddffa509 100644 --- a/sound/core/compress_offload.c +++ b/sound/core/compress_offload.c @@ -529,7 +529,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