Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp2940201rwb; Mon, 15 Aug 2022 14:29:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR6C2cCPXOJGXSgqOEiv5pTEc7KO+pj5CyuVHll7UOz8JfxwJAocKjnyDdHoiIa7UByMIzyd X-Received: by 2002:a65:46c4:0:b0:41d:e36b:1e59 with SMTP id n4-20020a6546c4000000b0041de36b1e59mr15172794pgr.494.1660598961884; Mon, 15 Aug 2022 14:29:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660598961; cv=none; d=google.com; s=arc-20160816; b=fUoMhrLnN5KHYSUIDAxR69cvIXVpsOZbkA7R1eUz/YEdCHOJ7XZQkQt+nfRRNx4ZoR me1s4e+FNUXzs4nkru/e5XmiCMZ/JMZDhEXPjocoz4o9Gf5fAWZHi9RvHGDb92fBGXDv NZiIX2jRuwjUL2rvtnGwTCgZZfP+3GfoFkI0pIRlCERciUOe196BhKi8OuF9Q1TEqVFt sDR9EctEnnoUrigmhP44Pw0pMQXX8B+r6n82uKhL6Q5I4Gx/zCYW/kpYw5L3N2+lhWWB NNoCzXVTyFVCrkghO/2qZqZ98RoN1/degGDWgd5v8QQZNuJ+vGXT+CqjFe4FsbcCR27D 2V+g== 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=nCoUqzhIwJDsSKsAsxMLBnlElqb1qJGwmTbP5my1yIU=; b=Mnto4MPUo8xuVewXNRweWSA2NtzIrRQTAFh42JnK6Z/6rL5MbngjpiRbCduYgPH986 BBQBtcKATVY7+fu/HO9v1PeOcCWqu+55wqHxnLZGILHlHqy7hl9Wz505onVzeLPG3TKo nP89tpkP6f8H/fKmOAWB+VhBFWScxOIiFZzzCWIPxlUxk4bheLnw0t9o0k1pHHV5a+FC Ky5ysR2qzgQZ1yum07MVB4jTlCy3jPtLQNqbar7mFqmMTVZs/QSZrojT71wZW2vwUb9T I4Y1CreRDZ8Bh6n4HLFFHsrHQdZ/WeOiGwVatX+jZRy7m0HLkONgHN/rEndTgOo3birY 1f8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Cpiikw84; 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 e17-20020a056a001a9100b005186df822dfsi12369103pfv.378.2022.08.15.14.29.02; Mon, 15 Aug 2022 14:29:21 -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=Cpiikw84; 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 S1347432AbiHOVZi (ORCPT + 99 others); Mon, 15 Aug 2022 17:25:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241608AbiHOVNs (ORCPT ); Mon, 15 Aug 2022 17:13:48 -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 DB262DABB5; Mon, 15 Aug 2022 12:19:47 -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 49EF460A52; Mon, 15 Aug 2022 19:19:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37903C433D6; Mon, 15 Aug 2022 19:19:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660591186; bh=qXskdu1j9rHf85RE4xREBJawMz2p1A/Hq3++wgRptaI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cpiikw84cllnhkM4OGWv5CIppUOh0eunSQjR4WRk1GbvvHVffEEMb1MeTHkSDBOm1 wgenBsf5/HEV0z9QGknKhFz89bBlYAF/1ypwAAp8ddP7a1DAtPwWxTIGdL+7iNAIQJ yhTq0uv6bF4AXqj8eSBCyLCRUIkx5hmTaJekq9EU= 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 5.18 0467/1095] wifi: wil6210: debugfs: fix info leak in wil_write_file_wmi() Date: Mon, 15 Aug 2022 19:57:46 +0200 Message-Id: <20220815180448.927414587@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@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 4c944e595978..c6f8254cb21d 100644 --- a/drivers/net/wireless/ath/wil6210/debugfs.c +++ b/drivers/net/wireless/ath/wil6210/debugfs.c @@ -1012,18 +1012,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