Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3409404rwa; Tue, 23 Aug 2022 04:25:16 -0700 (PDT) X-Google-Smtp-Source: AA6agR5kgwUOlCDOqT/VGFcxlPm0aJQd+SYDP/p+aaN0l1D6Rzs5KpKXtQ4hm6e1gCBFx2/nkGSp X-Received: by 2002:a17:902:a411:b0:172:766e:7f3d with SMTP id p17-20020a170902a41100b00172766e7f3dmr23014622plq.24.1661253916139; Tue, 23 Aug 2022 04:25:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253916; cv=none; d=google.com; s=arc-20160816; b=O3Acm+0+hpp/TXZw4GsYxkrDu/GTD7BJQKyM2aC45EDV8W0p07HcZTPstW6MjacaPQ CMEC1f3+qNYObRxKuMBN8489ZdllIuh78Y9bSmg6spADBso/b4/+P1CrZvHJGBp1CoSu DfH3FtRVI8Hgswhn32Dc+5rUlDsHhSrTfXPuew9DVXVjYqdaf8WWRY8X852qt7FIcsYX 5wQgRsW9sYR63+sDdryMrZ+JwyUq5wBKoe0Gf9tta3JcbzOMTbcK4cYdhOBID7C8Ot/a DaBObkwxMMZI+dj4RnEKoCFGCt9wTJwpd62xzHYhcZEQDWrs7Z1j/p3qQM+tu/zf/wHH z/Hg== 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=JsXqxQ3y0W8sVgrhgNy3T1nSiSAno7/Htsnd7em49Ek=; b=okAKTUchWn+6dggzPLvNCC3DELghcYArJdICx2+srghDy+7HCV5lZvGIm+oSx91ZX+ T8d8b/Lfk9PTvtkiolSfTPQjWnxSeUd/FLSOBiDCefjMNqsS7k+O0xheFvxLhCb6sfmU h+PnEoThlBkn1edDwBzcG2CbTiC0A6X0iM/Vp5lm8Z+1+hTX8CeQqw/Pa/yc8AMbw81R wxyRo7QDU4CsmQsXaNNHOOGgWT88V0JO5it3F3Y/HukPcPrqDWXZLW32WjF6KlSWGQbP oT9rOxIBiyjr0yB0yN7W7vG4xWFR8baUuz8FKOoBiOnNRn+k9pKC2HvEHhQ7KbUDMs1F eltg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mdoSxSMA; 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 w18-20020a1709027b9200b0017280be5a02si13495534pll.589.2022.08.23.04.25.05; Tue, 23 Aug 2022 04:25:16 -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=mdoSxSMA; 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 S231504AbiHWJuP (ORCPT + 99 others); Tue, 23 Aug 2022 05:50:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243895AbiHWJsK (ORCPT ); Tue, 23 Aug 2022 05:48:10 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CB547A758; Tue, 23 Aug 2022 01:44:42 -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 A29CEB81BF8; Tue, 23 Aug 2022 08:44:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F374FC4314A; Tue, 23 Aug 2022 08:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244280; bh=CmcPK2lc47Okxh9b7fsrFvpDKb/n652OLhI6HxQ2s24=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mdoSxSMAEvQfdbvlKlhPCuzuB5GiZQIwiydH6mkglSSllZrC4JI4sRNgLL4aP56Yr bN6BDCJv/dhq/IGVWXe1LZL/ZESRKxfpUo5UkM77+yaRocCPS50K35t3/nkodIQWHs MF1wqkcwNPEp6EyIRRl52u/ahWCTO8YjRUbcAhxQ= 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 4.14 113/229] platform/olpc: Fix uninitialized data in debugfs write Date: Tue, 23 Aug 2022 10:24:34 +0200 Message-Id: <20220823080057.723034349@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080053.202747790@linuxfoundation.org> References: <20220823080053.202747790@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 374a8028fec7..b36a000ed969 100644 --- a/drivers/platform/olpc/olpc-ec.c +++ b/drivers/platform/olpc/olpc-ec.c @@ -170,7 +170,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