Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9456579pxu; Mon, 28 Dec 2020 17:13:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJyO7BDP2nl5StPghTnTXvkb+ydcDlL8HzsFDvSJxPhVsRjlGcjqDanRC5lTaGfWURcKopwM X-Received: by 2002:a17:906:6a8a:: with SMTP id p10mr42216085ejr.169.1609204425433; Mon, 28 Dec 2020 17:13:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609204425; cv=none; d=google.com; s=arc-20160816; b=VOc5Ql2Pu7yhcAmK2uXaNqfBUPB0Y/LNF+Tfx/zqOoeg60lRpg74Ti4EK6KNpVSEPW AhIAzJJT3cEeDqchjVBguop7XWhEJ3uvoZNg5MF/oI2dfoIevsK2gTIzzf4EndWeCEmq wEJtoKaK7qrVDfVlUvFlHjoFE90mO0H8RRxq3aq395SD4M2DFrAfoIl8rBEoFS+3rwM+ XZo74KrgsPkUHpQ2yuCCmG+yW9Lvfp9wvPUUxvA3T+LrxCF3zGxkig4l5O9eGQxGTx4B /gEMh3QkNr7fPiCDJg/bPEbIW8QNCWuAYib5o+fgA9lLmVnYPGiz0pAaaxSaW/aso5sY 8CkQ== 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=w0sIr98zPUDeNIX2gN7B/g67ILTYKUViZjAVHilZBg0db8XjvxtGsMYd/HImKcdy6l OZRZbBBLBlMBDe5gl9RZBBPpTWNhAIqFOurixwYb2EUMpMNA42F4J7cVH56B4W2VhKEI QyGCudcwVrkK4/DacIXAnr+rCfzx9LYlb3oYInacUL4javoaYZABGRXjRvr7Q8TygwoL HjK30D3Ns8KDGUnacAAv0nEpomJAxzcrOpmIXo6EhTP1uOK/PG4TA2SjRiaWAzznsImI nUAvu1rB1hdGZf6749hf1FhKjsY7qC4C6Q9mZSy5sanp6uiRHhNV3RbTAxjhcsiKJni4 Musg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="0/o/gk9I"; 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 fy14si19234869ejb.227.2020.12.28.17.13.23; Mon, 28 Dec 2020 17:13:45 -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="0/o/gk9I"; 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 S2633726AbgL1Qob (ORCPT + 99 others); Mon, 28 Dec 2020 11:44:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:53240 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728323AbgL1M5Y (ORCPT ); Mon, 28 Dec 2020 07:57:24 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E377D208D5; Mon, 28 Dec 2020 12:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160229; bh=KOoJc5JTb36RPmNjEg6gF6NNmOD4K3nWpA6dERLmLYw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0/o/gk9IDTs1O+gQSbDLt/Pz5tDj2KfG2dXebwXpwtbEplH6MaIqw/kLyPleghLfE 2oqBODcE23fDoqnUSJXe1IpexD3ddbMrkOpgUjw+uCaVE+dPsxa1/bMfnGxmmQVoTI sLFLTqdjCU8O7XnbuCM2pm7+i6BsH7EX0+vW4kRc= 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.4 112/132] USB: serial: keyspan_pda: fix write-wakeup use-after-free Date: Mon, 28 Dec 2020 13:49:56 +0100 Message-Id: <20201228124851.827005376@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124846.409999325@linuxfoundation.org> References: <20201228124846.409999325@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;