From patchwork Wed Oct 19 08:27:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4685 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp212991wrs; Wed, 19 Oct 2022 02:08:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM70nrfAe5zOCzDMH0aONJyA9t8/QPQUKvGClEZFswslbFETcJDH+KQ7l7ZPYelxlu266NoJ X-Received: by 2002:a05:6402:448:b0:45c:8de5:4fc with SMTP id p8-20020a056402044800b0045c8de504fcmr6431808edw.133.1666170531921; Wed, 19 Oct 2022 02:08:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170531; cv=none; d=google.com; s=arc-20160816; b=pdzuKNGd0B2Cgb+Gw6+avRvR5sfEJPCTPkZUFh7041nWeB7oM4zbihlED9o6+Gtjuv dcLsiTX7Ty+c0YEEQwOGIVmw5DWftqBI3qnaiSkfrNZ7rtN2oeraJQh7IuK6/XbTFtLx sw7qS5Blv6eNC4k1F/358gz0gUhC2m9T5rwAvGEaARve9BwQxBq0tz+AvPG1RVwSKUG6 y7B8iD7B/vbzqnmvLmqUvm2ZvvZ/oooitpO39etbbPVKygNs2pumOtPeQ/0qObyP8dtA JzTuo52gq3SbMIgszOrirgJfZoRnvbvUEHpzHsCIGwtlgljm40X9Qwra9ljlDzQMV4GL Hnnw== 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=pSBBrXRY9Z4cgnIlH7/TzH/L3nTUpril3EL78nqF+x7NTn0ACR5p84c1QVOo7wVJu0 uP7AGiw1/yaG0ROHpPPFWKDA4tP8VSrjAfsKYvpNRiZOMDqfewzo0eRWLRQ7SW6N1sAx p4XJaAYaNqzYC4wJyGXW0OjcB4nI+r6T+NXbTe9c3uvt7RYc2V2I4pzxMQuQrDgF+cip CTai2C1W4gQeR1tQJbHSk9K5Q9wOawP2Hq075C765e2U3WejtXe3a0rwX/McJp/UBDwJ YwvtpQqk3RrzrzO0t18LpipwJCCeP1bnSFCmjxvrLElqT297eUWh+RN/al5UZGCNyI2k jUbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="xdb6PY/A"; 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 v8-20020a50c408000000b0045744c3c3d8si12682511edf.515.2022.10.19.02.08.18; Wed, 19 Oct 2022 02:08:51 -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="xdb6PY/A"; 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 S232115AbiJSJDl (ORCPT + 99 others); Wed, 19 Oct 2022 05:03:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229808AbiJSJC2 (ORCPT ); Wed, 19 Oct 2022 05:02:28 -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 60A7D95E72; Wed, 19 Oct 2022 01:55:57 -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 531E2617D1; Wed, 19 Oct 2022 08:54:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5DC7AC433C1; Wed, 19 Oct 2022 08:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169671; bh=FGLUiA+nI5EoWurmpv9dwxt2Cwd9+rHSJ5m5kYCZDGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xdb6PY/AkXp2s+ImeWD4wPj4V82RIOeHNvdEhMZBqVBeUVjL26j7u/cqZ5QyBKaPQ yX28o8T6QhxfU0byffuXGRo+wvsGtBsXDqmCOCJvelCSCXR/6i1kfnJoIHLtJSQfvg v9APonAEMdacZU/7xiTu+Uz2Ld+k5Sv0f/nj8K/g= 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 6.0 364/862] platform/chrome: fix memory corruption in ioctl Date: Wed, 19 Oct 2022 10:27:31 +0200 Message-Id: <20221019083306.085879814@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747106432019431519?= X-GMAIL-MSGID: =?utf-8?q?1747106432019431519?= 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)