Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3095365rwb; Mon, 15 Aug 2022 18:00:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR4jmBNEfnwF9+Gc+O2ZR+qApGwQDoinLBo4mJ2khD3cZND877Mgm0IryENtbNGwhEgGsy4j X-Received: by 2002:a17:907:28c9:b0:730:c053:986f with SMTP id en9-20020a17090728c900b00730c053986fmr11584041ejc.194.1660611657575; Mon, 15 Aug 2022 18:00:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660611657; cv=none; d=google.com; s=arc-20160816; b=FWuQlXy2bztLYasKCFHUodT/1czthENDYY8BWmfwuuOb3HGzKSPhIO2sd8OCtlCpwf 8o1eO175EBoydmtWM52EItbMd4DHGMkg+KcKhH15Z5pxsipozQeboRfSxptPRDRJPliz xjswRts92+yIOx5GWlC1dpygEOHWt4cxO6DXustXMiN0M5zprmvEVWykwnSAiRCi4Ed1 zwGlIND6AtB556bo6/P6Qp6BJAYj/jxAbLDdOAlu9lXZSE9utn4SMjn2ohTVK8PBKj9U /jxga6rFOuNZxRIGUCeo4grR/DbKuI/rm659lFKxFQ9EGx9eYIX0bmclUebA1yfycJQ+ 1FpA== 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=Ds0KoOLJAPbcf7qGO6VmURWbCrFVliVkG/m28XJRpEwYcK9Esoqe95PNZaZr05HKcu adN4e3oviCPpuv8gwed4bc7cGlCxBiEvTasGt88N3sF+smxgFTphbjf6cYXxNx8ldxfl LIpfy0eB0p81m5+hiAQVc2oJG3G5djLWCDvOgrmFg2FCtgOHq20k0Nj2EMGBYyslwDva mNOQFv5NqhHYvSsYK9Yvjd/X/hRyqqocE/97J3aCy4el6IL5C6yN3G0pZZ4aehl5WJ81 fL8+N+stehCDB6cSL8xJwfgGNhF5sfa/xM4JYqH66js7u973TigbPLdQBS+7ITf+e9dT 2hoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=t3ZfCs+C; 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 q8-20020a50cc88000000b00442296a8407si7823131edi.629.2022.08.15.18.00.31; Mon, 15 Aug 2022 18:00:57 -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=t3ZfCs+C; 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 S1348325AbiHPAcs (ORCPT + 99 others); Mon, 15 Aug 2022 20:32:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347219AbiHPAaf (ORCPT ); Mon, 15 Aug 2022 20:30:35 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3157537FA0; Mon, 15 Aug 2022 13:35:43 -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 936C4B80EAD; Mon, 15 Aug 2022 20:35:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C2B92C433C1; Mon, 15 Aug 2022 20:35:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660595741; bh=PQa41Dw1cLrvGbifrXo1+Q6UP14K5C3ONaexlLXM2xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t3ZfCs+C/2gOY+8Q12x47dZHuunEQsBJkcHv2c4w6rIPCy9eeAnIoq/TqpqGppVRg WWXzwFcQ7/zMpPVqpw6uuTmui9W8rdmDY4nd43O/Rt8FC2Z8TVwibzJmwM3kl4QAgO bppFJ3G3i/LfKezvTSWpZuwtLtBcdl8SI0hypvEg= 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.19 0859/1157] platform/olpc: Fix uninitialized data in debugfs write Date: Mon, 15 Aug 2022 20:03:35 +0200 Message-Id: <20220815180513.832536957@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@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