Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp4484993rwb; Tue, 6 Sep 2022 08:09:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR4upoJfktqqm2QGUkLJ93UQaIi0pQKNEKrhNf7dC346BQTHf2wJv+PFroScydIE4nKCzYWo X-Received: by 2002:a17:902:ce8e:b0:16f:8f2b:b16f with SMTP id f14-20020a170902ce8e00b0016f8f2bb16fmr53910197plg.167.1662476984863; Tue, 06 Sep 2022 08:09:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662476984; cv=none; d=google.com; s=arc-20160816; b=NxMLHrgHhvVqUY2fg1Jt/ObG0a7Kje8uNwnUbONh8XpcH5Kbzm0Jk6xuzilaj+TQfT 24nEVc8evFNqj5PVOkheufiJRoi68hrjUahH53KglU2Vx1N4C6CiBWHUo0mA1avNYmN8 RZfYXmeCgfSiDo8C9GAJN2ZdRDUCewkv3jrCFD79Eg4/+dPy+fOulu3zNLFKY8PIVBUb 9KVa9BcuZURFuogWQyJSry2Rko9o2NB86Cr23rXTI224TLohhg5vUy1d6yK6LCnZ206N DFDJSPXVXdvFw4XXBRhb/1CV1qhFTV8nHHDqqiIapU0iOakvD6CGNLB+VD+c4zL0DgJm J+XA== 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=1k9GKoUQlUASaXKJ2bONsbqiBm8JDKlzxxps7y2WLiI=; b=i4wo/t9AczUZfnjxaOUQ5G3Sbxn2F7dlLUx6w1yKTCWz4Bn/OPzNKIl26mXM0ERIx+ QwpKryCno2xfnPXyNz0LU4XbWrxSSLvlfiQXNa5R4kIWS772Y2v/PzarvL1CZwlQ3ncX gF/W4TFpJ9tp9POhFUzZNxBNG6UigWDtwdfRiLunK/w+ZnloeNvo9gGaaJssBjnhWZdf c8vgt+uEnYyNW5UD0GFbTbsJxqIz+0l6q0yf8JQDMmCCHeJY9XtdxjrS0Dv+/a1SEDJj 4DR3ZHldsER+mxlX2RO/2buHUIcp9EE1zPm3mitGBxZ0K3kp6P9bSMSJ8WrF/wjqk3fs qFwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Vn3QOWB/"; 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 q13-20020a635c0d000000b0042c87a0ea5bsi13875142pgb.175.2022.09.06.08.09.33; Tue, 06 Sep 2022 08:09:44 -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="Vn3QOWB/"; 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 S241790AbiIFOWH (ORCPT + 99 others); Tue, 6 Sep 2022 10:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241975AbiIFOTJ (ORCPT ); Tue, 6 Sep 2022 10:19:09 -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 7B290832C5; Tue, 6 Sep 2022 06:50:15 -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 4D276B818D3; Tue, 6 Sep 2022 13:44:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95531C433C1; Tue, 6 Sep 2022 13:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1662471845; bh=jCbiulv3+SkkRMqoeGCKxedOr2kOBhDnFPmxoCl8K/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vn3QOWB/PhvBPJvdnbLSjXZuNEbmU/X35YoTpsaXLZeDMslO2VlS6cC35cEGH5NHD RSG5yb3ahLtAf4bhxpXjYp3ZPcBmOxnPb4CItWOIsWwlmCssIr/VMyBR7/+nh5v//F tQdJHdJTNUevb0lvugekTkNSVGRR8WgWBUDUkRHY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, stable , Zheng Wang , Dan Carpenter Subject: [PATCH 5.19 058/155] staging: rtl8712: fix use after free bugs Date: Tue, 6 Sep 2022 15:30:06 +0200 Message-Id: <20220906132831.873667553@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906132829.417117002@linuxfoundation.org> References: <20220906132829.417117002@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 commit e230a4455ac3e9b112f0367d1b8e255e141afae0 upstream. _Read/Write_MACREG callbacks are NULL so the read/write_macreg_hdl() functions don't do anything except free the "pcmd" pointer. It results in a use after free. Delete them. Fixes: 2865d42c78a9 ("staging: r8712u: Add the new driver to the mainline kernel") Cc: stable Reported-by: Zheng Wang Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/Yw4ASqkYcUhUfoY2@kili Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/rtl8712_cmd.c | 36 ---------------------------------- 1 file changed, 36 deletions(-) --- a/drivers/staging/rtl8712/rtl8712_cmd.c +++ b/drivers/staging/rtl8712/rtl8712_cmd.c @@ -117,34 +117,6 @@ static void r871x_internal_cmd_hdl(struc kfree(pdrvcmd->pbuf); } -static u8 read_macreg_hdl(struct _adapter *padapter, u8 *pbuf) -{ - void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); - struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - - /* invoke cmd->callback function */ - pcmd_callback = cmd_callback[pcmd->cmdcode].callback; - if (!pcmd_callback) - r8712_free_cmd_obj(pcmd); - else - pcmd_callback(padapter, pcmd); - return H2C_SUCCESS; -} - -static u8 write_macreg_hdl(struct _adapter *padapter, u8 *pbuf) -{ - void (*pcmd_callback)(struct _adapter *dev, struct cmd_obj *pcmd); - struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; - - /* invoke cmd->callback function */ - pcmd_callback = cmd_callback[pcmd->cmdcode].callback; - if (!pcmd_callback) - r8712_free_cmd_obj(pcmd); - else - pcmd_callback(padapter, pcmd); - return H2C_SUCCESS; -} - static u8 read_bbreg_hdl(struct _adapter *padapter, u8 *pbuf) { struct cmd_obj *pcmd = (struct cmd_obj *)pbuf; @@ -213,14 +185,6 @@ static struct cmd_obj *cmd_hdl_filter(st pcmd_r = NULL; switch (pcmd->cmdcode) { - case GEN_CMD_CODE(_Read_MACREG): - read_macreg_hdl(padapter, (u8 *)pcmd); - pcmd_r = pcmd; - break; - case GEN_CMD_CODE(_Write_MACREG): - write_macreg_hdl(padapter, (u8 *)pcmd); - pcmd_r = pcmd; - break; case GEN_CMD_CODE(_Read_BBREG): read_bbreg_hdl(padapter, (u8 *)pcmd); break;