Skip to content

Commit e1ee367

Browse files
ummakynesdavem330
authored andcommitted
genetlink: fix usage of NLM_F_EXCL or NLM_F_REPLACE
Currently, it is not possible to use neither NLM_F_EXCL nor NLM_F_REPLACE from genetlink. This is due to this checking in genl_family_rcv_msg: if (nlh->nlmsg_flags & NLM_F_DUMP) NLM_F_DUMP is NLM_F_MATCH|NLM_F_ROOT. Thus, if NLM_F_EXCL or NLM_F_REPLACE flag is set, genetlink believes that you're requesting a dump and it calls the .dumpit callback. The solution that I propose is to refine this checking to make it stricter: if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) And given the combination NLM_F_REPLACE and NLM_F_EXCL does not make sense to me, it removes the ambiguity. There was a patch that tried to fix this some time ago (0ab03c2 netlink: test for all flags of the NLM_F_DUMP composite) but it tried to resolve this ambiguity in *all* existing netlink subsystems, not only genetlink. That patch was reverted since it broke iproute2, which is using NLM_F_ROOT to request the dump of the routing cache. Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent ff862a4 commit e1ee367

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/netlink/genetlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
571571
!capable(CAP_NET_ADMIN))
572572
return -EPERM;
573573

574-
if (nlh->nlmsg_flags & NLM_F_DUMP) {
574+
if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
575575
struct netlink_dump_control c = {
576576
.dump = ops->dumpit,
577577
.done = ops->done,

0 commit comments

Comments
 (0)