Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp277856pxx; Wed, 28 Oct 2020 04:50:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzuvFYiKJW5jfhyFiRC6DURRw+kBlLqTL/bEdPFq7WSDMvmL2ICMImL+HV3VIfI7nbCcaqB X-Received: by 2002:a17:906:9504:: with SMTP id u4mr7115356ejx.19.1603885817815; Wed, 28 Oct 2020 04:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603885817; cv=none; d=google.com; s=arc-20160816; b=ETS14Rg/s3joVwKcTduHtOwkp+lhtlyM5cAlg1O+G2sYQYprxUfb2t3p0/hA6Y/9nb Ow1AmwcHa9RuthzdoOi/Fw4xpePv7Ovz21CYgdfe5fGlFDADA4INTClCcn4JWIULFeYG F08uXUbkc9/mlW2NeI/NV61cH3oriC4ZSeANepKqYK91dcjJ5mk5vzy89xdHiWXFur5v z/g+VDWb/V7o6xXKH4E7XMcUr6Pr5+EcRnZ1IF8kCMJ6NhBmVrYJa2Z2xg8ndfp70o66 vI0wOdjn049PdSHpU9pYqbMKhnsBwi11t0UglxwYcgPRxnfITp9gKibQ2BxXTlIBlFZb oWRw== 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:dkim-signature; bh=TBMefy90p+aJmxevQwKf5j9TZGrvd0aj3nrHlaT2mVQ=; b=t/K16lKd0AKCB21mpbAejuU3x4idtyLhDXUvYclN9mqJCW7iSom1WyNu3EYyn+wr/b BTrE8VS0wOtYKiWo+gW4JxasU8KyJMjz5PnNDsDopD/jViXbxti9+8ZgVbULQ9GM8r79 f6Ky5dhCEmCfKZ1i5E7d9CMex2gEV8hPiaiqJ3xoYRfqDcE4gq9eBDvB8aCHTeEgjVWp x6+j9QcknWFfBC5ZuV2zjnmiYSLSXm6lVAufHSxb7wknHlmAuqYSUxeNNWub3lf59X9P oOOKplhli0DyjImv+q2B/6P7yvjiozZ8i7LbkwVd0dPB7aWWS2QAGCNkcrc+BswALd4R 3fVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="vhP/z/YV"; 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 o10si2705925ejr.482.2020.10.28.04.49.56; Wed, 28 Oct 2020 04:50:17 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b="vhP/z/YV"; 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 S1794588AbgJ0PMd (ORCPT + 99 others); Tue, 27 Oct 2020 11:12:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:34330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752143AbgJ0PAr (ORCPT ); Tue, 27 Oct 2020 11:00:47 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 951D422456; Tue, 27 Oct 2020 15:00:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810846; bh=mhzYQj5KSeDFLRpIDX5A9SUN2fe1XUuYOAmgzmCT5yQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vhP/z/YV13paizB3arB6itAjCGaGlohsmOx2s+/siZLkX7ndKrMwFQFpW4vJCKZlV w5hhmKHPuwzY8E1oLWoyUt9dax9rIloXeRf1XzIENtnlQu5xQbaecllOycHRrI0STQ bkRUEa5FRDYQcB99n1bByLmM9ijarzQgPPKRt/ak= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Ranjani Sridharan , Guennadi Liakhovetski , Kai Vehmanen , Mark Brown , Sasha Levin Subject: [PATCH 5.8 252/633] ASoC: SOF: control: add size checks for ext_bytes control .put() Date: Tue, 27 Oct 2020 14:49:55 +0100 Message-Id: <20201027135534.492071007@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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: Pierre-Louis Bossart [ Upstream commit 2ca210112ad91880d2d5a3f85fecc838600afbce ] Make sure the TLV header and size are consistent before copying from userspace. Fixes: c3078f5397046 ('ASoC: SOF: Add Sound Open Firmware KControl support') Signed-off-by: Pierre-Louis Bossart Reviewed-by: Ranjani Sridharan Reviewed-by: Guennadi Liakhovetski Signed-off-by: Kai Vehmanen Link: https://lore.kernel.org/r/20200921110814.2910477-4-kai.vehmanen@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/control.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/sof/control.c b/sound/soc/sof/control.c index 186eea105bb15..009938d45ddd9 100644 --- a/sound/soc/sof/control.c +++ b/sound/soc/sof/control.c @@ -298,6 +298,10 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, const struct snd_ctl_tlv __user *tlvd = (const struct snd_ctl_tlv __user *)binary_data; + /* make sure we have at least a header */ + if (size < sizeof(struct snd_ctl_tlv)) + return -EINVAL; + /* * The beginning of bytes data contains a header from where * the length (as bytes) is needed to know the correct copy @@ -306,6 +310,13 @@ int snd_sof_bytes_ext_put(struct snd_kcontrol *kcontrol, if (copy_from_user(&header, tlvd, sizeof(const struct snd_ctl_tlv))) return -EFAULT; + /* make sure TLV info is consistent */ + if (header.length + sizeof(struct snd_ctl_tlv) > size) { + dev_err_ratelimited(scomp->dev, "error: inconsistent TLV, data %d + header %zu > %d\n", + header.length, sizeof(struct snd_ctl_tlv), size); + return -EINVAL; + } + /* be->max is coming from topology */ if (header.length > be->max) { dev_err_ratelimited(scomp->dev, "error: Bytes data size %d exceeds max %d.\n", -- 2.25.1