Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp278029lqp; Wed, 22 May 2024 04:34:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCU2Sl55dPjXgRspfZuc6J/KxWAtMNmOyeNGCKr2doBWl4kb1Cpmoz07Jul8R55yDJ19s8feke6kfBIuVv640w6/LZT4SVTLHERw4ecfZQ== X-Google-Smtp-Source: AGHT+IHzSTTYtqEc6mKh8afQtjAOObStvRohNQNZDNt2fgR90G/g2m0YdDSsGu/nGfeMCVBBUyGl X-Received: by 2002:a05:6a20:dd86:b0:1af:d017:c14b with SMTP id adf61e73a8af0-1b1f87f8a0bmr1666065637.30.1716377689529; Wed, 22 May 2024 04:34:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716377689; cv=pass; d=google.com; s=arc-20160816; b=zlR7cyohcFqpFxK36ps7p8X1KbtIWDmuG4sqKN06ZvRjNC8F0bHQUWXJ8NgQzMX+OJ cCYK/FVep1FkfIMtiNOqk0Rc3/ehxlIucMKgMHfS5FAL1XVIJDw2t66PzkLOUp8dYN05 eUrDDiK7Q4Wceuc5DWLHMljtZTvyNJpujzyB9EIz8DcrxSOeCMx7DsQiHoK3WgEosFaj Y2z+m9XimRCTRU1+Q56PARFR28krVgdK3jZn3wutDrIABaik+7g/d4vKE0Jpl1IpxN6G xslQt98wDJc9GC2lcLPaoftTq2rgyJz73B0PhDBMKSOpw3wASJ6QzCPuiRAdvgpmt/ds kQig== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Fycn84WCB5YI73qNuPYMq3B3okQP8jmSiOROYbKsWdU=; fh=q5gNkNOHysRbRWOrUsgmvf/wrai7WP9UDMD3Kq1bf7U=; b=bGvYm+jQzxpovhEcrewcADQpB68Z3yMLmM1zuq6bYya8wcf7/MDh8eLWNdbyFmPuTH H+UcbnbGxq8+peGU+EfBshgouzbEUByW5b4YPzBS3lU8Os9YL6iKkyF6CYYlCJSfuxzb HtgQXagKZ0g0XKEgiuS2T+TaxQQ+F+e3vdyBpP5nQRvCjULL+OA2PFAZxQO56MFnxLRP nWSO/cntBm5TEThqglAB/E58fcYoLgII2dNy8sWH+a9xnCP2LUEcuTgYje2o9PZNDgP6 0Blsi+pIXvdpvg9TRaGfDrOc3NBKwhdbIchtIZPGMcR0rbp+D6AqTJZG2EtbtwcV/HDe nU5w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-186145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186145-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 98e67ed59e1d1-2bd92b3c80csi3068712a91.182.2024.05.22.04.34.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 04:34:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=sina.com); spf=pass (google.com: domain of linux-kernel+bounces-186145-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186145-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 30705283783 for ; Wed, 22 May 2024 11:34:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 12CC482871; Wed, 22 May 2024 11:34:44 +0000 (UTC) Received: from mail115-171.sinamail.sina.com.cn (mail115-171.sinamail.sina.com.cn [218.30.115.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E80F656B72 for ; Wed, 22 May 2024 11:34:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=218.30.115.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716377683; cv=none; b=WEElSdC/qIS7nV+wUAQW3TVn7h+dXtW38Glo7YKXqC7EsgSj4OOlTVVO5iezwW/ze6Ckbj1aycMdXEaMjcGl2o39wTUkjhCescI17P+stQWhsSvTZnPupLsnMmwTYiLFhpHj8GhxTmlD2YjxPebR+2GqJCO+9l1vOATs0wtnwzw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716377683; c=relaxed/simple; bh=lH6KbgxQ/zhQaHHB/tshrEoyjiCr4O+1LfFZ/Ly2bCw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rJy0L+78gHENWjm3v2WNsMKp6y+l+mPfLBwHJJCPZ3QayRqtNPlSSdKq9hFbm+myYHO1pUsSwXGS0OHP2ppAFEpq6cuQt2cp1d9QqGzGvMRoTlyoL86GCq1zuCPnmKmFKBXM/qimt7q92XpduxhfwEUnLshrRVyx3MvA5P1JhfA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com; spf=pass smtp.mailfrom=sina.com; arc=none smtp.client-ip=218.30.115.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=sina.com X-SMAIL-HELO: localhost.localdomain Received: from unknown (HELO localhost.localdomain)([113.118.71.62]) by sina.com (172.16.235.25) with ESMTP id 664DD8260000282A; Wed, 22 May 2024 19:34:00 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com Authentication-Results: sina.com; spf=none smtp.mailfrom=hdanton@sina.com; dkim=none header.i=none; dmarc=none action=none header.from=hdanton@sina.com X-SMAIL-MID: 70485834210399 X-SMAIL-UIID: FADD444D6EE443508E86F8EBE03CEA13-20240522-193400-1 From: Hillf Danton To: Jakub Sitnicki Cc: Alexei Starovoitov , Tetsuo Handa , Eric Dumazet , Linus Torvalds , bpf , LKML Subject: Re: [PATCH] bpf, sockmap: defer sk_psock_free_link() using RCU Date: Wed, 22 May 2024 19:33:49 +0800 Message-Id: <20240522113349.2202-1-hdanton@sina.com> In-Reply-To: <877cfmxjie.fsf@cloudflare.com> References: <838e7959-a360-4ac1-b36a-a3469236129b@I-love.SAKURA.ne.jp> <20240521225918.2147-1-hdanton@sina.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Wed, 22 May 2024 11:50:49 +0200 Jakub Sitnicki On Wed, May 22, 2024 at 06:59 AM +08, Hillf Danton wrote: > > On Tue, 21 May 2024 08:38:52 -0700 Alexei Starovoitov > >> On Sun, May 12, 2024 at 12:22=E2=80=AFAM Tetsuo Handa wrote: > >> > --- a/net/core/sock_map.c > >> > +++ b/net/core/sock_map.c > >> > @@ -142,6 +142,7 @@ static void sock_map_del_link(struct sock *sk, > >> > bool strp_stop =3D false, verdict_stop =3D false; > >> > struct sk_psock_link *link, *tmp; > >> > > >> > + rcu_read_lock(); > >> > spin_lock_bh(&psock->link_lock); > >> > >> I think this is incorrect. > >> spin_lock_bh may sleep in RT and it won't be safe to do in rcu cs. > > > > Could you specify why it won't be safe in rcu cs if you are right? > > What does rcu look like in RT if not nothing? > > RCU readers can't block, while spinlock RT doesn't disable preemption. > > https://docs.kernel.org/RCU/rcu.html > https://docs.kernel.org/locking/locktypes.html#spinlock-t-and-preempt-rt > > I've finally gotten around to testing proposed fix that just disallows > map_delete_elem on sockmap/sockhash from BPF tracing progs > completely. This should put an end to this saga of syzkaller reports. > > https://lore.kernel.org/all/87jzjnxaqf.fsf@cloudflare.com/ > The locking info syzbot reported [2] suggests a known issue that like Alexei you hit the send button earlier than expected. 4 locks held by syz-executor361/5090: #0: ffffffff8e334d20 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:329 [inline] #0: ffffffff8e334d20 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:781 [inline] #0: ffffffff8e334d20 (rcu_read_lock){....}-{1:2}, at: map_delete_elem+0x388/0x5e0 kernel/bpf/syscall.c:1695 #1: ffff88807b2af8f8 (&htab->buckets[i].lock){+...}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:356 [inline] #1: ffff88807b2af8f8 (&htab->buckets[i].lock){+...}-{2:2}, at: sock_hash_delete_elem+0x17c/0x400 net/core/sock_map.c:945 #2: ffff88801c2a4290 (&psock->link_lock){+...}-{2:2}, at: spin_lock_bh include/linux/spinlock.h:356 [inline] #2: ffff88801c2a4290 (&psock->link_lock){+...}-{2:2}, at: sock_map_del_link net/core/sock_map.c:145 [inline] #2: ffff88801c2a4290 (&psock->link_lock){+...}-{2:2}, at: sock_map_unref+0xcc/0x5e0 net/core/sock_map.c:180 #3: ffffffff8e334d20 (rcu_read_lock){....}-{1:2}, at: rcu_lock_acquire include/linux/rcupdate.h:329 [inline] #3: ffffffff8e334d20 (rcu_read_lock){....}-{1:2}, at: rcu_read_lock include/linux/rcupdate.h:781 [inline] #3: ffffffff8e334d20 (rcu_read_lock){....}-{1:2}, at: __bpf_trace_run kernel/trace/bpf_trace.c:2380 [inline] #3: ffffffff8e334d20 (rcu_read_lock){....}-{1:2}, at: bpf_trace_run2+0x114/0x420 kernel/trace/bpf_trace.c:2420 [2] https://lore.kernel.org/all/000000000000d0b87206170dd88f@google.com/ If CONFIG_PREEMPT_RCU=y rcu_read_lock() does not disable preemption. This is even true for !RT kernels with CONFIG_PREEMPT=y [3] Subject: Re: [patch 30/63] locking/spinlock: Provide RT variant https://lore.kernel.org/all/874kc6rizr.ffs@tglx/