An existing gateway job keeps its original flags when its modifications are replaced by a UID update. cgw_parse_attr() selects modification functions using the flags from the update request. Changing CGW_FLAGS_CAN_FD therefore installs CAN FD data operations on a Classical CAN job. A CAN FD data modification can then touch 64 data bytes on a frame that only carries 8. Reject UID updates that change the CAN FD frame-format flag while leaving updates to the other flags as before. Fixes: 456a8a646b25 ("can: gw: add support for CAN FD frames") Signed-off-by: Hungyu Lin <denn…@gmail.com> --- net/can/gw.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/can/gw.c b/net/can/gw.c index 8a5327d8a00e8..ff2542f388b66 100644 --- a/net/can/gw.c +++ b/net/can/gw.c @@ -1122,8 +1122,9 @@ static int cgw_create_job(struct sk_buff *skb, struct nlmsghdr *nlh, if (old_cf->uid != mod->uid) continue; - /* interfaces & filters must be identical */ - if (memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) { + /* interfaces, filters and frame format must be identical */ + if (((gwj->flags ^ r->flags) & CGW_FLAGS_CAN_FD) || + memcmp(&gwj->ccgw, &ccgw, sizeof(ccgw))) { err = -EINVAL; goto out_free_cf; }
-- 2.50.1 (Apple Git-155)