Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp463133rdh; Thu, 23 Nov 2023 08:32:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFXq+Xgb9tozKUkFO1hzwjT8dRCEtL5ZRbDnMcOL6fBDjMm7T4wpC4zgL0vK4UUa6HncpN0 X-Received: by 2002:a17:903:181:b0:1c6:21b4:30bb with SMTP id z1-20020a170903018100b001c621b430bbmr37601plg.15.1700757167933; Thu, 23 Nov 2023 08:32:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700757167; cv=none; d=google.com; s=arc-20160816; b=OmZkNX5OnE4dI/6F8bKIEZxySBQJbxBReZGpbA6y/Geg2IkG4GsnGiWvuWAFHTia+L hULwpyJd2kRySl+Wq24Z0MYrOOwF2yUHAJypGn5mrNqP3r80irOaszHPLGch24Ai67h+ 6mBFSdrv0MO4cza7E8A74z1LiyMSg14rOVzr4AKUCS+37xnbCVJPfY8FqyQxjMBxxrBl EIMleiDL6l8uxdHgFu7V0EXUjPGZUhu8aGhjwaSWpZduwBSxPyZxWAqr5AZJ4D2WR72L MAUPk47nQ0U6f7ngD3R9YghWdKOVToM2VTvgfmq2uyKtgo+6mK2ncgJlfHvIyJ1Uwdxh eEww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=kHnx14cr1yCK8qle9tu2EE/pgUOBSdUP8QNopUBV1ok=; fh=cECbmmbdlJ6lgVAvx+6QT1kGrdUwsUzK+M7vTYQhd/k=; b=vs3EYNeK78k+OgLUSav5dc60WLywHWoqI4ALFky2e7JIdIafuOhQKvUU+bw30kpZtU HUOQ9WoXGMBqbvf+VLnVqoodfXrCqQD1JeYQ5FmmdVCTWFuHibQt0Zy4BRWnDb1ux0qc PzGBad9JtxJDUTxDEsCRFRiLaoD/6FuIsGgG7kacovDhmnfei7KaywXF1H4MXjF+alo1 6sDyYEG53GDOtjF4d/8YlQgX/hRJ8pUqiTf1F3D6nnZ+7kKsZoC8F/Gx+wpqO1G5cmq/ h66bOt1f8x2+yV0y0et6rsvcXlNMnOLEfYtzNaMUqv+qWXkgcFr1Q5zLUdQbMcKgPEsC xjqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pTAB8MJV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id i18-20020a17090332d200b001c61bdd8e89si1476834plr.150.2023.11.23.08.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 08:32:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=pTAB8MJV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id B235A806676E; Thu, 23 Nov 2023 08:32:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229602AbjKWQcW (ORCPT + 99 others); Thu, 23 Nov 2023 11:32:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229462AbjKWQcU (ORCPT ); Thu, 23 Nov 2023 11:32:20 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5146810C6 for ; Thu, 23 Nov 2023 08:32:26 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-548ae9a5eeaso11926a12.1 for ; Thu, 23 Nov 2023 08:32:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1700757145; x=1701361945; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=kHnx14cr1yCK8qle9tu2EE/pgUOBSdUP8QNopUBV1ok=; b=pTAB8MJVLfCdKrBFt3EDg5XJN+BVkaCDpdEBi6MO4zb45FMBKy+MXcjfoRdWcpYcB6 9kHJ+ZHf/sBinz8UeEqoBleBmmzneFnTJcRxBtYx9Ht34zhCroTZoVgHibgyjrlTwIKB zQgsjxRdrFZFF/wBeDXXhhjpmDbxzrzA+Ln1VPP+hs5VAmbzU3BXaMCxpTLHYRcgtZRU NiWEo4aRf/qHUx3C/JXxXEyRfZI7C4mNIi0PnFpXhXxikU6xF2QdTy7ZJlFnPSHCHVJG 0+bhYEUmdICIRUuhX0dJr0GpDqRv097OgbWFkGy55fOOBL4zzJlMS7CSifvzSy+ZVUl7 m4hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700757145; x=1701361945; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kHnx14cr1yCK8qle9tu2EE/pgUOBSdUP8QNopUBV1ok=; b=JpIUJiCtXTJEn+KjwDmIcj833L3AKyK8qriDdPlOnhp1QQLEVKpYOI8kKKeutbj0OM PJ2hP6zbbonxS5NSReeL8TM0Xrt5TGm+wNuDapxbT1IQaaLHbk2yDYwe9hTDjtueN/th v02rV16u49LePQIaIwjsb99MOIoc/Y+I/Fal1izLZMivjN7zWAIvHLraerxqQg5A+DJI BdfKv5BRZq5niWomaY3YSeWhNcK2AHcAfVm5Cc7eBgEuE0O0nZPucApaAPOE9yVnabho 2IkWOXuSwP1znFDQL3ZAyBaHG+GojI18mnEEkBtuxY88lXvTNM1rPVCtYUfueGSd1BzY ee3Q== X-Gm-Message-State: AOJu0Yw/p2kL939JEEEkJ0q7h/c2ddBoP0hNxavckUGrjK8P/tX5t++L QlCN93Y3+d+kHWe7brFs6OVAXNCB6G8tV+wdAWV+QA== X-Received: by 2002:a05:6402:35ca:b0:544:24a8:ebd with SMTP id z10-20020a05640235ca00b0054424a80ebdmr390780edc.4.1700757144364; Thu, 23 Nov 2023 08:32:24 -0800 (PST) MIME-Version: 1.0 References: <20231115210509.481514-1-vschneid@redhat.com> <20231115210509.481514-2-vschneid@redhat.com> In-Reply-To: From: Eric Dumazet Date: Thu, 23 Nov 2023 17:32:10 +0100 Message-ID: Subject: Re: [PATCH v2 1/2] tcp/dcpp: Un-pin tw_timer To: Valentin Schneider Cc: dccp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org, "David S. Miller" , Jakub Kicinski , Paolo Abeni , David Ahern , Juri Lelli , Tomas Glozar , Sebastian Andrzej Siewior , Thomas Gleixner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 23 Nov 2023 08:32:35 -0800 (PST) On Thu, Nov 23, 2023 at 3:34=E2=80=AFPM Valentin Schneider wrote: > > Hi Eric, > > On Mon, 20 Nov 2023 at 18:56, Eric Dumazet wrote: > > > > On Wed, Nov 15, 2023 at 10:05=E2=80=AFPM Valentin Schneider wrote: > > > > > > @@ -53,16 +53,14 @@ void dccp_time_wait(struct sock *sk, int state, i= nt timeo) > > > if (state =3D=3D DCCP_TIME_WAIT) > > > timeo =3D DCCP_TIMEWAIT_LEN; > > > > > > - /* tw_timer is pinned, so we need to make sure BH are= disabled > > > - * in following section, otherwise timer handler coul= d run before > > > - * we complete the initialization. > > > - */ > > > - local_bh_disable(); > > > - inet_twsk_schedule(tw, timeo); > > > - /* Linkage updates. > > > - * Note that access to tw after this point is illegal= . > > > - */ > > > + local_bh_disable(); > > > + > > > + // Linkage updates > > > inet_twsk_hashdance(tw, sk, &dccp_hashinfo); > > > + inet_twsk_schedule(tw, timeo); > > > > We could arm a timer there, while another thread/cpu found the TW in > > the ehash table. > > > > > > > > > + // Access to tw after this point is illegal. > > > + inet_twsk_put(tw); > > > > This would eventually call inet_twsk_free() while the timer is armed. > > > > I think more work is needed. > > > > Perhaps make sure that a live timer owns a reference on tw->tw_refcnt > > (This is not the case atm) > > > > I thought that was already the case, per inet_twsk_hashdance(): > > /* tw_refcnt is set to 3 because we have : > * - one reference for bhash chain. > * - one reference for ehash chain. > * - one reference for timer. > > and > > tw_timer_handler() > `\ > inet_twsk_kill() > `\ > inet_twsk_put() > > So AFAICT, after we go through the hashdance, there's a reference on > tw_refcnt held by the tw_timer. > inet_twsk_deschedule_put() can race with arming the timer, but it only > calls inet_twsk_kill() if the timer > was already armed & has been deleted, so there's no risk of calling it > twice... If I got it right :-) > Again, I think you missed some details. I am OOO for a few days, I do not have time to elaborate. You will need to properly track active timer by elevating tw->tw_refcnt, or I guarantee something wrong will happen.