aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid S. Miller <davem@davemloft.net>2016-11-25 16:17:12 -0500
committerDavid S. Miller <davem@davemloft.net>2016-11-25 16:17:12 -0500
commitfb09c8c524dae2b893aacc9348e876a87b45b697 (patch)
treedee10b44205d1d370854c7c2bcd2b5b53538ebe4
parentf7db0ec9572f66b36c0d4d6bc4b564da53c8b35d (diff)
parent5499a6b22e5508b921c447757685b0a5e40a07ed (diff)
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>
-rw-r--r--net/can/bcm.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/net/can/bcm.c b/net/can/bcm.c
index 8af9d25ff988..436a7537e6a9 100644
--- a/net/can/bcm.c
+++ b/net/can/bcm.c
@@ -77,7 +77,7 @@
77 (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG) : \ 77 (CAN_EFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG) : \
78 (CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG)) 78 (CAN_SFF_MASK | CAN_EFF_FLAG | CAN_RTR_FLAG))
79 79
80#define CAN_BCM_VERSION "20160617" 80#define CAN_BCM_VERSION "20161123"
81 81
82MODULE_DESCRIPTION("PF_CAN broadcast manager protocol"); 82MODULE_DESCRIPTION("PF_CAN broadcast manager protocol");
83MODULE_LICENSE("Dual BSD/GPL"); 83MODULE_LICENSE("Dual BSD/GPL");
@@ -109,8 +109,9 @@ struct bcm_op {
109 u32 count; 109 u32 count;
110 u32 nframes; 110 u32 nframes;
111 u32 currframe; 111 u32 currframe;
112 struct canfd_frame *frames; 112 /* void pointers to arrays of struct can[fd]_frame */
113 struct canfd_frame *last_frames; 113 void *frames;
114 void *last_frames;
114 struct canfd_frame sframe; 115 struct canfd_frame sframe;
115 struct canfd_frame last_sframe; 116 struct canfd_frame last_sframe;
116 struct sock *sk; 117 struct sock *sk;
@@ -681,7 +682,7 @@ static void bcm_rx_handler(struct sk_buff *skb, void *data)
681 682
682 if (op->flags & RX_FILTER_ID) { 683 if (op->flags & RX_FILTER_ID) {
683 /* the easiest case */ 684 /* 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);
685 goto rx_starttimer; 686 goto rx_starttimer;
686 } 687 }
687 688
@@ -1068,7 +1069,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1068 1069
1069 if (msg_head->nframes) { 1070 if (msg_head->nframes) {
1070 /* update CAN frames content */ 1071 /* update CAN frames content */
1071 err = memcpy_from_msg((u8 *)op->frames, msg, 1072 err = memcpy_from_msg(op->frames, msg,
1072 msg_head->nframes * op->cfsiz); 1073 msg_head->nframes * op->cfsiz);
1073 if (err < 0) 1074 if (err < 0)
1074 return err; 1075 return err;
@@ -1118,7 +1119,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1118 } 1119 }
1119 1120
1120 if (msg_head->nframes) { 1121 if (msg_head->nframes) {
1121 err = memcpy_from_msg((u8 *)op->frames, msg, 1122 err = memcpy_from_msg(op->frames, msg,
1122 msg_head->nframes * op->cfsiz); 1123 msg_head->nframes * op->cfsiz);
1123 if (err < 0) { 1124 if (err < 0) {
1124 if (op->frames != &op->sframe) 1125 if (op->frames != &op->sframe)
@@ -1163,6 +1164,7 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1163 /* check flags */ 1164 /* check flags */
1164 1165
1165 if (op->flags & RX_RTR_FRAME) { 1166 if (op->flags & RX_RTR_FRAME) {
1167 struct canfd_frame *frame0 = op->frames;
1166 1168
1167 /* no timers in RTR-mode */ 1169 /* no timers in RTR-mode */
1168 hrtimer_cancel(&op->thrtimer); 1170 hrtimer_cancel(&op->thrtimer);
@@ -1174,8 +1176,8 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg,
1174 * prevent a full-load-loopback-test ... ;-] 1176 * prevent a full-load-loopback-test ... ;-]
1175 */ 1177 */
1176 if ((op->flags & TX_CP_CAN_ID) || 1178 if ((op->flags & TX_CP_CAN_ID) ||
1177 (op->frames[0].can_id == op->can_id)) 1179 (frame0->can_id == op->can_id))
1178 op->frames[0].can_id = op->can_id & ~CAN_RTR_FLAG; 1180 frame0->can_id = op->can_id & ~CAN_RTR_FLAG;
1179 1181
1180 } else { 1182 } else {
1181 if (op->flags & SETTIMER) { 1183 if (op->flags & SETTIMER) {