Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2476321pxj; Mon, 10 May 2021 04:02:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxFaQOEDH75V+NiDTPYu9Ih9X38Ma6Zjr22xv9HHsMEQtnZgRn4mqpkcrPMdpgpVjdC/YQ X-Received: by 2002:a17:907:1b20:: with SMTP id mp32mr25531770ejc.495.1620644565528; Mon, 10 May 2021 04:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620644565; cv=none; d=google.com; s=arc-20160816; b=Il6WdVDDkwPolo6FeTjH9Jkj9upySQuI2Wd3lQ35oXlsv9o/2/cyYS+n2YOKqsbTm3 wb29S6gL9tQJzdR2NzGOiuHgpZJEI2O61RPTLj3oe5gqPw7zykhGfPjMFvfwIdW+oZFh xWJXbIBMAvEfnFMHyBidVR1tvRa8LJN9pw0Yvv4vxMSuAjUdl7UdcIA313kZHQhoVBr/ aMaXozHxsOcOo/rpRgbb45sUR2PkEehcvHsuXmntg02ETacQxpfc9cuXCtLx8yo7mu2T N5JPOEAzuZnHVqPaSwuSfhOHeD6u47DAQbKU3Mr0hTGlnK8FeiABji95KJkKFTESEoTJ k0Wg== 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=7sTUaPvs86auWscrtzMwSjD9ZNuS3rH9sJE8NAAMUZ0=; b=ZJlsh1lwevEWj2IkDTKvaasaSgiUVO8lgZ1f+95qe7iI85ug8DdkG8cjwWSDQvsBpI r9lpmZTdH/JhZJZWOV4LJNae7bTd2ZuR8lMXW6nz0kBi1idunWZErUXverJ92h1ou47X 18Jtfy0azhv1AQcikwu7RRuw+nI+TGDGQ3V8852sbrivKanGgH6i5jSXqZxrv0P5s/fs HpopHOAZtufeWSXBqrJ9Cs4Ra8SS50iQBQlKoJG8mzz2U/a1fNIJcL9Lss2lRu4LG9f9 ksgWO6UU/yQVjei650yroZkmk3Op+jN0DdlF4s8so0OvhRIwKTXlIa99ZvmqgY70enqL eZOg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=txW6tOMc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d18si13372320edz.163.2021.05.10.04.02.19; Mon, 10 May 2021 04:02:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=txW6tOMc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S231586AbhEJK5g (ORCPT + 99 others); Mon, 10 May 2021 06:57:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:59374 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233140AbhEJKpO (ORCPT ); Mon, 10 May 2021 06:45:14 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id ECEFF61879; Mon, 10 May 2021 10:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620642892; bh=ZSqH0HKaES/cRWmAqrfBEeb5+bXwFPujDyAIfNZi+lw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=txW6tOMceqjDZQLYTiUnAMS3jCKXFWtkTmRuDx0DUYJt9/9d+dUk14+CYfuFmHKnL +hGbUQUdK+8INuwMxs8IekTZLTMrTlhW0c7DywJajb1KiossdnED2GaQJmOj5eTeq3 nmEKlKNOoIcySr6zE8wByKeRXh0lihCdmbg8QBPo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , Sasha Levin Subject: [PATCH 5.10 095/299] usb: gadget: tegra-xudc: Fix possible use-after-free in tegra_xudc_remove() Date: Mon, 10 May 2021 12:18:12 +0200 Message-Id: <20210510102008.079664045@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210510102004.821838356@linuxfoundation.org> References: <20210510102004.821838356@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yang Yingliang [ Upstream commit a932ee40c276767cd55fadec9e38829bf441db41 ] This driver's remove path calls cancel_delayed_work(). However, that function does not wait until the work function finishes. This means that the callback function may still be running after the driver's remove function has finished, which would result in a use-after-free. Fix by calling cancel_delayed_work_sync(), which ensures that the work is properly cancelled, no longer running, and unable to re-schedule itself. Reported-by: Hulk Robot Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20210407092947.3271507-1-yangyingliang@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/gadget/udc/tegra-xudc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/udc/tegra-xudc.c b/drivers/usb/gadget/udc/tegra-xudc.c index 580bef8eb4cb..2319c9737c2b 100644 --- a/drivers/usb/gadget/udc/tegra-xudc.c +++ b/drivers/usb/gadget/udc/tegra-xudc.c @@ -3883,7 +3883,7 @@ static int tegra_xudc_remove(struct platform_device *pdev) pm_runtime_get_sync(xudc->dev); - cancel_delayed_work(&xudc->plc_reset_work); + cancel_delayed_work_sync(&xudc->plc_reset_work); cancel_work_sync(&xudc->usb_role_sw_work); usb_del_gadget_udc(&xudc->gadget); -- 2.30.2