From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 5A54A3BFE31 for ; Fri, 26 Jun 2026 21:43:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782510193; cv=none; b=ntfuDzFMf6mgeAgyTXeou0gwLjZfFQlTn+PTaTpvayBC3+OqegCFs5eBecwt2DJNmEmFg/UQppLkJNpQ8Ul+z6jkVt1IQQXt+LLIIihij/0NrJlR/SSpnCaOmZqhdmldRlQrDBLa3a0mEwcgwDLilY6w5rckYhyUX5IYM4BscbY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782510193; c=relaxed/simple; bh=ojAE35OYkjQ5Ta8z6j4eofFJGg/eZvKv0lvdydmDurE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Jnc1a5Za396gK5wBXRkguLbvG9MtD6WdDvthOQeZDsP43hhLPYtxndVao5HjBH4zRlDOFdaD6KaJqaSNfcJkwABP0inGkujVf0FI7s8u8OWQU4rGmanHRxgY9O9mCx/xm4GUc+wsXq9aTyf4te3MHyVJw/XFXofD7QPS63y0Joo= 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=HcneWN+f; arc=none smtp.client-ip=209.85.214.173 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="HcneWN+f" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-2c7f11646c3so10801185ad.3 for ; Fri, 26 Jun 2026 14:43:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782510191; x=1783114991; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=87C0TqpdzgkT/i/TbUSL1BACHUANW3mTasT2WjTMKNM=; b=HcneWN+fJdEfejOPPPUTcHeKO/vUZ9Guakon5GWvyWePOGM5IErTddkOzEO74lcBHx NMpjuWUaCLc5RT9aSkJX7V47104iURHwxtkfu47J/FoLJjdBhh2VfbiK9HHTdGvMXL6J tyoNc9aoYgqTe7GZoGjUrQE/Jl0LSE1Nu9WNAtOUgfoYSr0wFyhR2PSMPDzAqPl5Yk8c Tlyw/yE+YRcISrKvpDeO7t13k1xHJm19emABGmf3WSY4M7Q6bS7Oiz8lUgvMA9nSeXBS B2DODMNF8JmPnEm6z38Eyu3B3/vXIJsLlsuR2dutgKqR2XmgNK5wrxWe3y5IDR5zf8P5 Z9Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782510191; x=1783114991; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=87C0TqpdzgkT/i/TbUSL1BACHUANW3mTasT2WjTMKNM=; b=APVvPwtPvEXSUhlkPWlwaAPS2h5E0I69I3st6Em2H+//silsBYuYi9ycUYKPrNmu5M 3mZ7MNbbRTCkAFpvmwoRMcxXtPBrxUeX9EWPenDbyR0GuVGS+MBXzG0ti4Gd6djS9JBw A4NeW0UQs9MOdK8TZm7+Zs+0Jyz4VWA5p1U69lKpKhKXmS7u5A7cDbcWXbtIq0clGqNc ur4KseYltmYJRAObKjxIYlrdiGsQ0U62ikTFU4m32QiYVZnKyS3F1bPa10rpUHNfNfva 5939DMmfghqU1vajxXkI08z5sxbH1lXScnVuy10OCWzrgveEZSDS1IIRXONKLj8Zds+J QsNw== X-Forwarded-Encrypted: i=1; AHgh+Rpxl20yOUad+2v7c51r4qN8JbCwjOj5GEmx1TXPLi4XVuW/VGXN/be+Pco3SrnyzJm48D+8+XTRO0UPioQ=@vger.kernel.org X-Gm-Message-State: AOJu0YxeA746p1saZuZwVcp5Rjf8Iz4XDpD7Gy4uGEYv3YSgnbeyo70I BKCXZNjyI+QDINSvIzkZGkkNRP5Zlx/CvBJ79sbKMYZWqhKLJGzrs1qr X-Gm-Gg: AfdE7cnLL/ib/wK3LFIPeA6EeikVAq9DwzQ87ivLs5y/NfuFZEc+kUiW5958IeThYPA CgHV71mZowegpGQQ7EmOWxL1ZkVuXbYDThxX2z1UMbclsUoH3qUeh7UiWsX6DLx4T236o/R89Kl 02cyKNoMK3KnlR9Jag+DxuUhhg3O2Aqms6ahvOQ+zuTsrS0eXUhxCidNDINDhpeHAKH5zbagodc CNMiOsUlBtooxO3tuCptSzizqKamwc2MMFgYR0C3rn7TfhV2YQNLqHc2l7O+1ATx/fHXbEVQwGm Padnu6o6hmwiDbL+/BRXxJY6/tQMrKHLSW/zR3Ko4Fed6C67c6HDch2VxwbMNCS9ttxh0GT1De8 p/3Ugo2kndbDRXqf3iKC091iTy8q70Vx6ecuKIBsVwmm8VpkcnJzRM+Mv0U2SYmSLnFsyIjfL+a 3K/5cTLVd/EKw= X-Received: by 2002:a17:902:e78e:b0:2c4:608:167c with SMTP id d9443c01a7336-2c7fc663951mr79432975ad.6.1782510191468; Fri, 26 Jun 2026 14:43:11 -0700 (PDT) Received: from john-p8 ([98.97.43.120]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2c7f5ae2092sm46078615ad.20.2026.06.26.14.43.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jun 2026 14:43:10 -0700 (PDT) Date: Fri, 26 Jun 2026 14:43:08 -0700 From: John Fastabend To: Jakub Sitnicki Cc: Kuniyuki Iwashima , Michal Luczaj , Willem de Bruijn , Jiayuan Chen , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Alexei Starovoitov , Cong Wang , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Shuah Khan , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH bpf 1/2] bpf, sockmap: Don't leak UDP socks on lookup-bind-release Message-ID: References: <20260623-sockmap-lookup-udp-leak-v1-0-05804f9308e4@rbox.co> <20260623-sockmap-lookup-udp-leak-v1-1-05804f9308e4@rbox.co> <87wlvoxdq1.fsf@cloudflare.com> <87o6gyyjxk.fsf@cloudflare.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <87o6gyyjxk.fsf@cloudflare.com> On Thu, Jun 25, 2026 at 12:48:55PM +0200, Jakub Sitnicki wrote: >On Wed, Jun 24, 2026 at 02:39 PM -07, Kuniyuki Iwashima wrote: >> On Wed, Jun 24, 2026 at 2:33 PM Kuniyuki Iwashima wrote: >>> >>> On Wed, Jun 24, 2026 at 2:26 PM Michal Luczaj wrote: >>> > >>> > On 6/24/26 22:01, Willem de Bruijn wrote: >>> > > Jakub Sitnicki wrote: >>> > >> On Tue, Jun 23, 2026 at 08:03 PM +02, Michal Luczaj wrote: >>> > >>> UDP sockets get SOCK_RCU_FREE set when (auto-)bound. This means >>> > >>> sk_is_refcounted(unbound) = true, while sk_is_refcounted(bound) = false. >>> > >>> >>> > >>> Because sockmap accepts unbound UDP sockets, a BPF program can increment a >>> > >>> socket's refcount via lookup. If the socket is subsequently bound, the >>> > >>> transition from unbound to bound causes bpf_sk_release() to skip the >>> > >>> decrement of the refcount, causing a memory leak. >>> > >>> >>> > >>> unreferenced object 0xffff88810bc2eb40 (size 1984): >>> > >>> comm "test_progs", pid 2451, jiffies 4295320596 >>> > >>> hex dump (first 32 bytes): >>> > >>> 7f 00 00 01 7f 00 00 01 d2 04 1b b7 04 d2 00 00 ................ >>> > >>> 02 00 01 40 00 00 00 00 00 00 00 00 00 00 00 00 ...@............ >>> > >>> backtrace (crc bdee079d): >>> > >>> kmem_cache_alloc_noprof+0x557/0x660 >>> > >>> sk_prot_alloc+0x69/0x240 >>> > >>> sk_alloc+0x30/0x460 >>> > >>> inet_create+0x2ce/0xf80 >>> > >>> __sock_create+0x25b/0x5c0 >>> > >>> __sys_socket+0x119/0x1d0 >>> > >>> __x64_sys_socket+0x72/0xd0 >>> > >>> do_syscall_64+0xa1/0x5f0 >>> > >>> entry_SYSCALL_64_after_hwframe+0x76/0x7e >>> > >>> >>> > >>> Maintain balanced refcounts across sk lookup/release: (re-)set >>> > >>> SOCK_RCU_FREE on proto update to treat the socket (whether bound or >>> > >>> unbound) as not requiring a refcount increment on (a RCU protected) lookup. >>> > >>> >>> > >>> Fixes: 0c48eefae712 ("sock_map: Lift socket state restriction for datagram sockets") >>> > >>> Signed-off-by: Michal Luczaj [...] >Rejecting unhashed UDP sockets on insert to sockmap SGTM. >It is also in line with disable-problematic-cases strategy. Agree ACK just disallow it.