Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp2267915rwi; Thu, 3 Nov 2022 15:01:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM73U4P5ys/j1nQisCxJxJYAud+NAuQyAreNo6lZEb207Dq5NF1B2tmHz4Ar/e4gT1rl3YxY X-Received: by 2002:aa7:cb59:0:b0:461:7378:7be0 with SMTP id w25-20020aa7cb59000000b0046173787be0mr32711352edt.60.1667512908818; Thu, 03 Nov 2022 15:01:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667512908; cv=none; d=google.com; s=arc-20160816; b=knjUzyTTlRHnQZ2MhwreFchwqQwHL8e9hicx56cm0bJmFYaTpEktJQUhpI3Mbx2rVv V0JzJIifpKDq+HOJhcOEIU5/wIWltxxz5tDJ9C0R5eqMKegOYr0R80Zy5OKmbiIlxyy3 txeg2nnl3VtUxFZcxD7rf5cEFp/BG2Jt+ZS1a6LM9Nli21qJJyzAi0z1mQJ0kItgYQlT nrLeUyF+cWeo5kFZvUA7G/Adq5QyltOC4zjHDj5CtwUH7+kJH0xbdw89Acnr+NIkDOc7 PhyeZ5OVn8d1cnWohGBK4dmxXLkfyHrO4F1/lyBoOzJ+28V7SUJzBp+Q684kBbtZJUyE tFdw== 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=kBEGbbUdit/QFBNEmaeSXTwWzKu/Ca3hXhrVRgsXBLs=; b=CpkCFMADX18I+y6y9U1v5nnEQykmPpQRcNsl3BjHUnRt9J3TIhXEmPiV0lhGyDoafa S0vCBazjYJpKfKpv5s1YSqRW1fXEeH7fvEdWAC8NdMFy2BmCd5G0NvEEP8Sl2ccqoKQ2 Cmh/hKmCi5aALKsZVFYm7FOHIzLjsHnD8RJHLcaVQwWnshnN6LJSwNarRS/ObF6uHyhV n6VXgQHjJNpJ83md7SZbKBWb4Dv6XjL3ma+h4/aVYrRH6g9ut/PAzJTzH74fZdTHSxvY WY5eYer5UTIQW68FtEScZHeSsInFhVU0fxre8JL8GUYxxSwrZ36mVhUufGdiEzhx6Mtx EadA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-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 g22-20020a056402321600b004592ebc28a9si2203167eda.59.2022.11.03.15.00.57; Thu, 03 Nov 2022 15:01:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231260AbiKCVv3 (ORCPT + 66 others); Thu, 3 Nov 2022 17:51:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56902 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbiKCVv2 (ORCPT ); Thu, 3 Nov 2022 17:51:28 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B4605C28; Thu, 3 Nov 2022 14:51:26 -0700 (PDT) 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 51FC962015; Thu, 3 Nov 2022 21:51:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D00C6C433D6; Thu, 3 Nov 2022 21:51:24 +0000 (UTC) Date: Thu, 3 Nov 2022 17:51:23 -0400 From: Steven Rostedt To: Paolo Abeni Cc: Jakub Kicinski , Linus Torvalds , linux-kernel@vger.kernel.org, Thomas Gleixner , Stephen Boyd , Guenter Roeck , Jesse Brandeburg , Tony Nguyen , "David S. Miller" , Eric Dumazet , Mirko Lindner , Stephen Hemminger , Martin KaFai Lau , Alexei Starovoitov , Kuniyuki Iwashima , Pavel Begunkov , Menglong Dong , linux-usb@vger.kernel.org, linux-wireless@vger.kernel.org, bridge@lists.linux-foundation.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, lvs-devel@vger.kernel.org, linux-afs@lists.infradead.org, linux-nfs@vger.kernel.org, tipc-discussion@lists.sourceforge.net Subject: Re: [RFC][PATCH v2 19/31] timers: net: Use del_timer_shutdown() before freeing timer Message-ID: <20221103175123.744d0f37@rorschach.local.home> In-Reply-To: <27a6a587fee5e9172e41acd16ae1bc1f556fdbd7.camel@redhat.com> References: <20221027150525.753064657@goodmis.org> <20221027150928.780676863@goodmis.org> <20221027155513.60b211e2@gandalf.local.home> <20221027163453.383bbf8e@gandalf.local.home> <20221027170720.31497319@gandalf.local.home> <20221027183511.66b058c4@gandalf.local.home> <20221028183149.2882a29b@gandalf.local.home> <20221028154617.3c63ba68@kernel.org> <27a6a587fee5e9172e41acd16ae1bc1f556fdbd7.camel@redhat.com> 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-wireless@vger.kernel.org On Sun, 30 Oct 2022 18:22:03 +0100 Paolo Abeni wrote: > On the positive side, I think converting the sk_stop_timer in > inet_csk_clear_xmit_timers() should be safe and should cover the issue > reported by Guenter Would something like this be OK? [ Note, talking with Thomas Gleixner, we agreed that we are changing the name to: time_shutdown_sync() and timer_shutdown() (no wait version). I'll be posting new patches soon. ] -- Steve diff --git a/include/net/sock.h b/include/net/sock.h index 22f8bab583dd..0ef58697d4e5 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2439,6 +2439,8 @@ void sk_stop_timer(struct sock *sk, struct timer_list *timer); void sk_stop_timer_sync(struct sock *sk, struct timer_list *timer); +void sk_shutdown_timer(struct sock *sk, struct timer_list *timer); + int __sk_queue_drop_skb(struct sock *sk, struct sk_buff_head *sk_queue, struct sk_buff *skb, unsigned int flags, void (*destructor)(struct sock *sk, diff --git a/net/core/sock.c b/net/core/sock.c index a3ba0358c77c..82124862b594 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3357,6 +3357,13 @@ void sk_stop_timer_sync(struct sock *sk, struct timer_list *timer) } EXPORT_SYMBOL(sk_stop_timer_sync); +void sk_shutdown_timer(struct sock *sk, struct timer_list* timer) +{ + if (timer_shutdown(timer)) + __sock_put(sk); +} +EXPORT_SYMBOL(sk_shutdown_timer); + void sock_init_data(struct socket *sock, struct sock *sk) { sk_init_common(sk); diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 5e70228c5ae9..71f398f51958 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -722,15 +722,15 @@ void inet_csk_clear_xmit_timers(struct sock *sk) icsk->icsk_pending = icsk->icsk_ack.pending = 0; - sk_stop_timer(sk, &icsk->icsk_retransmit_timer); - sk_stop_timer(sk, &icsk->icsk_delack_timer); - sk_stop_timer(sk, &sk->sk_timer); + sk_shutdown_timer(sk, &icsk->icsk_retransmit_timer); + sk_shutdown_timer(sk, &icsk->icsk_delack_timer); + sk_shutdown_timer(sk, &sk->sk_timer); } EXPORT_SYMBOL(inet_csk_clear_xmit_timers); void inet_csk_delete_keepalive_timer(struct sock *sk) { - sk_stop_timer(sk, &sk->sk_timer); + sk_shutdown_timer(sk, &sk->sk_timer); } EXPORT_SYMBOL(inet_csk_delete_keepalive_timer);