summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPablo Neira <pablo@netfilter.org>2013-07-29 12:30:04 +0200
committerLorenzo Colitti <lorenzo@google.com>2018-02-14 16:38:51 +0900
commit7fd08f83e13ce5c9b4d4daa71a05d5bb8e0dd295 (patch)
tree4b170b6d4be002fdc9df28aba00ca35e7d31a03d
parent65a96e9d84431d4948582d65117334cc5048f280 (diff)
downloadtegra-7fd08f83e13ce5c9b4d4daa71a05d5bb8e0dd295.tar.gz
UPSTREAM: 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 <pablo@netfilter.org> Signed-off-by: David S. Miller <davem@davemloft.net> (cherry picked from commit e1ee3673a83cc02b6b5e43c9e647d8dd5e1c4e26) Change-Id: I1e7dfdfb1accfd22a171eb9a9a993e5b191dd27f
-rw-r--r--net/netlink/genetlink.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
index 2fd6dbea327a..145d145dbc8e 100644
--- a/net/netlink/genetlink.c
+++ b/net/netlink/genetlink.c
@@ -571,7 +571,7 @@ static int genl_family_rcv_msg(struct genl_family *family,
!capable(CAP_NET_ADMIN))
return -EPERM;
- if (nlh->nlmsg_flags & NLM_F_DUMP) {
+ if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
struct netlink_dump_control c = {
.dump = ops->dumpit,
.done = ops->done,