From patchwork Mon Oct 24 11:30:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp435002wru; Mon, 24 Oct 2022 05:53:28 -0700 (PDT) X-Google-Smtp-Source: AMsMyM71hvmnvqCXH0hv/19ojfWEEapSBovwCF/yiXvB184wBsqrNbyrDGIRbMSfrN5n8jxV23D0 X-Received: by 2002:a17:907:3d91:b0:78e:11cc:3bc7 with SMTP id he17-20020a1709073d9100b0078e11cc3bc7mr27606039ejc.655.1666616008373; Mon, 24 Oct 2022 05:53:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616008; cv=none; d=google.com; s=arc-20160816; b=xpmnhkpO68pdN7d7jAG4LbxFPVpghzDizGKkq0lfYNA1LEP/0PVkX7rEcZ2GbyBJNs MPEb7U+XaJ4NknZoHU0VgSxSGZmaj+3y2vHBHchFyGpLziUkdxj7a9rk5QjSZbuwVXdO UMBd3mUstXlL6qtLF9DMP76H5Mc9RrGeKRz+oj8nktouflgwdyR7lFb4GG9WyQwAn6JF GxKbTNPAQVHzWDC5axBgqeR600qDxn3kQWZPU+9IjkFkJJKxPRjtYSeJK+KkPd2qY3WU 4aPdQ9VRteNnPkCsGEFqSbigFE7hrq9DFvBOaPOE4F5wEtnCU1HWJxGsMRLT9UzWnc14 B4zA== 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=/csJDqmCeT0TSNlaMlarojsPi8f4jlNdRTYmo9/D3jQ=; b=iaYEBRzXQ7EyrxBOMy+VwGIsbc1k7Uoe97WgoDCOkrDvPesM+l1mglb2K3uhoX+sp6 +3jddWqIkYE1kD7lwiwv6MHnxpx5S8EXbpfPG75uJCaSF1lAaOIWIz67xo4VHZdpl/mV LBfu/4No5HfEsgANNnxBCJZFzxh7YzVTeUTzCf5pxZjvRc+eYd+sZw3vysRbgjt0W+lw TbQvn0Y+8Wp5OvB3zyZIRWV3OcbxrnOSQrEvkfgJXNA50ME0Bvg7jjVAImbmWrtD+U9u Iz6qI7DGykMk8rJIH4BVrgQBELffcubEy981liLWgio5nl8Fj5vl3zetVpXaVy6UMepR wcbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lZaQS7xd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nb21-20020a1709071c9500b0078049ab4bbasi28802641ejc.526.2022.10.24.05.53.03; Mon, 24 Oct 2022 05:53:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lZaQS7xd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234625AbiJXMwM (ORCPT + 99 others); Mon, 24 Oct 2022 08:52:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234842AbiJXMpw (ORCPT ); Mon, 24 Oct 2022 08:45:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A67A24BA55; Mon, 24 Oct 2022 05:10:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id BC40661280; Mon, 24 Oct 2022 12:09:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4108C433C1; Mon, 24 Oct 2022 12:09:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613398; bh=Bi/jTu3vv3ASwo99EidjsRPHNNx3PdUduh5fUYjNiGY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lZaQS7xdINCFy3cGfWMrectNkc/JeuHMSr5vrRaIiOCJFaCSAJydjWG1RgIjfRj5Y PwEYebEtHrQr5IUM+7B3nIvPT+0S0MiFa7qDuN+hdiKu+XJ0d/mvAxNHXJbT1uKLD7 ZSUFAQkFj4JPm8IZqkW7qBbtY1/Ms70eSbX6gZ/U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Guenter Roeck , Tzung-Bi Shih , Sasha Levin Subject: [PATCH 5.4 091/255] platform/chrome: fix memory corruption in ioctl Date: Mon, 24 Oct 2022 13:30:01 +0200 Message-Id: <20221024113005.527640362@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747573547594493085?= X-GMAIL-MSGID: =?utf-8?q?1747573547594493085?= From: Dan Carpenter [ Upstream commit 8a07b45fd3c2dda24fad43639be5335a4595196a ] If "s_mem.bytes" is larger than the buffer size it leads to memory corruption. Fixes: eda2e30c6684 ("mfd / platform: cros_ec: Miscellaneous character device to talk with the EC") Signed-off-by: Dan Carpenter Reviewed-by: Guenter Roeck Signed-off-by: Tzung-Bi Shih Link: https://lore.kernel.org/r/Yv8dpCFZJdbUT5ye@kili Signed-off-by: Sasha Levin --- drivers/platform/chrome/cros_ec_chardev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/platform/chrome/cros_ec_chardev.c b/drivers/platform/chrome/cros_ec_chardev.c index 74ded441bb50..1f5f4a46ab74 100644 --- a/drivers/platform/chrome/cros_ec_chardev.c +++ b/drivers/platform/chrome/cros_ec_chardev.c @@ -328,6 +328,9 @@ static long cros_ec_chardev_ioctl_readmem(struct cros_ec_dev *ec, if (copy_from_user(&s_mem, arg, sizeof(s_mem))) return -EFAULT; + if (s_mem.bytes > sizeof(s_mem.buffer)) + return -EINVAL; + num = ec_dev->cmd_readmem(ec_dev, s_mem.offset, s_mem.bytes, s_mem.buffer); if (num <= 0)