From patchwork Mon Oct 24 11:29:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9125 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp456350wru; Mon, 24 Oct 2022 06:34:03 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6zWZ0dzOdBTiIezWbGA4zTKb+eyY+n1ABt6MSZAILtUrsDQ4bg20LC03FM4PJaRC+tqb7k X-Received: by 2002:a05:6a00:2382:b0:56b:a25d:76a3 with SMTP id f2-20020a056a00238200b0056ba25d76a3mr9760021pfc.8.1666618443295; Mon, 24 Oct 2022 06:34:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666618443; cv=none; d=google.com; s=arc-20160816; b=DFyRpKRk8pJjm06zsUsocvpEppKi7TOBPbXFUfVlCpwVZYkVfPSrVvhZGkJwocpSTj kr62KdYbaqv8qtyuqcjFvpHWQFmErqsiGUj8yBm2mkBwoXvyiBJUJMjZjTxX1nA/s7Ub yG2vzdJnknQB8urHN0mido2NFABom8sja7d7FKId1hIIU9orsr/xKAPzRjUzMap5Yh8A LSa/S2ZD7tbcLE8txbd/ZrHmrBbw511XK3S1hFbMM5KXmOCK6dZFqIGSdDbmk/xUyzRV Z1R4bnZyHrrSYeYqwD+l+X04wsrh8KvuUuWxUZEcbZGHmV4/LQGD9jm1BRQXZxfZmBe+ Hzug== 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=Fc9exZXT750WKQjZu64CgejmE6Xww9Eyn1Fy6s4PrLjBv2IBkQSiogATonEi8Sa7gZ 1vJmzINgzBfLByhbIZb2g/Fq9r1dHLYsVd9/mODIIzV63nFwfaHaeMXscZtG4OQVRSLl iG4UcucTTQS8rNu2N925HcWVXGkdhiHS8CfW7/wcD213ITH+mN8UUZWTHrucqv1j+Zt6 ZXWW+cKhlz5zlxITYooOSyjdfpSo83HrZq09iv6CJ4hZQDKZMOwSJ44W6CrD0qbMYP/U EguQNhpD9PbhO/I0toyJwTLJpAHyIpj1VjCr2fpztYXzyJUpQkBbvcV/MgwOnAiB/ehQ 8f2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MMQESAQP; 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 j18-20020a170902da9200b00179f8a3f838si39434796plx.593.2022.10.24.06.33.40; Mon, 24 Oct 2022 06:34:03 -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=MMQESAQP; 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 S232196AbiJXNUt (ORCPT + 99 others); Mon, 24 Oct 2022 09:20:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235987AbiJXNS4 (ORCPT ); Mon, 24 Oct 2022 09:18:56 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C653CA52EF; Mon, 24 Oct 2022 05:27:27 -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 E7069612CA; Mon, 24 Oct 2022 12:23:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02E70C433D6; Mon, 24 Oct 2022 12:23:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614187; bh=FGLUiA+nI5EoWurmpv9dwxt2Cwd9+rHSJ5m5kYCZDGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MMQESAQPUb6KUjoQkKO64OFIbjeZMEMtSdC1A2Ehfh/NfXEsAAmLpEBWN/ZZk3iSJ NL8fQiUszwPjBPAOGmS4+/Hc88LJoBGC/LrzEhuJp/C4axjHSw7Y/aFhKg1r5DEkvL CIiSjg+X9NWz76G3U56G+vjS/2xWXUVrXsQ6eurM= 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.10 148/390] platform/chrome: fix memory corruption in ioctl Date: Mon, 24 Oct 2022 13:29:05 +0200 Message-Id: <20221024113028.991208637@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747576101029253157?= X-GMAIL-MSGID: =?utf-8?q?1747576101029253157?= 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)