lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <14e86ea6-e038-4702-957a-39af27bfc280@hartkopp.net>
Date: Mon, 8 Jan 2024 19:57:36 +0100
From: Oliver Hartkopp <socketcan@...tkopp.net>
To: Nicolas Maier <nicolas.maier.dev@...il.com>, mkl@...gutronix.de,
 linux-can@...r.kernel.org
Cc: davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
 pabeni@...hat.com, corbet@....net, netdev@...r.kernel.org,
 linux-doc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] can: bcm: add recvmsg flags for own, local and remote
 traffic

Hi Nicolas,

thanks for the patch!

On 07.01.24 07:44, Nicolas Maier wrote:

> @@ -642,7 +666,7 @@ static enum hrtimer_restart bcm_rx_thr_handler(struct hrtimer *hrtimer)
>   static void bcm_rx_handler(struct sk_buff *skb, void *data)
>   {
>   	struct bcm_op *op = (struct bcm_op *)data;
> -	const struct canfd_frame *rxframe = (struct canfd_frame *)skb->data;
> +	struct canfd_frame *rxframe = (struct canfd_frame *)skb->data;
>   	unsigned int i;
>   
>   	if (op->can_id != rxframe->can_id)
> @@ -657,6 +681,13 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
>   			return;
>   	}
>   
> +	/* add flags to distinguish between own/local/remote CAN traffic */
> +	if (skb->sk) {
> +		rxframe->flags |= RX_LOCAL;
> +		if (skb->sk == op->sk)
> +			rxframe->flags |= RX_OWN;
> +	}
> +
>   	/* disable timeout */
>   	hrtimer_cancel(&op->timer);
>   

No. You are writing to a read-only skbuff, which is not yet cloned or 
copied. The read-only handling of the skb is done in the NET_RX_SOFTIRQ 
triggering can_rcv_filter() and friends.

See this note:

https://elixir.bootlin.com/linux/v6.7/source/net/can/af_can.c#L430

When you are also changing the CAN frames' content you need to 
skb_copy() the provided skb, see:

https://elixir.bootlin.com/linux/v6.7/source/net/can/gw.c#L504

So if you want to pass these new flags to the user space you should 
think of extending the parameter list of bcm_rx_update_and_send() and 
bcm_rx_cmp_to_index().

But in the first place I'm interested to know what the use-case for this 
extension is.

Best regards,
Oliver

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ