From patchwork Sat Oct 22 07:23:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7407 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1097367wrr; Sat, 22 Oct 2022 01:07:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6E2k9WFB2f7uric1c7flhIz1rsu4ebZTB/0xtcQ4VnfqhnQLEF1/YCIzNfHrpgt8f30ZHC X-Received: by 2002:a17:902:70c4:b0:178:54cf:d397 with SMTP id l4-20020a17090270c400b0017854cfd397mr22529742plt.24.1666426051879; Sat, 22 Oct 2022 01:07:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666426051; cv=none; d=google.com; s=arc-20160816; b=m3lr0W5J5MM8DFG/xWldVI6SadkyeTYXRuwfmBFgDRHpUj78OETAjuaqH3HthUstaF xfw9Cvf+rHZVQlO5DLPQgi3y4h889cFq6/XiNC1vi9Ai8ltLnr9q1cMuHHCr7cIRW7dP iSy8PvxdQFRRo0dY1l0eZVFNxd8RjRGJP/RUg/0KUotYoosYWiXM1nAdKZfbXQJIVF/F X83lO3ci/GUYWV97ASWo5Fokkn/Klp57/aOBXJkGyYcIJwKVngTbTvQIuqF6aejrjz6x TRuLWV//UBcNyPSAucAfw9IKEsewkblyqe6poGjF0LtuWocfHXS/nr7XkbD34ndjReD6 n7Aw== 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=vvI3+VWA+2mcXN4KXlGusSzPv4NyoHHcIk3s6pIfUvg=; b=Rs9gWtNOfWzFPClhOo8MS+EbVY7YAeKe3RBL+LNyqzE7okk/q6VPMLi+FQHXh1k2z3 o/bSENMcrJqKya5INc62OmaVJwnqap07RcMVqguzukczc34+Rxm2zlBJHkGHoUPcQkYJ YNV8s/FyJCthTG82Gf5nr+MYZ07XI24C58Gp0+sRyzpg3hOIgCW86ffZ3u71bvmpgWLV b/rX5QmBNACACBWhk8r+1N5XdRsclV2Wn6x4dzSk74Ffs6rYXOWt4FyMNnNvUEKsJPcA mVSBI3wUIO1xwRv58J2EDW4tlo+hS7tWiFWW2X74jXrRlgS5yJmh1VcNO70pKAsChl77 ufEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OvlJOOH0; 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 nh7-20020a17090b364700b0020d56f57eafsi1871864pjb.120.2022.10.22.01.07.19; Sat, 22 Oct 2022 01:07:31 -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=OvlJOOH0; 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 S232626AbiJVIHC (ORCPT + 99 others); Sat, 22 Oct 2022 04:07:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232981AbiJVIAa (ORCPT ); Sat, 22 Oct 2022 04:00:30 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A160253BD6; Sat, 22 Oct 2022 00:50:26 -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 ams.source.kernel.org (Postfix) with ESMTPS id 5F354B82E20; Sat, 22 Oct 2022 07:47:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B73B3C433D7; Sat, 22 Oct 2022 07:47:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424871; bh=FGLUiA+nI5EoWurmpv9dwxt2Cwd9+rHSJ5m5kYCZDGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OvlJOOH0zUz/2cGCojgm2eB7PVb9N5O68I60841tNneeaoR+MuaAXtu0SO9A0eNHL KdMX7nUp6lVFOKGOiPApKm3Rg4foVrcFeBR9R5GR9hJYVPkSAMePFa2l/IHu+LEMmi eAaxfDu58WF9XMOTzY2KfjmvsgOOakBXmJxqViPg= 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.19 308/717] platform/chrome: fix memory corruption in ioctl Date: Sat, 22 Oct 2022 09:23:07 +0200 Message-Id: <20221022072507.107751863@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747374363607406911?= X-GMAIL-MSGID: =?utf-8?q?1747374363607406911?= 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 fd33de546aee..0de7c255254e 100644 --- a/drivers/platform/chrome/cros_ec_chardev.c +++ b/drivers/platform/chrome/cros_ec_chardev.c @@ -327,6 +327,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)