From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-dl1-f41.google.com (mail-dl1-f41.google.com [74.125.82.41]) (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 E0A6B211290 for ; Tue, 20 Jan 2026 17:24:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768929886; cv=none; b=cyrRaE3J6/WUJal31Rptl21J8YWmnBND+k1WeF7PuTqL/8N81WDCX3xHNDf9yrBsip50Vx4SClGz+RUOEkEfq9kXnkeYDP/y66fYJuinvTIkq2+78fejNHuwJUUXLjOP+KCvj7u+yMryav7CBZCwvdLYslPszlA4mGEG5KnnEyE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768929886; c=relaxed/simple; bh=Ckdv+LBfVcrA4JvvMxCIADVWbw04Tilid9Ikn1lV+1Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ckOv6DfVJYzuakF/Wb+hTNcHVK+HOh2Voy991M2ExZvcRzLQKHwgQCbdcNzumVi1OfGWtBHQkBXAHeeisHfI6HE+wSZpvWPlIJYjgJ5wJeZGD019CPO5WnWcsYB921U8lR0VS30tymcM/oZZUdgCk8AM7jFJViH4roJZwfhsOP4= 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=LDAtbSLw; arc=none smtp.client-ip=74.125.82.41 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="LDAtbSLw" Received: by mail-dl1-f41.google.com with SMTP id a92af1059eb24-12336c0a8b6so11837868c88.1 for ; Tue, 20 Jan 2026 09:24:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768929884; x=1769534684; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=md0g+j6qZSK2w0IJlJPci/fZMbMlDX58xj6TKgMT//Y=; b=LDAtbSLwuZnGhvcBKwEeA8+tkz8271Yc+ZDPmnQvnHkEvyYx/tKKzxj++mNFJ1Oca7 FuW6DKS9vLXbxwLo13Ss8zukrUYDjmLPtMSiYmHW0wCwF80DlGxALMcmXspf+NawiXn3 PVLD2gDaBqpx72TkYJzzXdQaGRUttjky1vT+U9/6N+4DZoHgtV2Gw6Mt+ZR8clSNi+oI Tsq/NoezCzgEIocfepOB45ky7HM7nNurx6pVGZV4GyNhwaj2FVnAcSuHEhTJWu8xwpAy TY22+7ZV4LhFCJF3Guo5IThOUGqTr3O3jYnFDHK9ldEz1Sc9SSaCqrBVjYVF12vRZ+IR 2JlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768929884; x=1769534684; h=in-reply-to: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=md0g+j6qZSK2w0IJlJPci/fZMbMlDX58xj6TKgMT//Y=; b=CDpULJIQOU0JdHrsnII7b++Jt3LGex9ojEZyxZ3GY8GbKGK+alQLGrCJyLikwID15p 26rpVSenJuV5zp7hYFLS4i8H2hV5tGJnIdpFocO3/7t+a7EKosvcEingF8bbr9fmSGms uB8o1mWu7JnR9kj8HlrBv4ctq1B1UML6tGzLyD21ydV9eIKVDtLcEcXh07BSUZXNHIxF VkdfAi6/HeozXCXoN7Wqq/V9W1tFDm1t5upqIRVUkSSADk+f9innpClbqGEj0/DtKm25 TZb4+1EBWABE1FKmlwjJe+qP611OMz2RQluULUuIqJowMRo5Ozz6edJrQvx+ckvPlJ1N q2Rw== X-Forwarded-Encrypted: i=1; AJvYcCXIkcJIl8q4ygV1HBjjjWwb+mm75V6e1p52Iq/aYuOJCIAQIl7PWRxdJfbKoR09UYTtCee2w8qP/qPDMLM=@vger.kernel.org X-Gm-Message-State: AOJu0Ywq6SgLpjUUDdYwCuCkOKchn2QCTScg7HghUphi54tqRD6JHih6 7XW1oCoLqgUIqoA/S8QPjBpzK1EpA4T/upMXXI7+ItMppeYV+XoBuwKh9E3EfA== X-Gm-Gg: AY/fxX5E960jS5vm7BmRFJi25fEOm1Rx8auzZkWJhkBaw/riRunuzgCFF0617jaX4ym G0UZXfHd8ynMnzlfYR1tZbtkZnqpzvXSAjLq0rLytmhW70cHzBdBrplQbl0g7ebyR7oKk6t45kw 0hXc2speE3yhY+mnRyxfYlVwZaIQHC253CIXR8rIpplWJDlvUrFL2aY2h4Re58x8jy/9ZEbsDZX Olg347pdLtKKATpwju+DOY8r5IF5jCKxnBh1L+EV1JbcOGo7whTzE87z4WZMmz4VMrijoBtQcIU CRDJJVw4ApuXnMjFrlgbI8lfXziPNPmEnRmv6rQpvQvbbe+cZ1LllZ8++PkO2aFBR+3w0zWUfCB tY4VH3zxZgA9ZyfDv/eoOSNDKlgFkQRVhzTFkEUJKsfXoQGYzw3GefBegRUmFjbNjx+23NRCJt3 wfqxrX+CGU8Yo= X-Received: by 2002:a17:902:d4cb:b0:2a7:9196:a94e with SMTP id d9443c01a7336-2a79196aa80mr1234755ad.15.1768923524001; Tue, 20 Jan 2026 07:38:44 -0800 (PST) Received: from gmail.com ([98.97.43.126]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2a7190ce693sm112017965ad.36.2026.01.20.07.38.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Jan 2026 07:38:43 -0800 (PST) Date: Tue, 20 Jan 2026 07:38:16 -0800 From: John Fastabend To: Jakub Sitnicki Cc: Jiayuan Chen , bpf@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Neal Cardwell , Kuniyuki Iwashima , David Ahern , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , Michal Luczaj , Cong Wang , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: Re: [PATCH bpf-next v7 1/3] bpf, sockmap: Fix incorrect copied_seq calculation Message-ID: <20260120153807.gzwnhxxtcocycfmr@gmail.com> References: <20260113025121.197535-1-jiayuan.chen@linux.dev> <20260113025121.197535-2-jiayuan.chen@linux.dev> <875x8wuy4e.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=us-ascii Content-Disposition: inline In-Reply-To: <875x8wuy4e.fsf@cloudflare.com> On 2026-01-20 16:01:21, Jakub Sitnicki wrote: > On Tue, Jan 13, 2026 at 10:50 AM +08, Jiayuan Chen wrote: > > A socket using sockmap has its own independent receive queue: ingress_msg. > > This queue may contain data from its own protocol stack or from other > > sockets. > > > > The issue is that when reading from ingress_msg, we update tp->copied_seq > > by default. However, if the data is not from its own protocol stack, > > tcp->rcv_nxt is not increased. Later, if we convert this socket to a > > native socket, reading from this socket may fail because copied_seq might > > be significantly larger than rcv_nxt. > > > > This fix also addresses the syzkaller-reported bug referenced in the > > Closes tag. > > > > This patch marks the skmsg objects in ingress_msg. When reading, we update > > copied_seq only if the data is from its own protocol stack. > > > > FD1:read() > > -- FD1->copied_seq++ > > | [read data] > > | > > [enqueue data] v > > [sockmap] -> ingress to self -> ingress_msg queue > > FD1 native stack ------> ^ > > -- FD1->rcv_nxt++ -> redirect to other | [enqueue data] > > | | > > | ingress to FD1 > > v ^ > > ... | [sockmap] > > FD2 native stack > > > > Closes: https://syzkaller.appspot.com/bug?extid=06dbd397158ec0ea4983 > > Fixes: 04919bed948dc ("tcp: Introduce tcp_read_skb()") > > Reviewed-by: Jakub Sitnicki > > Signed-off-by: Jiayuan Chen [...] > > @@ -487,6 +494,14 @@ int sk_msg_recvmsg(struct sock *sk, struct sk_psock *psock, struct msghdr *msg, > > out: > > return copied; > > } > > +EXPORT_SYMBOL_GPL(__sk_msg_recvmsg); > > Nit: Sorry, I haven't caught that before. tcp_bpf is a built-in. We > don't need to export this internal helper to modules. We could probably push this without the 2/3 patch? If we are debating that patch still would be good to get this merged. Reviewed-by: John Fastabend