]> git.baikalelectronics.ru Git - kernel.git/commit
can: j1939: j1939_sk_setsockopt(): prevent allocation of j1939 filter for optlen...
authorNorbert Slusarek <nslusarek@gmx.net>
Sun, 20 Jun 2021 12:38:42 +0000 (14:38 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 24 Jun 2021 06:28:51 +0000 (08:28 +0200)
commitcd6fc2d6fdd30d418aa66f0c4d7413bbb5c1f7a9
tree1fb4a353da56ac6f7ebe4a5437e9271fb3485193
parenta57c1c379d3734e34f3b3c4ff259a25ebfcd43f3
can: j1939: j1939_sk_setsockopt(): prevent allocation of j1939 filter for optlen == 0

If optval != NULL and optlen == 0 are specified for SO_J1939_FILTER in
j1939_sk_setsockopt(), memdup_sockptr() will return ZERO_PTR for 0
size allocation. The new filter will be mistakenly assigned ZERO_PTR.
This patch checks for optlen != 0 and filter will be assigned NULL in
case of optlen == 0.

Fixes: 877b9bba3266 ("can: add support of SAE J1939 protocol")
Link: https://lore.kernel.org/r/20210620123842.117975-1-nslusarek@gmx.net
Signed-off-by: Norbert Slusarek <nslusarek@gmx.net>
Acked-by: Oleksij Rempel <o.rempel@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
net/can/j1939/socket.c