Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9178654pxu; Mon, 28 Dec 2020 08:32:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJyLfjPsMekSCMbl3OayKR2uwBWCt5qIQqII6/LGPYsNSN8HoSoQK9eyDPdFjO2fKZPBCOsB X-Received: by 2002:a05:6402:1a52:: with SMTP id bf18mr42730523edb.143.1609173123212; Mon, 28 Dec 2020 08:32:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609173123; cv=none; d=google.com; s=arc-20160816; b=coQHg0aX4xVc6t2FWvth1ZD6u1IpibkdjT/HjDMtRBeiYKCR/jtyhhG8sFqqna8neJ wo4IvP0VogiHtLv1NaSWI9CsBFafNlgJGF0zWiCAaJnO2/+q/NZT07Vrd21sIPmpVeW0 sQgcD2oDObiogMgruhA5EXNYtftuOxHVgmSxqpOCPSfJzjuosTqYRIU5NSiceCentow4 Jkrat2znGwLXqiMkLtwq9pCwaBSEVfUr38KIgw5Xd0eE9+R0dRClYl3Dq4tAp+V6fFIx VkC96pipSv19YfdQKACK7VUWRg9bRO4uHGtcWJHNXFr+8M2KEwZXY/nl5NUxCKXmVZL+ EA/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=CkoU3NiTS8Me2PrcXS8wE0LbSy+IwN9GZU/toeU0HB4=; b=L/ywDDAUq6/koKt1Baw5yGELRCu7h5g6xnZEm3TUdbsk3WfhFA6c836IQNI78c9cY5 phtQnUvNwh+CZzXMm9F2LmwoG1uiUlfdkBaUt6zO4gy16fhwGrIc2AjwuUfQnSCKsCRs dEaxO73n/7PHUE1Q4y4iB+d+0Ve1pPygW2TS/iKKSwHR9tXTrXgOjDBS0H/upzxs8AgM yz3RVXLPdM3cxaCNjwM9jw+PPQSWWd3zoRkCPKSkurZlXT+Gwxp1W3+nJwcbmC5/L76V n4c6RtOCWOI8Y57rAsaXgvfKIbtWVLAcO1Mx00L94jSRBeFCj8Sykl76SKF75rfRfdXA xpCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OsypLWfu; 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 b26si20261053eds.590.2020.12.28.08.31.40; Mon, 28 Dec 2020 08:32:03 -0800 (PST) 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=OsypLWfu; 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 S1730696AbgL1NHM (ORCPT + 99 others); Mon, 28 Dec 2020 08:07:12 -0500 Received: from mail.kernel.org ([198.145.29.99]:33888 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730708AbgL1NGF (ORCPT ); Mon, 28 Dec 2020 08:06:05 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6CC81208B6; Mon, 28 Dec 2020 13:05:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160725; bh=KOoJc5JTb36RPmNjEg6gF6NNmOD4K3nWpA6dERLmLYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OsypLWfuVRXRvy+LeZ4TeaYVpxFAxnGbsI5/5DwtnxZ7qdkwpDvzXHbuU05aEcouo on2vUBMq/bBylQBTSeQjjG4k/NiGxLkkkwfWvOd7pUeB1Owd/GlIq2RyCP69p3AUIT Vf4Zt66kQv/sHwFXhhqAC8wKYKIdAazxd1/ajybA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Andrzej Siewior , Johan Hovold Subject: [PATCH 4.9 148/175] USB: serial: keyspan_pda: fix write-wakeup use-after-free Date: Mon, 28 Dec 2020 13:50:01 +0100 Message-Id: <20201228124900.428847302@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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: Johan Hovold commit 37faf50615412947868c49aee62f68233307f4e4 upstream. The driver's deferred write wakeup was never flushed on disconnect, something which could lead to the driver port data being freed while the wakeup work is still scheduled. Fix this by using the usb-serial write wakeup which gets cancelled properly on disconnect. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Cc: stable@vger.kernel.org Acked-by: Sebastian Andrzej Siewior Reviewed-by: Greg Kroah-Hartman Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/usb/serial/keyspan_pda.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) --- a/drivers/usb/serial/keyspan_pda.c +++ b/drivers/usb/serial/keyspan_pda.c @@ -47,8 +47,7 @@ struct keyspan_pda_private { int tx_room; int tx_throttled; - struct work_struct wakeup_work; - struct work_struct unthrottle_work; + struct work_struct unthrottle_work; struct usb_serial *serial; struct usb_serial_port *port; }; @@ -101,15 +100,6 @@ static const struct usb_device_id id_tab }; #endif -static void keyspan_pda_wakeup_write(struct work_struct *work) -{ - struct keyspan_pda_private *priv = - container_of(work, struct keyspan_pda_private, wakeup_work); - struct usb_serial_port *port = priv->port; - - tty_port_tty_wakeup(&port->port); -} - static void keyspan_pda_request_unthrottle(struct work_struct *work) { struct keyspan_pda_private *priv = @@ -187,7 +177,7 @@ static void keyspan_pda_rx_interrupt(str case 2: /* tx unthrottle interrupt */ priv->tx_throttled = 0; /* queue up a wakeup at scheduler time */ - schedule_work(&priv->wakeup_work); + usb_serial_port_softint(port); break; default: break; @@ -567,7 +557,7 @@ static void keyspan_pda_write_bulk_callb priv = usb_get_serial_port_data(port); /* queue up a wakeup at scheduler time */ - schedule_work(&priv->wakeup_work); + usb_serial_port_softint(port); } @@ -733,7 +723,6 @@ static int keyspan_pda_port_probe(struct if (!priv) return -ENOMEM; - INIT_WORK(&priv->wakeup_work, keyspan_pda_wakeup_write); INIT_WORK(&priv->unthrottle_work, keyspan_pda_request_unthrottle); priv->serial = port->serial; priv->port = port;