From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 327C32FD69E for ; Mon, 29 Jun 2026 18:24:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782757494; cv=none; b=bXCt1iy80OxSzlzmIFGJPiJmBLyWFql4PDaGuZnu0GY9S4eg7UC3aSqFypGk0TWxiQE25FcShLSUiDvAikHGiWqPio87ksBF/2OJUhrV7ltlIhWqqn2y4pOK2lN9yPhkgYzHQ0Dpm+UD30dlQh9b3I4Uw9p43y1qmOeIt4MiLdI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782757494; c=relaxed/simple; bh=wD3MZbsN9jzINnVXN3GY8//2NKqq+BM9+4wJqBbMpj8=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=mryoYLRu06oIaTdgJaYTRnKVpDFK9SBEs42Ev4g+fXdYyee0PcoPZT+vAOqVd7TeklGooEZ1Zjq0Cgijp+AcOou7mOuZqo/QzlF/qHUW5fdg8woUyQz4oWVBebq/GQBxLiJFsCQYq2o1u7tfi+E8XyLfagA83zShhJzkhdwToRI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=fBso08I/; arc=none smtp.client-ip=209.85.210.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fBso08I/" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7e9c5830e22so1761443a34.0 for ; Mon, 29 Jun 2026 11:24:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782757491; x=1783362291; darn=vger.kernel.org; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=VgWBPgkIFq0GJmdrKvHCFz2V403YOlZzIZlCfT1y164=; b=fBso08I/obKfJVGigsaL/vbX5hEhW8hanNE2ztUwdOCwzJwbxm8RCiFve4x5RG5aX+ W1zP8ZjhaZQ1nuPmkSM5EL8GOI/ONNbOF16mSdKxkUmHvdpA3cYXpeaSU12eqGmREzGE a8nNYNwWGXA/vY1hMfFSbLgMb5yDRp0S+cXnEZhLKZY1so4vjagix6hb57+jqAh96lPn iY1FQIIbHsvgRwXWk321L2+bUdgzBS8KoQWCSsg9Tex2/58dEv9Kt2cx4PmABREnXugf eg7yadeV0sM2mL80e9Hio8tMusU6vunmUaEtT3NqgsnxciixeZ14DMBkAzI7I+GnA6c8 2nlw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782757491; x=1783362291; h=in-reply-to:references:to:from:subject:cc:message-id:date :content-type:content-transfer-encoding:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=VgWBPgkIFq0GJmdrKvHCFz2V403YOlZzIZlCfT1y164=; b=gNcJZGwkzMChHccCUwD0nnYu7FJUc5mxsNa+QUBpvl4MC9A8SnXOZaaRorfNPA5tJp djipbqkqIUzizFF4dZ+fTruhDizVD1LsVRdiCKZNt9mp7uHN03rjxAXYnm8Ux6bY7+xM Z0piWhqpDIJjM0aTo1+kId4LcEy0OEiPIArFnKaE3tZNJ67t4OdJV8e6ciA+ynYxiviu nKvm2F1LFrE/By/tHw3KkuizggYpHpf4vzP7OnrjlSqamr7lcUc3lgtHNSF1ejNfp/wB aLIfvDtmgp7iL/m7SjnxmKHHg5XB/nvc7V2J1UwM+jt9I4F6/FCzcQ6/Tl/pWJOmrAOc rKGA== X-Forwarded-Encrypted: i=1; AFNElJ/yK6PPHwmD0VsNqgeJcCf17ZkaVz3wYo0P4fMj63YJr62srcRh/EBRerA7rRy0k86rogRObdIr6Zgn8Ik=@vger.kernel.org X-Gm-Message-State: AOJu0YyvTpq5iPngHnCr4zje80B0HpOMyh6I5o3frfOCFViJQOLX4GjC pwBoer7f3N/5PNvm4gZHYsdpaG0K4PlpJwGPLyh+JjFGkUAnCerCIhA2 X-Gm-Gg: AfdE7ckBHgdJp3NbUfN2yg6yOh3S2inmFkxdHA9JJ9brXemqPADLfv44EyZUI9oLH2n pbiPAxDYDllVMKnxUnCw+pfeHhv/ccMUxjAitaroloUaIv4359+TVv6PIMhxp9msVzEX3jDNKKp x40VbwnkR7WTxERUC9beTqs2T/4Bz0HusYqkWqBcCKrB7yWJDPZa3kxUYBFupVbyZwdwalwyvg0 DCD3IkXzLxtVgN4DCGcOWBS8UyVdwUryS2fGI2PIROJ4bGMledCv6G8VC9WnskS9TYZZbdzf/qC h7kiK4Fr49Mbch3/j33aeBUlWZ0bRRR88xADFDzkRqmLEI3N1xnwXuUT1UWTTc9RcYD8SGLuK4x FgIeyLuYUaIep7oKlC9XnjI7J/73Z8+jy1ojYnK9gcViotV6Ce3Odh/ZImCA/SOYtS4lp+pqDv7 oRTabryoJKfB0HFSciY4ugo01YsIds0hn8ns9+uYHiqnHrICoUtpAcbXbBHjr3bSW4IncBhLktU wo8XXE= X-Received: by 2002:a05:6820:620:b0:6a1:5cd7:226f with SMTP id 006d021491bc7-6a1893f6428mr479536eaf.66.1782757491124; Mon, 29 Jun 2026 11:24:51 -0700 (PDT) Received: from localhost ([2a03:2880:10ff:4f::]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-6a18917194csm371263eaf.2.2026.06.29.11.24.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 29 Jun 2026 11:24:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 29 Jun 2026 11:24:49 -0700 Message-Id: Cc: "Martin KaFai Lau" , "Song Liu" , "Yonghong Song" , "Jiri Olsa" , "Stanislav Fomichev" , "Emil Tsalapatis" , "Lorenz Bauer" , "Jakub Sitnicki" , "Jiayuan Chen" , "Shuah Khan" , , , , Subject: Re: [PATCH bpf-next v3 1/2] bpf, sockmap: disallow update and delete from tc, xdp and flow_dissector From: "Alexei Starovoitov" To: "Sechang Lim" , "Alexei Starovoitov" , "Daniel Borkmann" , "Andrii Nakryiko" , "John Fastabend" , "Eduard Zingerman" , "Kumar Kartikeya Dwivedi" , "David S . Miller" , "Jakub Kicinski" , "Jesper Dangaard Brouer" X-Mailer: aerc References: <20260629172704.1302218-1-rhkrqnwk98@gmail.com> <20260629172704.1302218-2-rhkrqnwk98@gmail.com> In-Reply-To: <20260629172704.1302218-2-rhkrqnwk98@gmail.com> On Mon Jun 29, 2026 at 10:27 AM PDT, Sechang Lim wrote: > sock_map_update_common() and __sock_map_delete() hold stab->lock and call > sock_map_unref() -> sock_map_del_link(), which takes sk_callback_lock for > write. That gives the order stab->lock -> sk_callback_lock. > > The reverse order comes from the SK_SKB stream parser. > sk_psock_strp_data_ready() holds sk_callback_lock for read, and after the > verdict tcp_bpf_strp_read_sock() acks the consumed data inline via > __tcp_cleanup_rbuf(). The ACK goes out egress, where a sched_cls program > deletes from the sockmap and takes stab->lock: > > WARNING: possible circular locking dependency detected > ------------------------------------------------------ > syz.9.8824 is trying to acquire lock: > (&stab->lock){+.-.}-{3:3}, at: __sock_map_delete net/core/sock_map.c:42= 1 > but task is already holding lock: > (clock-AF_INET){++.-}-{3:3}, at: sk_psock_strp_data_ready net/core/skms= g.c:1173 > > -> #1 (clock-AF_INET){++.-}-{3:3}: > _raw_write_lock_bh > sock_map_del_link net/core/sock_map.c:167 > sock_map_unref net/core/sock_map.c:184 > sock_map_update_common net/core/sock_map.c:509 > sock_map_update_elem_sys net/core/sock_map.c:588 > map_update_elem kernel/bpf/syscall.c:1805 > > -> #0 (&stab->lock){+.-.}-{3:3}: > _raw_spin_lock_bh > __sock_map_delete net/core/sock_map.c:421 > sock_map_delete_elem net/core/sock_map.c:452 > bpf_prog_06044d24140080b6 > tcx_run net/core/dev.c:4451 > sch_handle_egress net/core/dev.c:4541 > __dev_queue_xmit net/core/dev.c:4808 > ... > tcp_bpf_strp_read_sock net/ipv4/tcp_bpf.c:701 > strp_data_ready net/strparser/strparser.c:402 > sk_psock_strp_data_ready net/core/skmsg.c:1174 > tcp_data_queue net/ipv4/tcp_input.c:5661 > > Possible unsafe locking scenario: > > CPU0 CPU1 > ---- ---- > rlock(clock-AF_INET); > lock(&stab->lock); > lock(clock-AF_INET); > lock(&stab->lock); > > *** DEADLOCK *** > > A tc, xdp or flow_dissector program has no reason to update or delete a > sockmap, and redirect does not go through here. Drop them from > may_update_sockmap() so the verifier rejects it. It also closes the > matching sockhash inversion. > > Suggested-by: John Fastabend > Signed-off-by: Sechang Lim John, please ack.