Skip to content

Commit

Permalink
genl: Always call subdissector
Browse files Browse the repository at this point in the history
Commit 61c5e8e ("genl: make subdissectors responsible for header")
changed the generic netlink dissector to only call a sub-dissector if
there is a payload after the generic netlink header.

However, there are commands in certain generic netlink families that do
not have any payload. For example, 'NET_DM_CMD_START' in the 'NET_DM'
family. This means that the command will not be dissected by the
subdissector, as it will never be invoked.

Change the generic netlink dissector to always call a subdissector, if
it is present. Prevent the subdissectors from trying to dissect past the
end of the packet by adding checks in the two existing subdissectors,
for the 'nlctrl' and 'nl80211' families.

Change-Id: I4d2f48531dee92b11dc45000081a8d2d3dd875c6
Signed-off-by: Ido Schimmel <[email protected]>
Reviewed-on: https://code.wireshark.org/review/34350
Reviewed-by: Peter Wu <[email protected]>
Petri-Dish: Peter Wu <[email protected]>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <[email protected]>
  • Loading branch information
idosch authored and AndersBroman committed Aug 30, 2019
1 parent f753bca commit 4ee007b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
19 changes: 10 additions & 9 deletions epan/dissectors/packet-netlink-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ dissect_genl_ctrl(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree _U_, v

offset = dissect_genl_header(tvb, genl_info, &hfi_genl_ctrl_cmd);

/* Return if command has no payload */
if (!tvb_reported_length_remaining(tvb, offset))
return offset;

dissect_netlink_attributes(tvb, &hfi_genl_ctrl_attr, ett_genl_ctrl_attr, &info, info.data, genl_info->genl_tree, offset, -1, dissect_genl_ctrl_attrs);

/*
Expand Down Expand Up @@ -445,15 +449,12 @@ dissect_netlink_generic(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi

/* Optional user-specific message header and optional message payload. */
next_tvb = tvb_new_subset_remaining(tvb, offset);
/* Try subdissector if there is a payload. */
if (tvb_reported_length_remaining(tvb, offset + 4)) {
if (family_name) {
int ret;
/* Invoke subdissector with genlmsghdr present. */
ret = dissector_try_string(genl_dissector_table, family_name, next_tvb, pinfo, tree, &info);
if (ret) {
return ret;
}
if (family_name) {
int ret;
/* Invoke subdissector with genlmsghdr present. */
ret = dissector_try_string(genl_dissector_table, family_name, next_tvb, pinfo, tree, &info);
if (ret) {
return ret;
}
}

Expand Down
4 changes: 4 additions & 0 deletions epan/dissectors/packet-netlink-nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -2901,6 +2901,10 @@ dissect_netlink_nl80211(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, voi

offset = dissect_genl_header(tvb, genl_info, &hfi_nl80211_commands);

/* Return if command has no payload */
if (!tvb_reported_length_remaining(tvb, offset))
return offset;

pi = proto_tree_add_item(tree, proto_registrar_get_nth(proto_netlink_nl80211), tvb, offset, -1, ENC_NA);
nlmsg_tree = proto_item_add_subtree(pi, ett_nl80211);

Expand Down

0 comments on commit 4ee007b

Please sign in to comment.