Re: [RFC PATCH can-next] can: raw: return -ERANGE when filterset does not fit into user space buffer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 12/16/20 6:49 PM, Oliver Hartkopp wrote:
> Multiple filters (struct can_filter) can be set with the setsockopt()
> function, which was originally intended as a write-only operation.
> 
> As getsockopt() also provides a CAN_RAW_FILTER option to read back the
> given filters, the caller has to provide an appropriate user space buffer.
> In the case this buffer is too small the getsockopt() silently truncates
> the filter information and gives no information about the needed space.
> This is safe but not convenient for the programmer.
> 
> In net/core/sock.c the SO_PEERGROUPS sockopt had a similar requirement
> and solved it by returning -ERANGE in the case that the provided data
> does not fit into the given user space buffer and fills the required size
> into optlen, so that the caller can retry with a matching buffer length.
> 
> This patch adopts this approach for CAN_RAW_FILTER getsockopt().
> 
> Reported-by: Phillip Schichtel <phillip@xxxxxxxxxx>
> Signed-off-by: Oliver Hartkopp <socketcan@xxxxxxxxxxxx>

Added to linux-can-next/testing. Do we need an update to the in kernel
Documentation?

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux