From: Thomas Graf <tgraf@suug.ch>
To: Hong Zhiguo <honkiko@gmail.com>
Cc: netdev@vger.kernel.org, davem@davemloft.net, stephen@networkplumber.org
Subject: Re: [PATCH net-next] netlink: add missing length check of rtnl msg
Date: Mon, 25 Mar 2013 23:12:04 +0000 [thread overview]
Message-ID: <20130325231204.GC27194@casper.infradead.org> (raw)
In-Reply-To: <1364232143-16754-1-git-send-email-honkiko@gmail.com>
On 03/26/13 at 01:22am, Hong Zhiguo wrote:
> protocol = TC_H_MIN(t->tcm_info);
> diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
> index 0bbce22..b30a988 100644
> --- a/net/sched/sch_api.c
> +++ b/net/sched/sch_api.c
> @@ -977,7 +977,7 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n)
> struct tcmsg *tcm = nlmsg_data(n);
> struct nlattr *tca[TCA_MAX + 1];
> struct net_device *dev;
> - u32 clid = tcm->tcm_parent;
> + u32 clid;
> struct Qdisc *q = NULL;
> struct Qdisc *p = NULL;
> int err;
> @@ -985,6 +985,9 @@ static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n)
> if ((n->nlmsg_type != RTM_GETQDISC) && !capable(CAP_NET_ADMIN))
> return -EPERM;
>
> + if (nlmsg_len(n) < sizeof(*tcm))
> + return -EINVAL;
> +
> dev = __dev_get_by_index(net, tcm->tcm_ifindex);
> if (!dev)
> return -ENODEV;
What do you think about moving the nlmsg_parse() call from below here
to before __dev_get_by_index()? It also verifies the header length and
it's how other netlink code verifies the message type specific header
as well.
> if (err < 0)
> @@ -1051,6 +1055,9 @@ static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n)
> if (!capable(CAP_NET_ADMIN))
> return -EPERM;
>
> + if (nlmsg_len(n) < sizeof(*tcm))
> + return -EINVAL;
> +
Same here.
> replay:
> /* Reinit, just in case something touches this. */
> tcm = nlmsg_data(n);
> @@ -1382,14 +1389,17 @@ static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n)
> const struct Qdisc_class_ops *cops;
> unsigned long cl = 0;
> unsigned long new_cl;
> - u32 portid = tcm->tcm_parent;
> - u32 clid = tcm->tcm_handle;
> - u32 qid = TC_H_MAJ(clid);
> + u32 portid;
> + u32 clid;
> + u32 qid;
> int err;
>
> if ((n->nlmsg_type != RTM_GETTCLASS) && !capable(CAP_NET_ADMIN))
> return -EPERM;
>
> + if (nlmsg_len(n) < sizeof(*tcm))
> + return -EINVAL;
> +
> dev = __dev_get_by_index(net, tcm->tcm_ifindex);
> if (!dev)
> return -ENODEV;
And here.
next prev parent reply other threads:[~2013-03-25 23:12 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-25 17:22 [PATCH net-next] netlink: add missing length check of rtnl msg Hong Zhiguo
2013-03-25 17:54 ` David Miller
2013-03-25 23:12 ` Thomas Graf [this message]
2013-03-26 3:36 ` [PATCH v2 net-next] netlink: have length check of rtnl msg before deref Hong Zhiguo
2013-03-26 8:59 ` Thomas Graf
2013-03-26 16:36 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130325231204.GC27194@casper.infradead.org \
--to=tgraf@suug.ch \
--cc=davem@davemloft.net \
--cc=honkiko@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=stephen@networkplumber.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).