* [PATCH] ipset: fix a missing check of nla_parse
@ 2018-12-26 3:50 Kangjie Lu
2018-12-26 9:16 ` Kirill Tkhai
0 siblings, 1 reply; 4+ messages in thread
From: Kangjie Lu @ 2018-12-26 3:50 UTC (permalink / raw)
To: kjlu
Cc: pakki001, Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
David S. Miller, Kirill Tkhai, Stefano Brivio, Andrey Ryabinin,
netfilter-devel, coreteam, netdev, linux-kernel
When nla_parse fails, we should not use the results (the first
argument). The fix checks if it fails, and if so, returns its error code
upstream.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
---
net/netfilter/ipset/ip_set_core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
index 1577f2f76060..4dc8057cff02 100644
--- a/net/netfilter/ipset/ip_set_core.c
+++ b/net/netfilter/ipset/ip_set_core.c
@@ -1531,8 +1531,10 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
memcpy(&errmsg->msg, nlh, nlh->nlmsg_len);
cmdattr = (void *)&errmsg->msg + min_len;
- nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
+ ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
nlh->nlmsg_len - min_len, ip_set_adt_policy, NULL);
+ if (ret)
+ return ret;
errline = nla_data(cda[IPSET_ATTR_LINENO]);
--
2.17.2 (Apple Git-113)
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ipset: fix a missing check of nla_parse
2018-12-26 3:50 [PATCH] ipset: fix a missing check of nla_parse Kangjie Lu
@ 2018-12-26 9:16 ` Kirill Tkhai
2019-01-09 22:43 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Kirill Tkhai @ 2018-12-26 9:16 UTC (permalink / raw)
To: Kangjie Lu
Cc: pakki001, Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
David S. Miller, Stefano Brivio, Andrey Ryabinin,
netfilter-devel, coreteam, netdev, linux-kernel
On 26.12.2018 06:50, Kangjie Lu wrote:
> When nla_parse fails, we should not use the results (the first
> argument). The fix checks if it fails, and if so, returns its error code
> upstream.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> net/netfilter/ipset/ip_set_core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
> index 1577f2f76060..4dc8057cff02 100644
> --- a/net/netfilter/ipset/ip_set_core.c
> +++ b/net/netfilter/ipset/ip_set_core.c
> @@ -1531,8 +1531,10 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
> memcpy(&errmsg->msg, nlh, nlh->nlmsg_len);
> cmdattr = (void *)&errmsg->msg + min_len;
>
> - nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
> + ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
> nlh->nlmsg_len - min_len, ip_set_adt_policy, NULL);
> + if (ret)
> + return ret;
In this function above nlmsg_new() allocates skb2, but I don't see, where you free it here.
>
> errline = nla_data(cda[IPSET_ATTR_LINENO]);
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipset: fix a missing check of nla_parse
2018-12-26 9:16 ` Kirill Tkhai
@ 2019-01-09 22:43 ` Pablo Neira Ayuso
2019-01-10 8:54 ` Kirill Tkhai
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2019-01-09 22:43 UTC (permalink / raw)
To: Kirill Tkhai
Cc: Kangjie Lu, pakki001, Jozsef Kadlecsik, Florian Westphal,
David S. Miller, Stefano Brivio, Andrey Ryabinin,
netfilter-devel, coreteam, netdev, linux-kernel
On Wed, Dec 26, 2018 at 12:16:25PM +0300, Kirill Tkhai wrote:
> On 26.12.2018 06:50, Kangjie Lu wrote:
> > When nla_parse fails, we should not use the results (the first
> > argument). The fix checks if it fails, and if so, returns its error code
> > upstream.
> >
> > Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> > ---
> > net/netfilter/ipset/ip_set_core.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
> > index 1577f2f76060..4dc8057cff02 100644
> > --- a/net/netfilter/ipset/ip_set_core.c
> > +++ b/net/netfilter/ipset/ip_set_core.c
> > @@ -1531,8 +1531,10 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
> > memcpy(&errmsg->msg, nlh, nlh->nlmsg_len);
> > cmdattr = (void *)&errmsg->msg + min_len;
> >
> > - nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
> > + ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
> > nlh->nlmsg_len - min_len, ip_set_adt_policy, NULL);
@Kangjie: nitpick, could you align this line below? ie.
ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
nlh->nlmsg_len - min_len, ip_set_adt_policy,
NULL);
> > + if (ret)
> > + return ret;
>
> In this function above nlmsg_new() allocates skb2, but I don't see, where you free it here.
netlink_unicast() is responsible for releasing this skb2.
> > errline = nla_data(cda[IPSET_ATTR_LINENO]);
> >
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ipset: fix a missing check of nla_parse
2019-01-09 22:43 ` Pablo Neira Ayuso
@ 2019-01-10 8:54 ` Kirill Tkhai
0 siblings, 0 replies; 4+ messages in thread
From: Kirill Tkhai @ 2019-01-10 8:54 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: Kangjie Lu, pakki001, Jozsef Kadlecsik, Florian Westphal,
David S. Miller, Stefano Brivio, Andrey Ryabinin,
netfilter-devel, coreteam, netdev, linux-kernel
On 10.01.2019 01:43, Pablo Neira Ayuso wrote:
> On Wed, Dec 26, 2018 at 12:16:25PM +0300, Kirill Tkhai wrote:
>> On 26.12.2018 06:50, Kangjie Lu wrote:
>>> When nla_parse fails, we should not use the results (the first
>>> argument). The fix checks if it fails, and if so, returns its error code
>>> upstream.
>>>
>>> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
>>> ---
>>> net/netfilter/ipset/ip_set_core.c | 4 +++-
>>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
>>> index 1577f2f76060..4dc8057cff02 100644
>>> --- a/net/netfilter/ipset/ip_set_core.c
>>> +++ b/net/netfilter/ipset/ip_set_core.c
>>> @@ -1531,8 +1531,10 @@ call_ad(struct sock *ctnl, struct sk_buff *skb, struct ip_set *set,
>>> memcpy(&errmsg->msg, nlh, nlh->nlmsg_len);
>>> cmdattr = (void *)&errmsg->msg + min_len;
>>>
>>> - nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
>>> + ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
>>> nlh->nlmsg_len - min_len, ip_set_adt_policy, NULL);
>
> @Kangjie: nitpick, could you align this line below? ie.
>
> ret = nla_parse(cda, IPSET_ATTR_CMD_MAX, cmdattr,
> nlh->nlmsg_len - min_len, ip_set_adt_policy,
> NULL);
>
>>> + if (ret)
>>> + return ret;
>>
>> In this function above nlmsg_new() allocates skb2, but I don't see, where you free it here.
>
> netlink_unicast() is responsible for releasing this skb2.
We return earlier at "if (ret)", so netlink_unicast() is not called.
>>> errline = nla_data(cda[IPSET_ATTR_LINENO]);
Kirill
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-01-10 8:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-26 3:50 [PATCH] ipset: fix a missing check of nla_parse Kangjie Lu
2018-12-26 9:16 ` Kirill Tkhai
2019-01-09 22:43 ` Pablo Neira Ayuso
2019-01-10 8:54 ` Kirill Tkhai
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).