Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp1357276ybp; Thu, 17 Oct 2019 11:33:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxhcmrgcmXQsQUEiFp5yznTBzYwh6Q52n5wkiEwFtuHHo0MJ6s0KE1bgq4dFrUMUW0G49dL X-Received: by 2002:a50:fe0f:: with SMTP id f15mr5225177edt.89.1571337218591; Thu, 17 Oct 2019 11:33:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571337218; cv=none; d=google.com; s=arc-20160816; b=wwgN5YGifrg4Ukas9r+LS6j2ZDv558974BXgEGIVvreDFy81C6191GgLQ9EPE7VZQn NjY904eFyIUfJ0FAjjjsOtIYl5hZ2uHRGDBzfDmd+TDGyCh0pEHSKbF9YrlM8G7S1hMr R+X4xdwMCZoldjlolD4pHTjDRZEKy8lCDDOvjZ9By8eUExsvkuP7BO0+4LIszo5Tgbq4 RvyasJnRP6g+6PBX7qwjFmuPagi45ho3y41KrMyQm3VKB0rD/sVY/R00cVhU5pld21s9 9djyyO/l7yEVHS6z8WJ78CYA/w3tEvWCrmoFu+XYLYFIj8oNC9In8Csm++y4JrYqncrc /VLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CqIuk9fO48x97YT9VJ6B2mp996ChN8Qj4am4rdNNvHg=; b=Hv87UCz+gFUHlniTTTKClo1i23bcQ/M/8VocbYbC48sqFY3Io8wBiwfqUj3kM3fczJ 6wf6XgdZ/PiwpBfbRfIGWHVz9lLQMrHwMiRT4r4AMw0j1biHUyNsQu77gIMZpLL8Zgea TlzDeh0cdKo5HVrFJIjgzZGvU5zw9W+SFuYldWyJkaD3XaifOwkjNDRIU05nfEjkPY5L EJYsY76lBVy4MyrtQTXQjho32Vq/OE8E9d72uKdtSh+jYdp8zMrjSiBtXzJFURHlO3ck o9LXb2P+G6NHIchwJ9CDqdBUbDxuxeZ5mgrOhI9h19DkRGtNumFzqQ7C9DDBUZSFe86x pR7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TFFzxXbe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wq10si1832636ejb.423.2019.10.17.11.33.15; Thu, 17 Oct 2019 11:33:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=TFFzxXbe; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407049AbfJPWHV (ORCPT + 99 others); Wed, 16 Oct 2019 18:07:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:51626 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406693AbfJPV6O (ORCPT ); Wed, 16 Oct 2019 17:58:14 -0400 Received: from localhost (unknown [192.55.54.58]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 861DE20872; Wed, 16 Oct 2019 21:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1571263093; bh=PAYf8s8/30odfXMIUrZmJ6XX6OBvHvz49VyVtIGCtdo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TFFzxXbegIxodqr3DU9JeIuYu+zi7IvEaTa5fZY4LYiewBOVr5k/EHPNqLu1uourA q9rj4AutjpiGWJLl2m0N3CwQYr6u0cltZHBdrW45KZ2ERjqOuTnVplhUVFQVWtKVk7 +d7TGs7MuOHgHfmB1Tz0CTHCgyynV7I9/2OMq3NE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+0243cb250a51eeefb8cc@syzkaller.appspotmail.com, Johan Hovold Subject: [PATCH 5.3 015/112] USB: adutux: fix use-after-free on disconnect Date: Wed, 16 Oct 2019 14:50:07 -0700 Message-Id: <20191016214847.953154975@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191016214844.038848564@linuxfoundation.org> References: <20191016214844.038848564@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johan Hovold commit 44efc269db7929f6275a1fa927ef082e533ecde0 upstream. The driver was clearing its struct usb_device pointer, which it used as an inverted disconnected flag, before deregistering the character device and without serialising against racing release(). This could lead to a use-after-free if a racing release() callback observes the cleared pointer and frees the driver data before disconnect() is finished with it. This could also lead to NULL-pointer dereferences in a racing open(). Fixes: f08812d5eb8f ("USB: FIx locks and urb->status in adutux (updated)") Cc: stable # 2.6.24 Reported-by: syzbot+0243cb250a51eeefb8cc@syzkaller.appspotmail.com Tested-by: syzbot+0243cb250a51eeefb8cc@syzkaller.appspotmail.com Signed-off-by: Johan Hovold Link: https://lore.kernel.org/r/20190925092913.8608-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/misc/adutux.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/usb/misc/adutux.c +++ b/drivers/usb/misc/adutux.c @@ -762,14 +762,15 @@ static void adu_disconnect(struct usb_in dev = usb_get_intfdata(interface); - mutex_lock(&dev->mtx); /* not interruptible */ - dev->udev = NULL; /* poison */ usb_deregister_dev(interface, &adu_class); - mutex_unlock(&dev->mtx); mutex_lock(&adutux_mutex); usb_set_intfdata(interface, NULL); + mutex_lock(&dev->mtx); /* not interruptible */ + dev->udev = NULL; /* poison */ + mutex_unlock(&dev->mtx); + /* if the device is not opened, then we clean up right now */ if (!dev->open_count) adu_delete(dev);