From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 04F909443 for ; Sun, 13 Aug 2023 21:21:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59780C433C7; Sun, 13 Aug 2023 21:21:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1691961699; bh=0AMdvi2yKg9TaoT5QvER/EDpE0FTF7lzsOVJd4Y4lHc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hj7sOY8irHDjF3o1+RyKzx9oJ01GUrl2BS2/pt2IJ78QeeCxhk3p11Bdmn3LbD2Sq sbDZ36MiMaKzcL90IpNx8iZ6eDEJ/Oh2D+T3JzZ5qmKV4+urq3xuAwixpbKXGnLxl0 VRVpIcYOmTZBCg0olGU7IPj/ssQVcJDL3hGLWD+I= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Tzung-Bi Shih , Yiyuan Guo , Stable@vger.kerenl.org, Jonathan Cameron Subject: [PATCH 4.14 08/26] iio: cros_ec: Fix the allocation size for cros_ec_command Date: Sun, 13 Aug 2023 23:19:01 +0200 Message-ID: <20230813211703.300724861@linuxfoundation.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230813211702.980427106@linuxfoundation.org> References: <20230813211702.980427106@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Yiyuan Guo commit 8a4629055ef55177b5b63dab1ecce676bd8cccdd upstream. The struct cros_ec_command contains several integer fields and a trailing array. An allocation size neglecting the integer fields can lead to buffer overrun. Reviewed-by: Tzung-Bi Shih Signed-off-by: Yiyuan Guo Fixes: 974e6f02e27e ("iio: cros_ec_sensors_core: Add common functions for the ChromeOS EC Sensor Hub.") Link: https://lore.kernel.org/r/20230630143719.1513906-1-yguoaz@gmail.com Cc: Signed-off-by: Jonathan Cameron Signed-off-by: Greg Kroah-Hartman --- drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c +++ b/drivers/iio/common/cros_ec_sensors/cros_ec_sensors_core.c @@ -47,7 +47,7 @@ int cros_ec_sensors_core_init(struct pla platform_set_drvdata(pdev, indio_dev); state->ec = ec->ec_dev; - state->msg = devm_kzalloc(&pdev->dev, + state->msg = devm_kzalloc(&pdev->dev, sizeof(*state->msg) + max((u16)sizeof(struct ec_params_motion_sense), state->ec->max_response), GFP_KERNEL); if (!state->msg)