The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Breno Leitao <leitao@debian.org>,
	Robin van der Gracht <robin@protonic.nl>,
	Oleksij Rempel <o.rempel@pengutronix.de>,
	kernel@pengutronix.de, Marc Kleine-Budde <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-team@meta.com
Subject: Re: [PATCH net-next 2/2] can: isotp: convert to getsockopt_iter
Date: Mon, 11 May 2026 09:05:07 +0200	[thread overview]
Message-ID: <14d3ad71-ade2-4d2b-8a67-b0fda3eef2b7@hartkopp.net> (raw)
In-Reply-To: <20260507-getsock_two_can-v1-2-3c2ae9edfadc@debian.org>



On 07.05.26 11:34, Breno Leitao wrote:
> Convert CAN ISO-TP socket's getsockopt implementation to use the new
> getsockopt_iter callback with sockopt_t.
> 
> Key changes:
> - Replace (char __user *optval, int __user *optlen) with sockopt_t *opt
> - Use opt->optlen for buffer length (input) and returned size (output)
> - Use copy_to_iter() instead of put_user()/copy_to_user()
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>
> ---
>   net/can/isotp.c | 12 +++++-------
>   1 file changed, 5 insertions(+), 7 deletions(-)
> 
> diff --git a/net/can/isotp.c b/net/can/isotp.c
> index c48b4a818297e..1c33f09fbd338 100644
> --- a/net/can/isotp.c
> +++ b/net/can/isotp.c
> @@ -1500,7 +1500,7 @@ static int isotp_setsockopt(struct socket *sock, int level, int optname,
>   }
>   
>   static int isotp_getsockopt(struct socket *sock, int level, int optname,
> -			    char __user *optval, int __user *optlen)
> +			    sockopt_t *opt)
>   {
>   	struct sock *sk = sock->sk;
>   	struct isotp_sock *so = isotp_sk(sk);
> @@ -1509,8 +1509,7 @@ static int isotp_getsockopt(struct socket *sock, int level, int optname,
>   
>   	if (level != SOL_CAN_ISOTP)
>   		return -EINVAL;
> -	if (get_user(len, optlen))
> -		return -EFAULT;
> +	len = opt->optlen;
>   	if (len < 0)
>   		return -EINVAL;
>   
> @@ -1544,9 +1543,8 @@ static int isotp_getsockopt(struct socket *sock, int level, int optname,
>   		return -ENOPROTOOPT;
>   	}
>   
> -	if (put_user(len, optlen))
> -		return -EFAULT;
> -	if (copy_to_user(optval, val, len))
> +	opt->optlen = len;
> +	if (copy_to_iter(val, len, &opt->iter_out) != len)
>   		return -EFAULT;
>   	return 0;
>   }
> @@ -1718,7 +1716,7 @@ static const struct proto_ops isotp_ops = {
>   	.listen = sock_no_listen,
>   	.shutdown = sock_no_shutdown,
>   	.setsockopt = isotp_setsockopt,
> -	.getsockopt = isotp_getsockopt,
> +	.getsockopt_iter = isotp_getsockopt,
>   	.sendmsg = isotp_sendmsg,
>   	.recvmsg = isotp_recvmsg,
>   	.mmap = sock_no_mmap,
> 

Same pattern as in net/can/raw.c that had slipped in via net-next last 
time ;-)

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>

Thanks Breno!

Best regards,
Oliver

      reply	other threads:[~2026-05-11  7:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-07  9:34 [PATCH net-next 0/2] net: convert remaining CAN protocols to getsockopt_iter Breno Leitao
2026-05-07  9:34 ` [PATCH net-next 1/2] can: j1939: convert " Breno Leitao
2026-05-11  4:21   ` Oleksij Rempel
2026-05-07  9:34 ` [PATCH net-next 2/2] can: isotp: " Breno Leitao
2026-05-11  7:05   ` Oliver Hartkopp [this message]

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=14d3ad71-ade2-4d2b-8a67-b0fda3eef2b7@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=kernel-team@meta.com \
    --cc=kernel@pengutronix.de \
    --cc=leitao@debian.org \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=o.rempel@pengutronix.de \
    --cc=robin@protonic.nl \
    /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