Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3026882rwb; Mon, 15 Aug 2022 16:25:05 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Tl/5Q3tGSuMxODSDnKQ6/M/oYS3uW4ix2eEHJSH1uWBrzMt0OiCqk6rnoCqynm/6d6UUB X-Received: by 2002:a17:902:e885:b0:16f:8f52:c93a with SMTP id w5-20020a170902e88500b0016f8f52c93amr18975841plg.140.1660605819425; Mon, 15 Aug 2022 16:23:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605819; cv=none; d=google.com; s=arc-20160816; b=p8JOP3R24L/c8R14lGeGioFw3LppUZSGWH1TQprkFV6KRFxBNFWDpjhtVy6Blc7crG BsoIPdnKPsQBbNzBRd52KyE4UsvLiuraBRfhHOurzoPJw5EnMAL0llSE3wXWyluTM/nJ /emYQLZ0uU9me7M8sx3R7xhE4toV4w0KTqPntjN7Y9lih9rxx7BstprEy+r34yqmPn0x 1kUFq7HSYzJQetJ7q5rADMFDdBHmrlbh/4ytR/LPr+rkzOFmHB93wxY6zohTCTQCttcS QgGML8GVs5HXYBz1/wZsfGbGF4/Rx1+1AqwJs4mogLjl1NdQTcDZs90wkrAIW3SNoQYQ npVQ== 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=AGPX7pPgHBuUiCi9oB8iD33i4rjnaUjDsvjRf2GUuo0=; b=b0iLaib3vkQr5MPrLmNXGAcJINdwAEirUzmj++L4pKGBRVdduxk6pHELV65Tq8VQfY lcJiuAsdFwtRy9mzF1sT7ZPkyCOEb/+xEX2AcjBjRSiC5ApOsZPgIlIhdT6F7zI1gIOM 1CVrvTTyrJu10PiZ9H+YwP0hTBUT2Z8bpRalTebuNnYViRMWkSSGHwi4eVBDy8e5nLiJ AJ4PsikfeIYLfgmRspnraGbwPXXvB71co58gEkltCbFmVlAushDuGedjEhYy2h5LlVU8 hu2R2Y10L1Q+2XInzGwbu061foKcDGmMkSK+o+mOuhUZL/P2M6YgPkP+RuSRRQuhFvnU K/rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FB8mS6C5; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q20-20020a056a00151400b0052f6911360esi11989998pfu.155.2022.08.15.16.23.28; Mon, 15 Aug 2022 16:23:39 -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=FB8mS6C5; 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 S1347689AbiHOWY2 (ORCPT + 99 others); Mon, 15 Aug 2022 18:24:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350792AbiHOWSd (ORCPT ); Mon, 15 Aug 2022 18:18:33 -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 1034941D0E; Mon, 15 Aug 2022 12:41:52 -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 A1DBA610A3; Mon, 15 Aug 2022 19:41:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95C54C433D7; Mon, 15 Aug 2022 19:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660592511; bh=PQa41Dw1cLrvGbifrXo1+Q6UP14K5C3ONaexlLXM2xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FB8mS6C50WsgEK4gkdcKJh6ZXRhpvSOdD4zvz/iwP+9BoZHlZNcLxnyvDPrhtD3eb KzJ1+znHqxTmTmfz3rlzd6tUaywI5bCyd0Tn//BKt18cxgdroz6WoXu2onOpZnZrv8 H6q1MRfUEwDmoMV9/2POcUWz74pFtGJHWqmplyd8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Hans de Goede , Sasha Levin Subject: [PATCH 5.18 0801/1095] platform/olpc: Fix uninitialized data in debugfs write Date: Mon, 15 Aug 2022 20:03:20 +0200 Message-Id: <20220815180502.399267021@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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,T_SCC_BODY_TEXT_LINE 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 From: Dan Carpenter [ Upstream commit 40ec787e1adf302c11668d4cc69838f4d584187d ] The call to: size = simple_write_to_buffer(cmdbuf, sizeof(cmdbuf), ppos, buf, size); will succeed if at least one byte is written to the "cmdbuf" buffer. The "*ppos" value controls which byte is written. Another problem is that this code does not check for errors so it's possible for the entire buffer to be uninitialized. Inintialize the struct to zero to prevent reading uninitialized stack data. Debugfs is normally only writable by root so the impact of this bug is very minimal. Fixes: 6cca83d498bd ("Platform: OLPC: move debugfs support from x86 EC driver") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/YthIKn+TfZSZMEcM@kili Reviewed-by: Hans de Goede Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin --- drivers/platform/olpc/olpc-ec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c index 4ff5c3a12991..921520475ff6 100644 --- a/drivers/platform/olpc/olpc-ec.c +++ b/drivers/platform/olpc/olpc-ec.c @@ -264,7 +264,7 @@ static ssize_t ec_dbgfs_cmd_write(struct file *file, const char __user *buf, int i, m; unsigned char ec_cmd[EC_MAX_CMD_ARGS]; unsigned int ec_cmd_int[EC_MAX_CMD_ARGS]; - char cmdbuf[64]; + char cmdbuf[64] = ""; int ec_cmd_bytes; mutex_lock(&ec_dbgfs_lock); -- 2.35.1