Skip to content

Commit

Permalink
netdev-offload-tc: Fix misaligned access to ct label.
Browse files Browse the repository at this point in the history
UndefinedBehaviorSanitizer:

  lib/netdev-offload-tc.c:1356:50: runtime error:
   member access within misaligned address 0x60700001a89c for type
   'const struct (unnamed struct at lib/netdev-offload-tc.c:1350:27)',
   which requires 8 byte alignment 0x60700001a89c: note: pointer points here
   24 00 04 00 01 00 00 05  00 00 0d 00 0a 00 00 00  00 00 00 00 ...
               ^
   0 0xd5d183 in parse_put_flow_ct_action lib/netdev-offload-tc.c:1356:50
   1 0xd5783f in netdev_tc_parse_nl_actions lib/netdev-offload-tc.c:2015:19
   2 0xd4027c in netdev_tc_flow_put lib/netdev-offload-tc.c:2355:11
   3 0x9666d7 in netdev_flow_put lib/netdev-offload.c:318:14
   4 0xcd4c0a in parse_flow_put lib/dpif-netlink.c:2297:11
   5 0xcd4c0a in try_send_to_netdev lib/dpif-netlink.c:2384:15
   6 0xcd4c0a in dpif_netlink_operate lib/dpif-netlink.c:2455:23
   7 0x87d40e in dpif_operate lib/dpif.c:1372:13
   8 0x6d43e9 in handle_upcalls ofproto/ofproto-dpif-upcall.c:1674:5
   9 0x6d43e9 in recv_upcalls ofproto/ofproto-dpif-upcall.c:905:9
   10 0x6cf6ea in udpif_upcall_handler ofproto/ofproto-dpif-upcall.c:801:13
   11 0xb6d7ea in ovsthread_wrapper lib/ovs-thread.c:423:12
   12 0x7f5ccf017801 in start_thread
   13 0x7f5ccefb744f in __GI___clone3

Fixes: 9221c72 ("netdev-offload-tc: Add conntrack label and mark support")
Reviewed-by: Simon Horman <[email protected]>
Acked-by: Eelco Chaudron <[email protected]>
Signed-off-by: Ilya Maximets <[email protected]>
  • Loading branch information
igsilya committed Jan 27, 2023
1 parent 3beff0a commit 9117f4d
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/netdev-offload-tc.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,13 +843,13 @@ parse_tc_flower_to_actions__(struct tc_flower *flower, struct ofpbuf *buf,
struct {
ovs_u128 key;
ovs_u128 mask;
} *ct_label;
} ct_label = {
.key = action->ct.label,
.mask = action->ct.label_mask,
};

ct_label = nl_msg_put_unspec_uninit(buf,
OVS_CT_ATTR_LABELS,
sizeof *ct_label);
ct_label->key = action->ct.label;
ct_label->mask = action->ct.label_mask;
nl_msg_put_unspec(buf, OVS_CT_ATTR_LABELS,
&ct_label, sizeof ct_label);
}

if (action->ct.nat_type) {
Expand Down Expand Up @@ -1339,13 +1339,14 @@ parse_put_flow_ct_action(struct tc_flower *flower,
break;
case OVS_CT_ATTR_LABELS: {
const struct {
ovs_u128 key;
ovs_u128 mask;
ovs_32aligned_u128 key;
ovs_32aligned_u128 mask;
} *ct_label;

ct_label = nl_attr_get_unspec(ct_attr, sizeof *ct_label);
action->ct.label = ct_label->key;
action->ct.label_mask = ct_label->mask;
action->ct.label = get_32aligned_u128(&ct_label->key);
action->ct.label_mask =
get_32aligned_u128(&ct_label->mask);
}
break;
}
Expand Down

0 comments on commit 9117f4d

Please sign in to comment.