Commit 0ab03c2b1478f2438d2c80204f7fef65b1bca9cf

Authored by Jan Engelhardt
Committed by David S. Miller
1 parent dba5a68ae1

netlink: test for all flags of the NLM_F_DUMP composite

Due to NLM_F_DUMP is composed of two bits, NLM_F_ROOT | NLM_F_MATCH,
when doing "if (x & NLM_F_DUMP)", it tests for _either_ of the bits
being set. Because NLM_F_MATCH's value overlaps with NLM_F_EXCL,
non-dump requests with NLM_F_EXCL set are mistaken as dump requests.

Substitute the condition to test for _all_ bits being set.

Signed-off-by: Jan Engelhardt <jengelh@medozas.de>
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 5 changed files with 6 additions and 6 deletions Side-by-side Diff

net/core/rtnetlink.c
... ... @@ -1820,7 +1820,7 @@
1820 1820 if (kind != 2 && security_netlink_recv(skb, CAP_NET_ADMIN))
1821 1821 return -EPERM;
1822 1822  
1823   - if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
  1823 + if (kind == 2 && (nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
1824 1824 struct sock *rtnl;
1825 1825 rtnl_dumpit_func dumpit;
1826 1826  
net/ipv4/inet_diag.c
... ... @@ -858,7 +858,7 @@
858 858 nlmsg_len(nlh) < hdrlen)
859 859 return -EINVAL;
860 860  
861   - if (nlh->nlmsg_flags & NLM_F_DUMP) {
  861 + if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
862 862 if (nlmsg_attrlen(nlh, hdrlen)) {
863 863 struct nlattr *attr;
864 864  
net/netfilter/nf_conntrack_netlink.c
... ... @@ -928,7 +928,7 @@
928 928 u16 zone;
929 929 int err;
930 930  
931   - if (nlh->nlmsg_flags & NLM_F_DUMP)
  931 + if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP)
932 932 return netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table,
933 933 ctnetlink_done);
934 934  
... ... @@ -1790,7 +1790,7 @@
1790 1790 u16 zone;
1791 1791 int err;
1792 1792  
1793   - if (nlh->nlmsg_flags & NLM_F_DUMP) {
  1793 + if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
1794 1794 return netlink_dump_start(ctnl, skb, nlh,
1795 1795 ctnetlink_exp_dump_table,
1796 1796 ctnetlink_exp_done);
net/netlink/genetlink.c
... ... @@ -519,7 +519,7 @@
519 519 security_netlink_recv(skb, CAP_NET_ADMIN))
520 520 return -EPERM;
521 521  
522   - if (nlh->nlmsg_flags & NLM_F_DUMP) {
  522 + if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
523 523 if (ops->dumpit == NULL)
524 524 return -EOPNOTSUPP;
525 525  
net/xfrm/xfrm_user.c
... ... @@ -2187,7 +2187,7 @@
2187 2187  
2188 2188 if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
2189 2189 type == (XFRM_MSG_GETPOLICY - XFRM_MSG_BASE)) &&
2190   - (nlh->nlmsg_flags & NLM_F_DUMP)) {
  2190 + (nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
2191 2191 if (link->dump == NULL)
2192 2192 return -EINVAL;
2193 2193