Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2929386rwb; Mon, 15 Aug 2022 14:15:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR6FmBarzUtv++KdvASye5bG+ioILVoqCQkItGv9wTVmRPCKUMWD8V2fefsWeLF6eUiAjVl7 X-Received: by 2002:a17:907:2cd1:b0:730:65c9:4c18 with SMTP id hg17-20020a1709072cd100b0073065c94c18mr11500854ejc.324.1660598106570; Mon, 15 Aug 2022 14:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598106; cv=none; d=google.com; s=arc-20160816; b=EjdP8J7kfv+bWA24eZNNV8jpwxPhu4B3x4cLJj5y5fJabAWoTX7p6xaUuDm1v2lJPT v5dvqJ717Fv1Nq951iKxexaEUm0coXSGHivoiTEkMfLPnmI95CPw7BjeqEm1gyBYQ8hF s62u5WwoKZohLWoOcyuMD0vEpJ7ICFtWeAVcTk9Q61yeDH78M8wfpj0WBiiiQnv3hxrS Pgb/Bz/Zp1xUfa3qU/vaahCNFe/qPMYpPnErVIeoDdeOtkY0ORYm8jLtmwUt6T3Yu9Xj dtHTKRMkFa6I8VyH6LN+7NxmOh179wQXN1ZYg4pqD11QotN3j1xYcy8BDQTVfMJpyT7h yLfA== 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=U31NSQnIc2eu9scwdjvQM4jA/KwFgpw/fkol055FZtPFpWG/txf1exG+50Oowa8V+Z cSxrI9jl8PSXvbcDGnoE+m4+S6YufgZoHgxky7IvqW5DXM6eAKLIO/Mpre0IAjk4Gd1V R95amyULgOizvgQWp8mUSNhW7g3VFjTRPMA/3v/XYdVHUHvS53iJd+otadOUs6PT4Cav Synq8Znrpn5EuSypEclTqyM8kx9so2AWjbMmod3TCYS7TE4HgnBqcuFGm84UfJXyyUh7 qsAh+oY81IUANQfJWMooq2eKPsBDxLKPS7BQZwzXSTgKpEL5AYgSd+7Blx93HUkaJeWY pmSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pKNKIBVU; 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-20020a50cc88000000b00442296a8407si7485393edi.629.2022.08.15.14.14.37; Mon, 15 Aug 2022 14:15:06 -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=pKNKIBVU; 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 S243812AbiHOT2Q (ORCPT + 99 others); Mon, 15 Aug 2022 15:28:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245662AbiHOTXm (ORCPT ); Mon, 15 Aug 2022 15:23:42 -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 8DAFB2E9E4; Mon, 15 Aug 2022 11:40:51 -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 1B93F6117D; Mon, 15 Aug 2022 18:40:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11A3AC433C1; Mon, 15 Aug 2022 18:40:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660588850; bh=PQa41Dw1cLrvGbifrXo1+Q6UP14K5C3ONaexlLXM2xo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pKNKIBVUW0d+GvqDQRHc8DmsH+QrOBZLmz4nGPN3+3QwjClNZiwQQvuQ9eAOtg452 mkEVlY3CJI3Cr84YyuZ7QuFDm3u6MGatgf9wBw3dHA7U8UJbG3fQzodqNSPpBwBQvN I1LWIS6gyquZgy83zb1NxuOn3r5Kjjz2BGpT+2pY= 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.15 535/779] platform/olpc: Fix uninitialized data in debugfs write Date: Mon, 15 Aug 2022 20:02:59 +0200 Message-Id: <20220815180400.174734457@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180337.130757997@linuxfoundation.org> References: <20220815180337.130757997@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