From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f67.google.com (mail-pj1-f67.google.com [209.85.216.67]) (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 70849368D43 for ; Sat, 13 Jun 2026 02:10:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.67 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781316623; cv=none; b=fHuXWopkhPcTpt7yaVLMrcfXk2E3RLBtzom/xH8gUgfZUn7atJtMlhEXwp7+KS5yr/PVN1vUPURgGx+z3KfNTxWUjjFcQ9tjSkRApd7uWqCDHIYyv26vN13lfRFE6hF590EG5NSx53apQMVisRRaFHZFkpJmBTNRz9rggHCjURM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781316623; c=relaxed/simple; bh=uTqsrI3kXHlZ9s5FCWhR0+ezVXqQfpVv9lD9udQjaag=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=t2T77RGt+Jotz1Bq98UhejLYdE88n6OuahmnK5myYk0fgUfal9XVn6+10VmlWxMYxqJW0UzIi2aD42om9DC54Jrq5OD5jLZXJJrHw7QkRzcYS8bdGUm3M9WnNF95w+uAJNXIOU3zebuwb9SWdFKcOqnrH2m3WxmSLgQ+AvD9Hfs= 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=WYBNAx6R; arc=none smtp.client-ip=209.85.216.67 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="WYBNAx6R" Received: by mail-pj1-f67.google.com with SMTP id 98e67ed59e1d1-36ba285e98bso1606268a91.2 for ; Fri, 12 Jun 2026 19:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1781316622; x=1781921422; 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=wlXZARvbuLg9eimNdY6LbUYqojjxqaDI2VXv+ws27Jk=; b=WYBNAx6RA3iHPgNBsHKg4uE+y16iBvAyMLIjSJjtVZOb3mrw5ALHYKZAjujzpuizAn XEYzSZUyhdLbQVSbmvk37prtPys0Khb7V+gyjUkS4L8PHfAVHYpwRCgeUJTTD3Tmn+Fs HZz8V5BzT8DmnRgJFK/o/ms07Q4nCvFGkXDZN95clbcrAkTry6NWv+UgcJ9S661w5vqs gADNzKaJ9VKbF7MlUjQNW7oINoGnsOxItnXPmNmUDPEi2B+1Wv9HxCtjLFTKxZ7YRdXR xhblQkcNhsdXFBYM/ahhBritH+mfGzNmbsSQqkaI9xMsjQi75yiW10zD75Fq7LjqXqji ujaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781316622; x=1781921422; 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=wlXZARvbuLg9eimNdY6LbUYqojjxqaDI2VXv+ws27Jk=; b=abUusfia3uFSq9pNb7MEb6aCM4ye9Uuvd5YfT5cuvc0U5UO5Ij1LRlx7svksXI8OCJ X7z2g23fXLwdsqIlbm0zEpFWgv1oH4kxLCPSQfCh5VxKNAIrD3uG/zc6i66Cv6k65D4+ J4jWE4ygXTiFDpNtSMKI5PM/CpcyA4IW3c9MynIhLQuGEZxCAQbditERuo2Uma8IzbkL UPCSh8eM0ti6hstXXkUMhEK/WG9w6HNMbFvnB03Co8sdvtRGtYKN2Q/sdYwSQAbDmDAO ND9G3Oog319ihtuUm6uEmmJtvEBXvJphyQQypCjRSalESjPeHgsSGIjGfgivpVc5JtYP IaJQ== X-Forwarded-Encrypted: i=1; AFNElJ+9TqyrFSaKEo7TsmY3d1HjKk9cl8hSYZggKb07vkTY0vrixB0OYjDLFH4W96TW9HYNf2vxNkU=@vger.kernel.org X-Gm-Message-State: AOJu0YyBJP7b/hSVFmZdgZ6fm2Hwp1mS7VYnH4qYArw8Jvu/ORgCBYQ6 ng7vgxrxHF7aBHP+UG6aM0mRbw89rqvCaDtyNy3RrMju/uY7ZHdgqVZY X-Gm-Gg: Acq92OEp7OsWlQeR9499l+osY5cNrs7sKyADroGk86DIqW2j/ya1P8DePRHeauZAoG+ VS0PUY483IL+VRy2h/TC0pYPA3rWBKvTtvT+NL+Wm0tJLKpQ96rdib1OX6fG3L6xyr4ap42fZ+0 ro4mxU2TcoJ0LJGSAYlTJkHHcYLqUqSwJ3tZjDM7HtxdcWi5apCwO6dF9WfctfXdwn0gkDEkoto 7LCtml0XXwwi76V4sZD7cXceBE7yqoOlgPpczLWKtl7/AS793WTGWlztdBDO++2Kbd2PJHqaMdY IQr/l57HT1UjPoNRq6yLxYsK/8sYhKtN1oUE+mwpzZ6oT9o7fbvb+H0AvvXUFlgHQrhMSw29skk uQZF2RKacGWBTq8WRcKQsSl17d2ABE0LZbjfDlAMfks1rfE3AVGzvKCS+kicYzxpwpEFgXE6uZI 8QI+LdtLAV1qsQ9yQzfpaEG0C9rjE= X-Received: by 2002:a17:90a:d44e:b0:36b:2179:6d23 with SMTP id 98e67ed59e1d1-37a01c36da1mr5844647a91.7.1781316621781; Fri, 12 Jun 2026 19:10:21 -0700 (PDT) Received: from localhost ([2a03:2880:2ff:41::]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-379c3240b5esm2395134a91.0.2026.06.12.19.10.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Jun 2026 19:10:21 -0700 (PDT) Date: Fri, 12 Jun 2026 19:10:15 -0700 From: Stanislav Fomichev To: Breno Leitao Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Willem de Bruijn , Shuah Khan , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kernel-team@meta.com Subject: Re: [PATCH net-next 2/2] udp: convert udp_lib_getsockopt to sockopt_t Message-ID: References: <20260612-getsockopt_phase2-v1-0-7b01f1f5d106@debian.org> <20260612-getsockopt_phase2-v1-2-7b01f1f5d106@debian.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20260612-getsockopt_phase2-v1-2-7b01f1f5d106@debian.org> On 06/12, Breno Leitao wrote: > In preparation for converting the proto-layer getsockopt callbacks to the > sockopt_t interface, switch udp_lib_getsockopt() to take a sockopt_t. > > The thin udp_getsockopt()/udpv6_getsockopt() wrappers keep their __user > signature for now: they build a user-backed sockopt_t with > sockopt_init_user(), call the helper, and write the returned length back > to optlen. The helper uses copy_to_iter() instead of copy_to_user(). > No functional change. > > Signed-off-by: Breno Leitao > --- > include/net/udp.h | 2 +- > net/ipv4/udp.c | 40 ++++++++++++++++++++++++++-------------- > net/ipv6/udp.c | 17 ++++++++++++++--- > 3 files changed, 41 insertions(+), 18 deletions(-) > > diff --git a/include/net/udp.h b/include/net/udp.h > index 8262e2b215b4e..1fee17274745f 100644 > --- a/include/net/udp.h > +++ b/include/net/udp.h > @@ -430,7 +430,7 @@ struct sk_buff *skb_udp_tunnel_segment(struct sk_buff *skb, > netdev_features_t features, > bool is_ipv6); > int udp_lib_getsockopt(struct sock *sk, int level, int optname, > - char __user *optval, int __user *optlen); > + sockopt_t *opt); > int udp_lib_setsockopt(struct sock *sk, int level, int optname, > sockptr_t optval, unsigned int optlen, > int (*push_pending_frames)(struct sock *)); > diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c > index 70f6cbd4ef73b..0691f74db2c11 100644 > --- a/net/ipv4/udp.c > +++ b/net/ipv4/udp.c > @@ -76,6 +76,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -2995,18 +2996,12 @@ static int udp_setsockopt(struct sock *sk, int level, int optname, sockptr_t opt > } > > int udp_lib_getsockopt(struct sock *sk, int level, int optname, > - char __user *optval, int __user *optlen) > + sockopt_t *opt) > { > struct udp_sock *up = udp_sk(sk); > int val, len; > > - if (get_user(len, optlen)) > - return -EFAULT; [..] > - if (len < 0) > - return -EINVAL; I see this part now in sockopt_init_user, but you mention that it's a transitional helper. When we drop it, will we loose this <0 check? Maybe keep `if ((int)opt->optlen < 0))` here for backwards compatibility?