Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp4895045rwb; Sun, 13 Nov 2022 16:35:11 -0800 (PST) X-Google-Smtp-Source: AA0mqf5iotv7uu0PrLzGjRz7TADjPKdvJ/aF4aJdb8QJqFk068OB3y/NYb1iHKqTeRgRW9GVjwFN X-Received: by 2002:a17:906:3a55:b0:78d:f2d8:4623 with SMTP id a21-20020a1709063a5500b0078df2d84623mr8917247ejf.274.1668386111583; Sun, 13 Nov 2022 16:35:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668386111; cv=none; d=google.com; s=arc-20160816; b=N3FBQ3v7dchKtB0Xcj/s9Zym8zUXcUbnrI270yiBiqT+6mVZY90yTG16xZp3pNXicU /+cdXv2BCKyPkNNHOa6Sf1ebJrEt4eGq2yztXZjYsSJr2BMVN/KFhP8p3th3oWekd0RG wHBhn6dyQO43QjyMkNQfJ3polbiSbBEZhBV4bmIJ47g+0wgue9touY4hm2Uzl+QTD2Dd ymmqaHzNxaHD0VE9Ed4wK7PLy/sdhkqQkjoCtT6fmyNbEO74KO+CvSeDrz6EA7b0zcoP n7UvkDOmeHmunpmgy4yInDhywe8/az6KEsezggSLflHFL23neuK9RCcCTef9Kr880R9b KrLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date; bh=SoiXyw4n/vN3z46Kd9qA2d1AN0bhZtJ1fdbzclQLT5I=; b=087XVba6mOrPTI03RRjlYsiP9yICy0PkU6grZyU1MioEKRk31NzxA8EdGtAkVNQVnV 454deA9bf1lE2hjn0Yds0lmAFwC5JjxZ6Ie6rGlvYPaTRZUMvH+r8DUA4EZPPjlG43I/ GciMtLb8sNage4pSveSIQbwCxBCa3Gxr4HmQ3ILMH8ZXi4BnuNkNapEqLl9ywFEahc50 aM4G3GUzzfx47/tPiG0qxxDVS4J9Md+vLxUMEoO+9mtkKj4ZRv6Ebsoirm9ueH1QkT3g wQolTJG7wcXCPeAxvu3e7iaWjgpRDHwTJDNGT29rkKO/yG6F/dHPmMOk0qFyMuASTqKl eUjg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q12-20020a056402518c00b0043e5ca9a0e2si6789518edd.628.2022.11.13.16.34.46; Sun, 13 Nov 2022 16:35:11 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235468AbiKNAPY (ORCPT + 89 others); Sun, 13 Nov 2022 19:15:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbiKNAPX (ORCPT ); Sun, 13 Nov 2022 19:15:23 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92483114B for ; Sun, 13 Nov 2022 16:15:22 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 325FA60DEE for ; Mon, 14 Nov 2022 00:15:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5E400C433D6; Mon, 14 Nov 2022 00:15:20 +0000 (UTC) Date: Sun, 13 Nov 2022 19:15:18 -0500 From: Steven Rostedt To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, Linus Torvalds , Stephen Boyd , Guenter Roeck , Anna-Maria Gleixner , Andrew Morton , Julia Lawall Subject: Re: [PATCH v6 4/6] timers: Add timer_shutdown_sync() to be called before freeing timers Message-ID: <20221113191518.0a3b29b1@rorschach.local.home> In-Reply-To: <875yfitpdu.ffs@tglx> References: <20221110064101.429013735@goodmis.org> <20221110064147.343514404@goodmis.org> <875yfitpdu.ffs@tglx> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,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 Mon, 14 Nov 2022 00:18:21 +0100 Thomas Gleixner wrote: > > @@ -1285,11 +1281,25 @@ int try_to_del_timer_sync(struct timer_list *timer) > > > > if (base->running_timer != timer) > > ret = detach_if_pending(timer, base, true); > > + if (free) > > + timer->function = NULL; > > Same problem as in the timer_shutdown() case just more subtle: > > CPU0 CPU1 > > lock_timer(timer); > base->running_timer = timer; > fn = timer->function; > unlock_timer(timer); > fn(timer) { > > __try_to_del_timer_sync(timer, free=true) > lock_timer(timer); > if (base->running_timer != timer) > // Not taken > if (free) mod_timer(timer); > if (WARN_ON_ONCE(!timer->function)) > return; // not taken > timer->function = NULL; > unlock_timer(timer); > lock_timer(timer); > enqueue_timer(timer); > unlock_timer(timer); > } > > //timer expires > lock_timer(timer); > fn = timer->function; > unlock_timer(timer); > fn(timer); <--- NULL pointer dereference > > You surely have spent a massive amount of analysis on this! > > Can you please explain how you came up with the brilliant idea of asking > Linus to pull this post -rc4 without a review from the timer maintainers > or anyone else who understands concurrency? I trusted the source of this code: https://lore.kernel.org/all/87pmlrkgi3.ffs@tglx/ -- Steve