can-utils icon indicating copy to clipboard operation
can-utils copied to clipboard

j1939 - Remove root requirements for messages with the priorities 0 & 1

Open josemic opened this issue 5 years ago • 1 comments

This is a follow-up of the issue #159 .

When testing the priorities, I noticed, that for the priorities 0 and 1, the message occurs, that setting the priority is not permitted:

./testj1939 -B -s -p3 vcan0:0x80 :,0x0200

Works ok.

./testj1939 -B -s -p1 vcan0:0x80 :,0x0200
testj1939: set priority 1: Operation not permitted
./testj1939 -B -s -p0 vcan0:0x80 :,0x0200
testj1939: set priority 0: Operation not permitted

I am not aware that the priorities 0 & 1 are not permitted.

Originally posted by @marckleinebudde in https://github.com/linux-can/can-utils/issues/159#issuecomment-560096730: Priorities 0 and 1 are only permitted for root or users with capable(CAP_NET_ADMIN), see:

https://elixir.bootlin.com/linux/latest/source/net/can/j1939/socket.c#L705

I think this limit is arbitrary and we can discuss if this makes sense at all or add this to the documentation.

josemic avatar May 30 '20 14:05 josemic

In https://www.spinics.net/lists/linux-can/msg03690.html Kurt says:

If I remember well, there is a similar restriction for ethernet or IP priorities. It's true that this limit is arbritrary. It's based on me never having seen intended prio 0 or 1 messages on a bus, but only as a result of 'we forgot to set the priority'.

The goal is to avoid people using 0 as a default without further attention. I think that this could be replaced by some kind of setsockopt call, that sets the highest allowed priority, without ever requiring root. The initial default would then be 2 (or any other value, but 2 seems feasible to me).

marckleinebudde avatar Jun 17 '20 12:06 marckleinebudde