* [PATCH] ovs: queue_userspace_packet: bail out if nla_nest_start returns NULL
@ 2013-07-03 8:49 Daniel Borkmann
2013-07-03 16:32 ` Jesse Gross
0 siblings, 1 reply; 3+ messages in thread
From: Daniel Borkmann @ 2013-07-03 8:49 UTC (permalink / raw)
To: jesse; +Cc: netdev, dev
The return value of nla_nest_start() is not checked, and can be NULL,
which is then being dereferenced in nla_nest_end(). Add a check to
prevent such situations.
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
---
On top of "net-next" tree.
net/openvswitch/datapath.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index d12d6b8..51a3c66 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -427,6 +427,10 @@ static int queue_userspace_packet(struct net *net, int dp_ifindex,
upcall->dp_ifindex = dp_ifindex;
nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY);
+ if (unlikely(!nla)) {
+ err = -ENOMEM;
+ goto out;
+ }
ovs_flow_to_nlattrs(upcall_info->key, user_skb);
nla_nest_end(user_skb, nla);
--
1.7.11.7
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] ovs: queue_userspace_packet: bail out if nla_nest_start returns NULL
2013-07-03 8:49 [PATCH] ovs: queue_userspace_packet: bail out if nla_nest_start returns NULL Daniel Borkmann
@ 2013-07-03 16:32 ` Jesse Gross
2013-07-03 17:13 ` Daniel Borkmann
0 siblings, 1 reply; 3+ messages in thread
From: Jesse Gross @ 2013-07-03 16:32 UTC (permalink / raw)
To: Daniel Borkmann; +Cc: netdev, dev@openvswitch.org
On Wed, Jul 3, 2013 at 1:49 AM, Daniel Borkmann <dborkman@redhat.com> wrote:
> The return value of nla_nest_start() is not checked, and can be NULL,
> which is then being dereferenced in nla_nest_end(). Add a check to
> prevent such situations.
>
> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
> ---
> On top of "net-next" tree.
>
> net/openvswitch/datapath.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index d12d6b8..51a3c66 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -427,6 +427,10 @@ static int queue_userspace_packet(struct net *net, int dp_ifindex,
> upcall->dp_ifindex = dp_ifindex;
>
> nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY);
> + if (unlikely(!nla)) {
> + err = -ENOMEM;
> + goto out;
> + }
nla_nest_start() doesn't allocate any memory, it only fails if there
isn't enough space, so the correct error code would be -EMSGSIZE.
However, we just calculated the correct size a few lines earlier and
we don't double check the size anywhere else, so this doesn't make a
lot of sense to me.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] ovs: queue_userspace_packet: bail out if nla_nest_start returns NULL
2013-07-03 16:32 ` Jesse Gross
@ 2013-07-03 17:13 ` Daniel Borkmann
0 siblings, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2013-07-03 17:13 UTC (permalink / raw)
To: Jesse Gross; +Cc: netdev, dev@openvswitch.org
On 07/03/2013 06:32 PM, Jesse Gross wrote:
> On Wed, Jul 3, 2013 at 1:49 AM, Daniel Borkmann <dborkman@redhat.com> wrote:
>> The return value of nla_nest_start() is not checked, and can be NULL,
>> which is then being dereferenced in nla_nest_end(). Add a check to
>> prevent such situations.
>>
>> Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
>> ---
>> On top of "net-next" tree.
>>
>> net/openvswitch/datapath.c | 4 ++++
>> 1 file changed, 4 insertions(+)
>>
>> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
>> index d12d6b8..51a3c66 100644
>> --- a/net/openvswitch/datapath.c
>> +++ b/net/openvswitch/datapath.c
>> @@ -427,6 +427,10 @@ static int queue_userspace_packet(struct net *net, int dp_ifindex,
>> upcall->dp_ifindex = dp_ifindex;
>>
>> nla = nla_nest_start(user_skb, OVS_PACKET_ATTR_KEY);
>> + if (unlikely(!nla)) {
>> + err = -ENOMEM;
>> + goto out;
>> + }
>
> nla_nest_start() doesn't allocate any memory, it only fails if there
> isn't enough space, so the correct error code would be -EMSGSIZE.
> However, we just calculated the correct size a few lines earlier and
> we don't double check the size anywhere else, so this doesn't make a
> lot of sense to me.
Fair enough, please drop this then.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-07-03 17:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-03 8:49 [PATCH] ovs: queue_userspace_packet: bail out if nla_nest_start returns NULL Daniel Borkmann
2013-07-03 16:32 ` Jesse Gross
2013-07-03 17:13 ` Daniel Borkmann
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).