Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3404048rwa; Tue, 23 Aug 2022 04:19:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR6cKMOUkBhe8gOw5XmsCTCz5W7n8Zn+OIe3XseAc0qfOKWTZ8jMi1kLC9vHcSrf6/E/RHC/ X-Received: by 2002:a05:6a00:148e:b0:536:4034:69cd with SMTP id v14-20020a056a00148e00b00536403469cdmr16799180pfu.84.1661253592946; Tue, 23 Aug 2022 04:19:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253592; cv=none; d=google.com; s=arc-20160816; b=zVotjfkEnwnim1GyedjLa4MJ7Fw0nxDVBwA6PzfYFymzbLtzb2z4LoTmrbmYJW9nYm IdkbyTSC3x4v29pzUfjkMNGXIfdNWHnnVTzZO41Ha/C9KUGHZ2Xd3f5FWaWegmCKm/LA AXo/Th7UdMyObHbpb0PLXzr5hsVswxdQQqy/J2d+NfLAz+2P9U+L9nbjpHgFIPtncu+s ZZLWSL5MTGInR3yrs1NiKwmROVWsP9Tltn4zGW54gotYQa7h3xVrHZXaSO5FL1PmX4Lb FK40q7WlOkmtvKufX4gavhStqxKorM8Q7LMMZK4iQTHJiWYBzzOnfly/9caMy/wr//zF hhMA== 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=G354L47AGRLZEVyIFntTP+qRmsKnl1ljqQ1UovFR1H8=; b=YZc0XWW1Zb52g+QyMTU6vxy4dfAuiw6ObTed/NprnsYgVznr6SkQBmYIBF09QpJGvx wD2LnQFQsZ3SMvtSUwh0Fl3qvK4tnFe0dENzVrTP+R4XvacJMAbYeKGsVaOe6acDbMww vnHjoN+N2Tf0tEyoVPqgGIn6egI7LZqVP0gRECEq/V+rwdB9mzlW7yqCk81SUACM+VE3 gr8lRZqx1I5To0W/GpAKnjwjA9UHnX6P0vitj/6ZMIGKpwKeIEt3EXNgwCHr6cOQI1CM 4AAMxyD4Jm6dQoxRBRG0lK74j2vioKiCzfrtcchHpuY1r50NJAk5dsmW6Z96iNC0z0HW DI8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=vcij6Hdq; 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 h185-20020a6383c2000000b0042ad04f3686si3324544pge.616.2022.08.23.04.19.41; Tue, 23 Aug 2022 04:19:52 -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=vcij6Hdq; 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 S1353795AbiHWKS4 (ORCPT + 99 others); Tue, 23 Aug 2022 06:18:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352593AbiHWKIM (ORCPT ); Tue, 23 Aug 2022 06:08:12 -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 6726C61DBB; Tue, 23 Aug 2022 01:54:33 -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 02E786150F; Tue, 23 Aug 2022 08:54:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0AF6FC433C1; Tue, 23 Aug 2022 08:54:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244872; bh=oJMCSW5rql9Q40OXoNYbb0n1b0xG0R5Y4bP304TLgHU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vcij6HdqAzdi5B3Ya1peIywjObds9WvHcOL5k8XPxq7xYqQ6+KpxvEE0yShw5uEvi UxH2GB6eNAAQOaCITRe92pp48U2yCMOfWh9HMDo6DRVL/sL8S3/xTaNOXF8i5tt0mj j6yywhpg4jpGia+GPUIObHNDhBIbTLMj7FyKoxvE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Frank Li , Faqiang Zhu , Sasha Levin Subject: [PATCH 5.15 165/244] usb: cdns3 fix use-after-free at workaround 2 Date: Tue, 23 Aug 2022 10:25:24 +0200 Message-Id: <20220823080104.723469870@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@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: Frank Li [ Upstream commit 7d602f30149a117eea260208b1661bc404c21dfd ] BUG: KFENCE: use-after-free read in __list_del_entry_valid+0x10/0xac cdns3_wa2_remove_old_request() { ... kfree(priv_req->request.buf); cdns3_gadget_ep_free_request(&priv_ep->endpoint, &priv_req->request); list_del_init(&priv_req->list); ^^^ use after free ... } cdns3_gadget_ep_free_request() free the space pointed by priv_req, but priv_req is used in the following list_del_init(). This patch move list_del_init() before cdns3_gadget_ep_free_request(). Signed-off-by: Frank Li Signed-off-by: Faqiang Zhu Link: https://lore.kernel.org/r/20220608190430.2814358-1-Frank.Li@nxp.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/cdns3/cdns3-gadget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c index ae049eb28b93..4bcaed787c0f 100644 --- a/drivers/usb/cdns3/cdns3-gadget.c +++ b/drivers/usb/cdns3/cdns3-gadget.c @@ -625,9 +625,9 @@ static void cdns3_wa2_remove_old_request(struct cdns3_endpoint *priv_ep) trace_cdns3_wa2(priv_ep, "removes eldest request"); kfree(priv_req->request.buf); + list_del_init(&priv_req->list); cdns3_gadget_ep_free_request(&priv_ep->endpoint, &priv_req->request); - list_del_init(&priv_req->list); --priv_ep->wa2_counter; if (!chain) -- 2.35.1