Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp609173pxj; Thu, 20 May 2021 17:45:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlNPO7YyEeH0o4NuHHbYJWJxIZOGu2kb1bB0GLLhrZ7XR1pxE/VbTOrCuTq184u0yVg9oz X-Received: by 2002:a05:6402:cb8:: with SMTP id cn24mr7678400edb.325.1621557949809; Thu, 20 May 2021 17:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621557949; cv=none; d=google.com; s=arc-20160816; b=yCkCS0dyQ8xkCkeaWtnyXiCn7ctAiVVwBb0FPCmA8Bo7IT9NBidZWK5eb1an0ZTeyN hP9liCFvB8Ur+4hgSJyQR0l3N/goLdnHtPjkhWFyZDCkQaVUgUprGaRsspul4Llx3YUN gJUhcNGAr4qAZt8DDBY9OlbRcpC2RHkjs2uI1+3Rem5vRxpOaY5w+6HxtrBLhnivXdAc 8apTn+7Enj+joR3c3GAZu8URa0EZpjjUhdFqNeh9anuqXcHfm0xryHyUQdCG9JsSeU9b coBDED34Qw8zIhRkqaFts5+oA0Mg2iA+jnzpw3pwIsQ/XGzOVGdaa9XvpcowQzZg1/w1 xD7g== 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=wLnnn5ittrPUMyrGjmhCAO9CRK260ybXHWJWRoQh0s4=; b=ql9aTNUmMDwYKm4qfIHrZ8xMpPJYEYsnbghe5wOv2Lm+wL0Bp+nzOjHNEAopNAM7TW X7CWLpvK2treyIHH84/gBbrd3HCQt1CwVcNvI5ogyGHQYR2QYZKO77uPAtc5Ce3VajR/ I3o71iuYslxU/UGdK7nIor4+9Emo2e4j9te+0Hb4lB8lTPz033wryErTPwV2jPTzeXtm Db8g/W9pNyCO3LHYT6M3JgE6QXfPFuLgO7qhV0xMohA7C0qFBNJOCXWFqG4FG3KA/jz/ AyVvAIbAMLbnsVYRVuSuDxGR6gb27XuqEcKXvPQgNqiAiz8GxWhXXjgiVR5vZvGMaagL T8zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=BV0xwm5F; 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 dp16si4666362ejc.200.2021.05.20.17.45.25; Thu, 20 May 2021 17:45:49 -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=BV0xwm5F; 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 S241024AbhETL25 (ORCPT + 99 others); Thu, 20 May 2021 07:28:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:47890 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239812AbhETLI6 (ORCPT ); Thu, 20 May 2021 07:08:58 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id BEF206193D; Thu, 20 May 2021 10:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505190; bh=vcXjnd0RVtjp9wv8OGxIBH6Btu3mKLehj10zJxynX8M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BV0xwm5Fy+KrwRgDIYuzFIOKgVSzgPqoZdDYBY6K5J/bQomZwdjPjnglgu+f5qOTl NZpjJKKOPfdr7rXfdCTBzl2an7MuhS2aukJg660WHx33ibFYhBXPPEt3zqYiMOVnq0 e2RVQEQvQjYE75bzphwQPZkRHV0P13wN/jFKVOVA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Yang Yingliang , Vinod Koul , Sasha Levin Subject: [PATCH 4.4 022/190] phy: phy-twl4030-usb: Fix possible use-after-free in twl4030_usb_remove() Date: Thu, 20 May 2021 11:21:26 +0200 Message-Id: <20210520092102.906269993@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@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 e1723d8b87b73ab363256e7ca3af3ddb75855680 ] 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/20210407092716.3270248-1-yangyingliang@huawei.com Signed-off-by: Vinod Koul Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/phy/phy-twl4030-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/phy/phy-twl4030-usb.c b/drivers/phy/phy-twl4030-usb.c index f96065a81d1e..168780eb29aa 100644 --- a/drivers/phy/phy-twl4030-usb.c +++ b/drivers/phy/phy-twl4030-usb.c @@ -753,7 +753,7 @@ static int twl4030_usb_remove(struct platform_device *pdev) usb_remove_phy(&twl->phy); pm_runtime_get_sync(twl->dev); - cancel_delayed_work(&twl->id_workaround_work); + cancel_delayed_work_sync(&twl->id_workaround_work); device_remove_file(twl->dev, &dev_attr_vbus); /* set transceiver mode to power on defaults */ -- 2.30.2