Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2846568rwb; Thu, 17 Nov 2022 17:30:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf7XY5QJplNysrVDYH89+oI5hCycxGx0KlUl5ELQ9X0Ns9RQ8T7hnrbSjv4oGu7RcGcTVGwa X-Received: by 2002:a05:6402:520b:b0:464:718c:b271 with SMTP id s11-20020a056402520b00b00464718cb271mr4312510edd.287.1668735004422; Thu, 17 Nov 2022 17:30:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668735004; cv=none; d=google.com; s=arc-20160816; b=TicN3O9ncBzcou216tMhA4w8DPOP4Qb8lcVgP54Wrmis74wQGVQxIPhgx5Je1SKQwL eTd+OJh0+0i68Va5mClP2swDPIQ85ZRkIK//xfhP0Fhm3IWQDIC3Hsvn5gN1frRMLqEp sDFgRcNudRTwgrsBLZl6HVlGlYNt4VRTV94BTvK4MUYNqiQ8biKy/T5CsT+2JvYlSNA4 MKYMOScX+pGLjbw5Kyg7NWRCXnSoAp6+oZ7KzpImHbaGgHdd6zNf9PcUhPfcUdbpUHFY 4k+KAQkW9yS+9vloDSLAPnBnLX1adJ2gs7nq3/Jd8ujgYJF/h1wFu0yc4Mi23EoTHl7i +YFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=OaUPbO6earlu9AsWr0Xwr8fyZn4kNeWtkN90s6Cvozw=; b=P65GijjljhdBOwgvuPBVJu745UE0lkC5OnBLtOoJt1TLG8jWkFvo5Pgcxo3O3ycZ/r nuU38mnOuANHUqerxipkMNRD83/OmlMpKTKDkP2OXVBh5GJF5BHDPwLrbxjlDJ31PBDD SdzhXMtypM9nmcqqo0zzkcV+43M0q5Kco+F7wuSPmGA7k66ovKDMAfdR/JhZooDvYqRA 1obS0Qhj9OD8S8st5BZcYfKzrNUwzb4fy5cpRJOEp312FwXKSUjETC6HdvXr824dSkfC T6clppESyoTe4ArdXf11QkbSmOtvZXqFFR4KGuKdcLKxTZIlzy+EZ4zkmKmLh+uk5FUn x54g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1v5eUZlI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wy4-20020a170906fe0400b0078cc8a2cf4bsi1768053ejb.614.2022.11.17.17.29.17; Thu, 17 Nov 2022 17:30:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1v5eUZlI; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233780AbiKRBSD (ORCPT + 92 others); Thu, 17 Nov 2022 20:18:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbiKRBSB (ORCPT ); Thu, 17 Nov 2022 20:18:01 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49727EAA for ; Thu, 17 Nov 2022 17:18:00 -0800 (PST) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668734278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OaUPbO6earlu9AsWr0Xwr8fyZn4kNeWtkN90s6Cvozw=; b=1v5eUZlIpmig19ckA5SJqANcOKrmCm2/exEzINHFwrbH3sUPmo9qtvAuSeu1GSuqGCK4Po meEIFhfFMMgnn0RV5eXFo2/YsCUG7mzZCcOR+0RNSgGFF9u/6EhtmGCGyCH28MhDSgA8eC O3sQqIq/IldNBHWkWPYcLETdTJHc1RAN9QiV+TCkx/hTdIS3Pcl4zC0rHAjouHNBCS7Ts9 HZJ+M3jfBsnwn7cyY8ebFeBWwkxM+Mj+8mp7eY5S+MgcLtz9Hv+qHXe+kLEGPKid+UgIRt oNsT203gSsH2KgC0zHnT0dR9xwXDkWK2eRJc8DLHD4wdBNTGsf2/IBqmPzlDBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668734278; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OaUPbO6earlu9AsWr0Xwr8fyZn4kNeWtkN90s6Cvozw=; b=Goj9ENaJOb6eZoB+ccPrZjC6xLaOeSHc0GkH7PN3v0NwXBzsVnY7LdniMtXDUb4OV7h1I/ DB+hl0IGnvCP29Dw== To: Tetsuo Handa , Luiz Augusto von Dentz Cc: Hillf Danton , syzbot , linux-kernel@vger.kernel.org, pbonzini@redhat.com, syzkaller-bugs@googlegroups.com, Steven Rostedt , Marcel Holtmann Subject: Re: [syzbot] WARNING in call_timer_fn In-Reply-To: References: <0000000000009d5daa05ed9815fa@google.com> <20221117024511.3606-1-hdanton@sina.com> <20221117125523.3783-1-hdanton@sina.com> <87wn7tlg4n.ffs@tglx> Date: Fri, 18 Nov 2022 02:17:58 +0100 Message-ID: <875yfdkqm1.ffs@tglx> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 18 2022 at 09:53, Tetsuo Handa wrote: > On 2022/11/18 6:16, Luiz Augusto von Dentz wrote: > The comment for drain_workqueue() says > > * Wait until the workqueue becomes empty. While draining is in progress, > * only chain queueing is allowed. IOW, only currently pending or running > * work items on @wq can queue further work items on it. @wq is flushed > * repeatedly until it becomes empty. The number of flushing is determined > * by the depth of chaining and should be relatively short. Whine if it > * takes too long. > > but why limited to "only currently pending or running work items on @wq" (that is, > only process context) ? > > Although drain_workqueue() is also called from destroy_workqueue() (which would cause > use-after-free bug if interrupt handler calls queue_work() some time after drain_workqueue()), > I think that we can wait for drain_workqueue() to call __flush_workqueue() again if a further > work item is queued from interrupt handler... Which is correct because at that point it's expecting to only accept the pending and chained pending work otherwise it will go on in circles and/or just be unable to provide the functionality of draining work, right? > Anyway, stopping all works and delayed works before calling > drain_workqueue() would address this problem. Only partially. You also have to make sure that none of the works can be rearmed or rescheduled after that point by any other context, e.g interrupts ... Thanks, tglx