From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3ED93C43219 for ; Tue, 30 Apr 2019 12:00:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 025942075E for ; Tue, 30 Apr 2019 12:00:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625641; bh=hplInzEK2u4jRyTMgl9aER7j6CPUgDmKh8VJJamwZGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=q85q8gRS525Qs0LPikUJnVW3/8JE0opOUy9WvSxnLItMWtw1TRMesPmPb20rqzuiR UcPPaUKcc0DCQQvBAfToo0iY1sPdA/49e0tN4bD/F6Tm3fM5nDewy0al34P045wY2i xGbvTTbShuLINXmDaQ1OmSjbPhBpYkXNdFoA2ixw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728691AbfD3MAk (ORCPT ); Tue, 30 Apr 2019 08:00:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:58066 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729237AbfD3Lpk (ORCPT ); Tue, 30 Apr 2019 07:45:40 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 A798221670; Tue, 30 Apr 2019 11:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556624740; bh=hplInzEK2u4jRyTMgl9aER7j6CPUgDmKh8VJJamwZGw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cq1b4P+/XrHUf59OHpi+ZrCmhrclF5GptGO1J0GPhm5XSod++n5aRshb0agdfW5qH lNI18IAydzACN5dcsh03F8fHHansX8fyMBxAjZys5ZDddXqXn3bx2p6t2bRhtSAw5R b9Oqtv8EQGqMZi+JySCzmpaXmA/Wp7unwyEgLw/E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , Tejun Heo Subject: [PATCH 4.19 055/100] workqueue: Try to catch flush_work() without INIT_WORK(). Date: Tue, 30 Apr 2019 13:38:24 +0200 Message-Id: <20190430113611.541863454@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113608.616903219@linuxfoundation.org> References: <20190430113608.616903219@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: Tetsuo Handa commit 4d43d395fed124631ca02356c711facb90185175 upstream. syzbot found a flush_work() caller who forgot to call INIT_WORK() because that work_struct was allocated by kzalloc() [1]. But the message INFO: trying to register non-static key. the code is fine but needs lockdep annotation. turning off the locking correctness validator. by lock_map_acquire() is failing to tell that INIT_WORK() is missing. Since flush_work() without INIT_WORK() is a bug, and INIT_WORK() should set ->func field to non-zero, let's warn if ->func field is zero. [1] https://syzkaller.appspot.com/bug?id=a5954455fcfa51c29ca2ab55b203076337e1c770 Signed-off-by: Tetsuo Handa Signed-off-by: Tejun Heo Signed-off-by: Greg Kroah-Hartman --- kernel/workqueue.c | 3 +++ 1 file changed, 3 insertions(+) --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2908,6 +2908,9 @@ static bool __flush_work(struct work_str if (WARN_ON(!wq_online)) return false; + if (WARN_ON(!work->func)) + return false; + if (!from_cancel) { lock_map_acquire(&work->lockdep_map); lock_map_release(&work->lockdep_map);