Netdev List
 help / color / mirror / Atom feed
From: Sabrina Dubroca <sd@queasysnail.net>
To: Breno Leitao <leitao@debian.org>
Cc: sdf@fomichev.me, "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Simon Horman" <horms@kernel.org>,
	"Alexander Aring" <alex.aring@gmail.com>,
	"Stefan Schmidt" <stefan@datenfreihafen.org>,
	"Miquel Raynal" <miquel.raynal@bootlin.com>,
	"Remi Denis-Courmont" <courmisch@gmail.com>,
	"Rémi Denis-Courmont" <remi.denis-courmont@nokia.com>,
	"John Fastabend" <john.fastabend@gmail.com>,
	"Shuah Khan" <shuah@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-wpan@vger.kernel.org, linux-kselftest@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH net-next v2 6/7] tls: convert getsockopt to sockopt_t
Date: Thu, 23 Jul 2026 11:51:43 +0200	[thread overview]
Message-ID: <amHkLwihrCUx-_pk@krikkit> (raw)
In-Reply-To: <20260720-getsockopt_phase4-v2-6-8a08fcfa0d72@debian.org>

2026-07-20, 09:17:47 -0700, Breno Leitao wrote:
> Continue converting the proto-layer getsockopt callbacks to the sockopt_t
> interface, converting do_tls_getsockopt() and its per-option helpers to
> take a sockopt_t.
> 
> The thin tls_getsockopt() wrapper keeps its __user signature for now: it
> builds a user-backed sockopt_t with sockopt_init_user(), calls the helper,
> and writes the returned length back to optlen. The helpers use
> copy_to_iter() instead of copy_to_user(); the NULL optval check in the
> TLS_TX/TLS_RX path is preserved by testing the iterator user buffer.
> 
> No functional change.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>

Reviewed-by: Sabrina Dubroca <sd@queasysnail.net>

Looks ok, just a few small comments:

> -static int do_tls_getsockopt_conf(struct sock *sk, char __user *optval,
> -				  int __user *optlen, int tx)
> +static int do_tls_getsockopt_conf(struct sock *sk, sockopt_t *opt, int tx)
>  {
>  	int rc = 0;
>  	const struct tls_cipher_desc *cipher_desc;
>  	struct tls_context *ctx = tls_get_ctx(sk);
>  	struct tls_crypto_info *crypto_info;
>  	struct cipher_context *cctx;
> -	int len;
> +	int len = opt->optlen;
>  
> -	if (get_user(len, optlen))
> -		return -EFAULT;
> -
> -	if (!optval || (len < sizeof(*crypto_info))) {
> +	if (!opt->iter_out.ubuf || len < sizeof(*crypto_info)) {

Not something about your patch but... I really wonder what this NULL
check was trying to accomplish. The other getsockopts in tls don't
have one, I don't think the rest of networkng does that either.


> @@ -591,12 +574,25 @@ static int tls_getsockopt(struct sock *sk, int level, int optname,
>  			  char __user *optval, int __user *optlen)
>  {
>  	struct tls_context *ctx = tls_get_ctx(sk);
> +	sockopt_t opt;
> +	int err;
>  
>  	if (level != SOL_TLS)
>  		return ctx->sk_proto->getsockopt(sk, level,
>  						 optname, optval, optlen);
>  
> -	return do_tls_getsockopt(sk, optname, optval, optlen);
> +	err = sockopt_init_user(&opt, optval, optlen);
> +	if (err)
> +		return err;
> +
> +	err = do_tls_getsockopt(sk, optname, &opt);
> +	if (err)
> +		return err;
> +
> +	if (put_user(opt.optlen, optlen))
> +		return -EFAULT;

One of the sashikos complains that we're now writing the length with
put_user in cases where we didn't before. I don't think we need to
care, but if someone complains, we could make this conditional on
optlen having been changed by the handler.

It also complains that optlen was getting updated on EFAULT and now
it's not. There's possibly some code out there that's crazy enough to
pass a bogus buffer to get the size it should have provided?

Also some complaints about "what if optlen is negative". I think we
can ignore all of that.

-- 
Sabrina

  reply	other threads:[~2026-07-23  9:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 16:17 [PATCH net-next v2 0/7] net: convert rawv6, ieee802154, phonet and tls getsockopt to sockopt_t Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 1/7] ipv6: raw: drop unused level argument from do_rawv6_getsockopt Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 2/7] ipv6: raw: convert do_rawv6_getsockopt to sockopt_t Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 3/7] ieee802154: convert dgram getsockopt " Breno Leitao
2026-07-22 13:40   ` Joe Damato
2026-07-20 16:17 ` [PATCH net-next v2 4/7] phonet: pep: do not write beyond optlen in getsockopt Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 5/7] phonet: pep: convert getsockopt to sockopt_t Breno Leitao
2026-07-20 16:17 ` [PATCH net-next v2 6/7] tls: " Breno Leitao
2026-07-23  9:51   ` Sabrina Dubroca [this message]
2026-07-20 16:17 ` [PATCH net-next v2 7/7] selftests: net: getsockopt_iter: cover rawv6, ieee802154, phonet and tls Breno Leitao
2026-07-23 10:29   ` Sabrina Dubroca
2026-07-22 13:42 ` [PATCH net-next v2 0/7] net: convert rawv6, ieee802154, phonet and tls getsockopt to sockopt_t Joe Damato
2026-07-23 14:05   ` Breno Leitao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=amHkLwihrCUx-_pk@krikkit \
    --to=sd@queasysnail.net \
    --cc=alex.aring@gmail.com \
    --cc=courmisch@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-wpan@vger.kernel.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=remi.denis-courmont@nokia.com \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=stefan@datenfreihafen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox