Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4811892yba; Tue, 30 Apr 2019 04:55:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqyD1kn5H3EWQ8/xBcqsaVsFWjzOEeaGk/XJZfMg8SOh3bXrmmfYuISH7GxU6dSVLmOHVEB7 X-Received: by 2002:a17:902:e283:: with SMTP id cf3mr28135245plb.160.1556625338085; Tue, 30 Apr 2019 04:55:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625338; cv=none; d=google.com; s=arc-20160816; b=vyH4bUHMKKKYNaM/ksSNu5zIISdDjAPgNILbAzB3P1aqJlgQx/I8hrYL0lU+47svbQ Wn9m5cyARQDVCCHxtC1d8Rf1LyaW7JaK8b4vykzDe+Gq5lQ/lS4C0G1uOcSZm5RS8nW9 V5o2ZdkRBePtU5YABI1We1Ht8AplB8JQeGMh0JR5ypVIRiCXoYN7NlUmQh+d2ysmy+Tp lMCFUcmRdTLDfo6mmIiObZ4HZV4LgaV3rM74/JrI632nucq69V5hndm7QxyYdKn7o3is Fnz489CB39h5E8wPkSWCmwQ2AoCLUpAYv6JMrF4AJG3GyI4hKWtQSRHNjFCEA1uwxmbI FkTw== 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=lpcuCTh4MWdDSLvZDwU3t33MLrv//dMjCA96vu9r45c=; b=F9d82jyQjYFELUN8Wpv1+G5lMD8zkkOQVgV15XNKrpyyfZ4t7KX1PqrNQZx4VNpsBJ dqVD1mhngIj5ZxcXScOaH4U5nmNj9yp82TMhpXdJffKyBB8fq2IUaJaNaQ1LBTdqIfBl I0ZYa1JVKToR7XXUV59hh3Y0SdkxaqN/4iJewl/lKTiozaFYI1R+FM5GRpIqobIz1DTK nPg/Q6L1yiUmx5SfWCMiUDYkMZNKwQ/gj45/eNmg9W5wMR74JjQS4j2TjgSLRS41SyZw rcqpiBzrxdzQ6eYabFmTZCBbM+WguTeqU1CM4PrbewWbtJywZNf+he4hivVsfvFOHNj9 8Q0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CVXjJ6ZJ; 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 e3si35295576pgc.98.2019.04.30.04.55.23; Tue, 30 Apr 2019 04:55: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=CVXjJ6ZJ; 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 S1729026AbfD3Lwd (ORCPT + 99 others); Tue, 30 Apr 2019 07:52:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:39404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730475AbfD3Lvd (ORCPT ); Tue, 30 Apr 2019 07:51:33 -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 5620E2054F; Tue, 30 Apr 2019 11:51:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625092; bh=wvkeDZFULudm6VnfULGjkMBtkwZGugK3mgVamZUMmBA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CVXjJ6ZJfj7ox2eoAUFRJGZapK6STuft4B1Dh2YpNVl9UrdEer3fiMMk/+6ejhKs7 qewEA9P0ELNfFu6qI7YFP3lWn2UadTAAfn5R6dlhOJrxdAItgbDxJvPGMUDcJY64uV t+2FRccA42ALdMsoX3hO87OzmYtx0iY2lY2wagHw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tetsuo Handa , Tejun Heo Subject: [PATCH 5.0 52/89] workqueue: Try to catch flush_work() without INIT_WORK(). Date: Tue, 30 Apr 2019 13:38:43 +0200 Message-Id: <20190430113612.128748223@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@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 @@ -2931,6 +2931,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);