Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3407955rwa; Tue, 23 Aug 2022 04:23:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR62xRO9xtuuUchk1TfeYNLe1E4YPiaigF1CM5PdcmlRlceaTiskmnekHg2ubmr4JCvyuokB X-Received: by 2002:a17:906:4795:b0:733:1d3:3d33 with SMTP id cw21-20020a170906479500b0073301d33d33mr16646122ejc.200.1661253823660; Tue, 23 Aug 2022 04:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253823; cv=none; d=google.com; s=arc-20160816; b=zELff8Tj61pVGHOWmj/YMu3lytqnokP9vfltPQkunj6qJHsJD1fJY4OcBvrk70Wai9 2ZvTRS1l0WsCoJkZEgWny2BIwCVKTfFQDfPNJeCS7Cv9L35xVrWZ02rqw8wZt/He77lC vGGKzPm6CUPUJzeJTE682oAodcntXppcKZ+lOBFTw1ejhU38ZpMPwlzCFus4qnteHsUH r5xCoMnLDsSS5dZcJdYqipdLpoJK3tSoB9njfJBO0H79wvqFk5+tipf6QTGe2MotJWRg CpcicL+M5iQejiCgiy6zpkjpRgd+/EteUYclVghudDyqUN9kyX8LJbJQxKtJebLexdRE NHcg== 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=8FSOSoqxyY10vubac9eyaV0Re1qgirXhyywgiAqy+qw=; b=jSTkMKz/TFuT7O1qpqMWFMKPWsw12yGUTYPnNODrLkg6x/71TQ7PqfIRlrFqfjfMLG B54aWyqSrRgEV8ozQbr/HzBMYh19nwPoNAxSYaxOhRguTmyxzeUctvEsVT+v6tRe6BrA D/mOtPqYY9OefhsiSFVClxCoNrutrSB4ZjVERgdlYfaS6hGre+VCzqUmi08vSta7ukI9 /m43AJb0FOeJfewjgcnNrNx99PJ/G7hhoKLRZ0sii30hyViDf04T9FY7xgf4yKVpTmDk 2gomvNp8RnuvPfosJff/CQ3Si3zG6GBWstivly3XOT9H1Je+JYnx7kOftGXTZ+VWCcYA KmxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v2EOvyIN; 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 z9-20020a056402274900b00446b9916bcesi2353322edd.13.2022.08.23.04.23.18; Tue, 23 Aug 2022 04:23:43 -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=v2EOvyIN; 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 S1355560AbiHWKjl (ORCPT + 99 others); Tue, 23 Aug 2022 06:39:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353458AbiHWKXy (ORCPT ); Tue, 23 Aug 2022 06:23:54 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFE271C107; Tue, 23 Aug 2022 02:04: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 2A1B8B81C66; Tue, 23 Aug 2022 09:04:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76CADC433D7; Tue, 23 Aug 2022 09:04:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661245479; bh=9Vm/04/BKez8WlyH59ztffwB8ABqaL/QFghDcHvSJOk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v2EOvyIN3+RvaDj6NAygT+U28CdAOb96XRGK4pzbzo3EbHIifl4SDf04RndlNDN33 HCQ0Sbl2PbtiIEIOjwo1g9YePKUkjv75A4QCm+EXdTMdy4VJUN5DtnFxcMSg4ZjHop gg5zOkgfg6FGpwp2jYOH3gSzkBZBEJuiNx28RJzw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Kalle Valo , Sasha Levin Subject: [PATCH 4.19 091/287] wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi() Date: Tue, 23 Aug 2022 10:24:20 +0200 Message-Id: <20220823080103.368341935@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080100.268827165@linuxfoundation.org> References: <20220823080100.268827165@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 7a4836560a6198d245d5732e26f94898b12eb760 ] The simple_write_to_buffer() function will succeed if even a single byte is initialized. However, we need to initialize the whole buffer to prevent information leaks. Just use memdup_user(). Fixes: ff974e408334 ("wil6210: debugfs interface to send raw WMI command") Signed-off-by: Dan Carpenter Signed-off-by: Kalle Valo Link: https://lore.kernel.org/r/Ysg14NdKAZF/hcNG@kili Signed-off-by: Sasha Levin --- drivers/net/wireless/ath/wil6210/debugfs.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c index 55a809cb3105..675b2829b4c7 100644 --- a/drivers/net/wireless/ath/wil6210/debugfs.c +++ b/drivers/net/wireless/ath/wil6210/debugfs.c @@ -1004,18 +1004,12 @@ static ssize_t wil_write_file_wmi(struct file *file, const char __user *buf, u16 cmdid; int rc, rc1; - if (cmdlen < 0) + if (cmdlen < 0 || *ppos != 0) return -EINVAL; - wmi = kmalloc(len, GFP_KERNEL); - if (!wmi) - return -ENOMEM; - - rc = simple_write_to_buffer(wmi, len, ppos, buf, len); - if (rc < 0) { - kfree(wmi); - return rc; - } + wmi = memdup_user(buf, len); + if (IS_ERR(wmi)) + return PTR_ERR(wmi); cmd = (cmdlen > 0) ? &wmi[1] : NULL; cmdid = le16_to_cpu(wmi->command_id); -- 2.35.1