Skip to content

Commit 0ab03c2

Browse files
Jan Engelhardtdavem330
authored andcommitted
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 <[email protected]> Acked-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent dba5a68 commit 0ab03c2

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

net/core/rtnetlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1820,7 +1820,7 @@ static int rtnetlink_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
18201820
if (kind != 2 && security_netlink_recv(skb, CAP_NET_ADMIN))
18211821
return -EPERM;
18221822

1823-
if (kind == 2 && nlh->nlmsg_flags&NLM_F_DUMP) {
1823+
if (kind == 2 && (nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
18241824
struct sock *rtnl;
18251825
rtnl_dumpit_func dumpit;
18261826

net/ipv4/inet_diag.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ static int inet_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
858858
nlmsg_len(nlh) < hdrlen)
859859
return -EINVAL;
860860

861-
if (nlh->nlmsg_flags & NLM_F_DUMP) {
861+
if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
862862
if (nlmsg_attrlen(nlh, hdrlen)) {
863863
struct nlattr *attr;
864864

net/netfilter/nf_conntrack_netlink.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ ctnetlink_get_conntrack(struct sock *ctnl, struct sk_buff *skb,
928928
u16 zone;
929929
int err;
930930

931-
if (nlh->nlmsg_flags & NLM_F_DUMP)
931+
if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP)
932932
return netlink_dump_start(ctnl, skb, nlh, ctnetlink_dump_table,
933933
ctnetlink_done);
934934

@@ -1790,7 +1790,7 @@ ctnetlink_get_expect(struct sock *ctnl, struct sk_buff *skb,
17901790
u16 zone;
17911791
int err;
17921792

1793-
if (nlh->nlmsg_flags & NLM_F_DUMP) {
1793+
if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
17941794
return netlink_dump_start(ctnl, skb, nlh,
17951795
ctnetlink_exp_dump_table,
17961796
ctnetlink_exp_done);

net/netlink/genetlink.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ static int genl_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
519519
security_netlink_recv(skb, CAP_NET_ADMIN))
520520
return -EPERM;
521521

522-
if (nlh->nlmsg_flags & NLM_F_DUMP) {
522+
if ((nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
523523
if (ops->dumpit == NULL)
524524
return -EOPNOTSUPP;
525525

net/xfrm/xfrm_user.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@ static int xfrm_user_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
21872187

21882188
if ((type == (XFRM_MSG_GETSA - XFRM_MSG_BASE) ||
21892189
type == (XFRM_MSG_GETPOLICY - XFRM_MSG_BASE)) &&
2190-
(nlh->nlmsg_flags & NLM_F_DUMP)) {
2190+
(nlh->nlmsg_flags & NLM_F_DUMP) == NLM_F_DUMP) {
21912191
if (link->dump == NULL)
21922192
return -EINVAL;
21932193

0 commit comments

Comments
 (0)