Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3224134ybt; Mon, 22 Jun 2020 19:00:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYWCN3TLzo7wxFNTThpsmG4fn37gOXwTm3g0qltfd2xkB5PCkjHF7Kbot+1lwAeRImgHsM X-Received: by 2002:a05:6402:1d96:: with SMTP id dk22mr20189464edb.258.1592877659123; Mon, 22 Jun 2020 19:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592877659; cv=none; d=google.com; s=arc-20160816; b=ZSuNTwr5YSFZ2wd39lsOKzqDOTYNibtjEqPydvwg++QwGFbqvA3T1KBeN+5ISZEx/i menZCm145eQmyZAFitxBqNOnlxV3NGpsscuHbr3wMHF21FxSjVi3+wWFc08k2j3wQoGo Z7rPajRkHNvHi2C8HBMyK70FnICAJOnxb+ZjjLIhgxf54zeSc1TyHy4D9YlpPw3AYBAc 9Ln25NJKFue2AT3mK/uapm3i0zQrUBxVSYHAn/2XZTeEnqqD8y3tRNPAb9n4NQMMoGHe 8d2EF4nugMUwyVMVEzoCgnUcnRUF8uRyaYnK3xBuIMMsqbW8VYdVDCMkbJ4MlFqNOB54 4Jkg== 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 :references:in-reply-to:from:subject:cc:to:message-id:date; bh=bVd89rFJSSpnBS4koh7ZQStV7RzVEP7cYbk/Ab/iO7I=; b=CtXuNIRPK509Tdu0LoWePj9+8vNi5HEp/k/ZAG+zmaAVJ8XDVWMVV/Gb8J4hUVf3Mn Cdl2uYDHLDn9wFZbWWmmcJUNpk22m4s+UNDuortW56veB4heUO6/wtSZDCUmQ83QjFIO ohNleX8M7rkzEiCxNRnV+AZQhIMGDqguzlPX+XRNSHPFaCSiGXdZI4VX2kVBMBoqctgM yyBoXb9nD7LCyl8h8F4LVVcWn5hpvGXnfUqbF37kAWW9SBO5FfoiroNDOMxb7Hk1ZDdp c8CRBDmwrldHzfy5Ao29pc+Qjw0QFiMrj8KEud0Ng6zkiDV38jdfFZOXnUHx8OsmvH9I VChA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bi11si11401259edb.544.2020.06.22.19.00.36; Mon, 22 Jun 2020 19:00:59 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730687AbgFVXey (ORCPT + 99 others); Mon, 22 Jun 2020 19:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730296AbgFVXex (ORCPT ); Mon, 22 Jun 2020 19:34:53 -0400 Received: from shards.monkeyblade.net (shards.monkeyblade.net [IPv6:2620:137:e000::1:9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFBA8C061573; Mon, 22 Jun 2020 16:34:53 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 4ED341297218C; Mon, 22 Jun 2020 16:34:53 -0700 (PDT) Date: Mon, 22 Jun 2020 16:34:52 -0700 (PDT) Message-Id: <20200622.163452.937354562065071557.davem@davemloft.net> To: tuomas.tynkkynen@iki.fi Cc: steve.glendinning@shawell.net, UNGLinuxDriver@microchip.com, kuba@kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] usbnet: smsc95xx: Fix use-after-free after removal From: David Miller In-Reply-To: <20200621104326.30604-1-tuomas.tynkkynen@iki.fi> References: <20200621104326.30604-1-tuomas.tynkkynen@iki.fi> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Mon, 22 Jun 2020 16:34:53 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tuomas Tynkkynen Date: Sun, 21 Jun 2020 13:43:26 +0300 > Syzbot reports an use-after-free in workqueue context: > > BUG: KASAN: use-after-free in mutex_unlock+0x19/0x40 kernel/locking/mutex.c:737 > mutex_unlock+0x19/0x40 kernel/locking/mutex.c:737 > __smsc95xx_mdio_read drivers/net/usb/smsc95xx.c:217 [inline] > smsc95xx_mdio_read+0x583/0x870 drivers/net/usb/smsc95xx.c:278 > check_carrier+0xd1/0x2e0 drivers/net/usb/smsc95xx.c:644 > process_one_work+0x777/0xf90 kernel/workqueue.c:2274 > worker_thread+0xa8f/0x1430 kernel/workqueue.c:2420 > kthread+0x2df/0x300 kernel/kthread.c:255 > > It looks like that smsc95xx_unbind() is freeing the structures that are > still in use by the concurrently running workqueue callback. Thus switch > to using cancel_delayed_work_sync() to ensure the work callback really > is no longer active. > > Reported-by: syzbot+29dc7d4ae19b703ff947@syzkaller.appspotmail.com > Signed-off-by: Tuomas Tynkkynen Applied, thanks.