Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1864399rwb; Fri, 19 Aug 2022 10:39:24 -0700 (PDT) X-Google-Smtp-Source: AA6agR5WJCICPMbtO6l8WyT/tjVfRgq33VVdcPwgqZsAd6aSE0mDOnAGQ/0c5/N3/FmbI33yKfE1 X-Received: by 2002:a17:90a:930b:b0:1ed:5441:1fff with SMTP id p11-20020a17090a930b00b001ed54411fffmr9649237pjo.238.1660930764260; Fri, 19 Aug 2022 10:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660930764; cv=none; d=google.com; s=arc-20160816; b=RZtRucgpcpvYOULqJ415NkZCZlVQ5KATn+IBuYQDq+I6sOrthWxhOnnt/BKPixyGX0 lqILhVuE4FT6uitj87wWZWGZFUI8RntykLGrX0lCRvhO9Umt0SepWHOpiuX+v4dTRt+Q oHPm9GmcQhhS1fQYq+hJVbgwBjGZXsWX3XOFGc77m9vpBiqTwk8aLHwOWl3IsLxfSW9I P5sJ2C8ulL4txREcKojZVIaOOuQo6/OPvViYetDeZGFgamtiHOjltzbWH44JMoVNLZ9o coKfG36oZJmxHvl5MF6rEvfqDQlplUMClVo1Hl0xC1IY1qC3QYdRjSWXIglnYts6sL8x Ltow== 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=19DdYnPHdrt4ArMHcfeTVoImyST+ELGwwUBT8+oSXog=; b=uU1hWXN1xHRRAsZ3JJ425jePSrjxvmqQzlNHwy1biN45bBThBmhe0+89PEArb22Vb3 4Ff1KM8VpIeSEEc1ruQrtV+NHYIm8kwx0rIGL9NNRqSyQu3mzuNwBceiywNKARjbRVtR VjLJr+H+/7EoyiLPjg8vxsde3IsQ3dvlKN3aPRAXoBwra7aSAanyrhQRSl7s7JCKebvR aHDSQ/Qhv2dDYPaZrt8mGnV6rtNjI787HgftI9hTXYU9PD5aEwKc45e4G+PnP5zDY2v2 NgkfF02bM5P/xYrhPs+99uLzwMxnjIM2OgG1RkxiLT3CMXRcUAbFYI5Ts0/J51qnpbl+ Le+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0uVaEPye; 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 m2-20020a170902768200b00172bb852a27si3368675pll.256.2022.08.19.10.39.13; Fri, 19 Aug 2022 10:39:24 -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=0uVaEPye; 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 S1353132AbiHSQd1 (ORCPT + 99 others); Fri, 19 Aug 2022 12:33:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353059AbiHSQab (ORCPT ); Fri, 19 Aug 2022 12:30:31 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88D2310AE10; Fri, 19 Aug 2022 09:04:48 -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 2234FB82802; Fri, 19 Aug 2022 16:04:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D4F0C433C1; Fri, 19 Aug 2022 16:04:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660925084; bh=YcBMqvhV+F0IBf4JpO7+0HnjAx/i8V8xOh8U7HuEtzY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0uVaEPyew5iLcCri8lhEGZwJvqSZ/kYb/uBZ0c/EzFGPvFJLRa0Nx8v2b0RSTuhe+ TERdqFo+wDePMwOVfWuPBOtlJjQ0olveHsIA4pvc+jeEPe5CDdKC9YWHrNCIQ+RBjz ogIivss2saQEyrPcrxKi58QccNUha8CyIHlLPey4= 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.10 349/545] platform/olpc: Fix uninitialized data in debugfs write Date: Fri, 19 Aug 2022 17:41:59 +0200 Message-Id: <20220819153844.995199967@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220819153829.135562864@linuxfoundation.org> References: <20220819153829.135562864@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 2db7113383fd..89d9fca02fe9 100644 --- a/drivers/platform/olpc/olpc-ec.c +++ b/drivers/platform/olpc/olpc-ec.c @@ -265,7 +265,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