can: dev: fix crtlmode_supported check
authorOliver Hartkopp <socketcan@hartkopp.net>
Mon, 5 Jan 2015 17:40:15 +0000 (18:40 +0100)
committerJiri Slaby <jslaby@suse.cz>
Thu, 29 Jan 2015 14:45:03 +0000 (15:45 +0100)
commitb9c03b60cf6631b21ce28b7a1ade8b9ca2f7f1f8
tree099effcd885ca366a19b9572766061bf0cb5793a
parente02941b00980cc2c42257cbcdb432750a8a6850b
can: dev: fix crtlmode_supported check

commit 9b1087aa5e86448fe6ad40a58964e35f3ba423d5 upstream.

When changing flags in the CAN drivers ctrlmode the provided new content has to
be checked whether the bits are allowed to be changed. The bits that are to be
changed are given as a bitfield in cm->mask. Therefore checking against
cm->flags is wrong as the content can hold any kind of values.

The iproute2 tool sets the bits in cm->mask and cm->flags depending on the
detected command line options. To be robust against bogus user space
applications additionally sanitize the provided flags with the provided mask.

Cc: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/net/can/dev.c