diff options
| author | Jiri Benc <jbenc@redhat.com> | 2013-11-07 13:59:19 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2013-11-08 15:12:11 -0500 |
| commit | cdbe7c2d6d485459801838c244c409b938e32df5 (patch) | |
| tree | adaff9745719732f3ff93abae3f52fa94b80db18 | |
| parent | 13eb2ab2d33c57ebddc57437a7d341995fc9138c (diff) | |
nfnetlink: do not ack malformed messages
Commit 0628b123c96d ("netfilter: nfnetlink: add batch support and use it
from nf_tables") introduced a bug leading to various crashes in netlink_ack
when netlink message with invalid nlmsg_len was sent by an unprivileged
user.
Signed-off-by: Jiri Benc <jbenc@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | net/netfilter/nfnetlink.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c index 027f16af51a0..046aa13b4fea 100644 --- a/net/netfilter/nfnetlink.c +++ b/net/netfilter/nfnetlink.c | |||
| @@ -363,13 +363,15 @@ static void nfnetlink_rcv(struct sk_buff *skb) | |||
| 363 | struct net *net = sock_net(skb->sk); | 363 | struct net *net = sock_net(skb->sk); |
| 364 | int msglen; | 364 | int msglen; |
| 365 | 365 | ||
| 366 | if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) | ||
| 367 | return netlink_ack(skb, nlh, -EPERM); | ||
| 368 | |||
| 369 | if (nlh->nlmsg_len < NLMSG_HDRLEN || | 366 | if (nlh->nlmsg_len < NLMSG_HDRLEN || |
| 370 | skb->len < nlh->nlmsg_len) | 367 | skb->len < nlh->nlmsg_len) |
| 371 | return; | 368 | return; |
| 372 | 369 | ||
| 370 | if (!ns_capable(net->user_ns, CAP_NET_ADMIN)) { | ||
| 371 | netlink_ack(skb, nlh, -EPERM); | ||
| 372 | return; | ||
| 373 | } | ||
| 374 | |||
| 373 | if (nlh->nlmsg_type == NFNL_MSG_BATCH_BEGIN) { | 375 | if (nlh->nlmsg_type == NFNL_MSG_BATCH_BEGIN) { |
| 374 | struct nfgenmsg *nfgenmsg; | 376 | struct nfgenmsg *nfgenmsg; |
| 375 | 377 | ||
