Skip to content

Commit fb09c8c

Browse files
committed
Merge tag 'linux-can-fixes-for-4.9-20161123' of git://git.kernel.org/pub/scm/linux/kernel/git/mkl/linux-can
Marc Kleine-Budde says: ==================== pull-request: can 2016-11-23 this is a pull request for net/master. The patch by Oliver Hartkopp for the broadcast manager (bcm) fixes the CAN-FD support, which may cause an out-of-bounds access otherwise. ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents f7db0ec + 5499a6b commit fb09c8c

1 file changed

Lines changed: 10 additions & 8 deletions

File tree

‎net/can/bcm.c‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
(CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG) : \
7878
(CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG))
7979

80-
#define CAN_BCM_VERSION "20160617"
80+
#define CAN_BCM_VERSION "20161123"
8181

8282
MODULE_DESCRIPTION("PF_CAN broadcast manager protocol");
8383
MODULE_LICENSE("Dual BSD/GPL");
@@ -109,8 +109,9 @@ struct bcm_op {
109109
u32 count;
110110
u32 nframes;
111111
u32 currframe;
112-
struct canfd_frame *frames;
113-
struct canfd_frame *last_frames;
112+
/* void pointers to arrays of struct can[fd]_frame */
113+
void *frames;
114+
void *last_frames;
114115
struct canfd_frame sframe;
115116
struct canfd_frame last_sframe;
116117
struct sock *sk;
@@ -681,7 +682,7 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
681682

682683
if (op->flags & RX_FILTER_ID) {
683684
/* the easiest case */
684-
bcm_rx_update_and_send(op, &op->last_frames[0], rxframe);
685+
bcm_rx_update_and_send(op, op->last_frames, rxframe);
685686
goto rx_starttimer;
686687
}
687688

@@ -1068,7 +1069,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
10681069

10691070
if (msg_head->nframes) {
10701071
/* update CAN frames content */
1071-
err = memcpy_from_msg((u8 *)op->frames, msg,
1072+
err = memcpy_from_msg(op->frames, msg,
10721073
msg_head->nframes * op->cfsiz);
10731074
if (err < 0)
10741075
return err;
@@ -1118,7 +1119,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
11181119
}
11191120

11201121
if (msg_head->nframes) {
1121-
err = memcpy_from_msg((u8 *)op->frames, msg,
1122+
err = memcpy_from_msg(op->frames, msg,
11221123
msg_head->nframes * op->cfsiz);
11231124
if (err < 0) {
11241125
if (op->frames != &op->sframe)
@@ -1163,6 +1164,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
11631164
/* check flags */
11641165

11651166
if (op->flags & RX_RTR_FRAME) {
1167+
struct canfd_frame *frame0 = op->frames;
11661168

11671169
/* no timers in RTR-mode */
11681170
hrtimer_cancel(&op->thrtimer);
@@ -1174,8 +1176,8 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
11741176
* prevent a full-load-loopback-test ... ;-]
11751177
*/
11761178
if ((op->flags & TX_CP_CAN_ID) ||
1177-
(op->frames[0].can_id == op->can_id))
1178-
op->frames[0].can_id = op->can_id & ~CAN_RTR_FLAG;
1179+
(frame0->can_id == op->can_id))
1180+
frame0->can_id = op->can_id & ~CAN_RTR_FLAG;
11791181

11801182
} else {
11811183
if (op->flags & SETTIMER) {

0 commit comments

Comments
 (0)