* [PATCH] openvswitch: add null pointer check on upcall
@ 2017-11-09 13:59 Colin King
2017-11-09 14:06 ` [ovs-dev] " Pravin Shelar
0 siblings, 1 reply; 2+ messages in thread
From: Colin King @ 2017-11-09 13:59 UTC (permalink / raw)
To: Pravin Shelar, David S . Miller, netdev, dev
Cc: kernel-janitors, linux-kernel
From: Colin Ian King <colin.king@canonical.com>
upcall may be assigned a NULL pointer as genlmsg_put can potentially
return a NULL. Add a null check to avoid a null pointer dereference
on upcall.
Detected by CoverityScan, CID#728404 ("Dereference null return value")
Fixes: commit ccb1352e76cf ("net: Add Open vSwitch kernel components.")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
net/openvswitch/datapath.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
index 4d38ac044cee..e8fb3d76fa6e 100644
--- a/net/openvswitch/datapath.c
+++ b/net/openvswitch/datapath.c
@@ -461,6 +461,10 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
upcall = genlmsg_put(user_skb, 0, 0, &dp_packet_genl_family,
0, upcall_info->cmd);
+ if (!upcall) {
+ err = -ENOBUFS;
+ goto out;
+ }
upcall->dp_ifindex = dp_ifindex;
err = ovs_nla_put_key(key, key, OVS_PACKET_ATTR_KEY, false, user_skb);
--
2.14.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [ovs-dev] [PATCH] openvswitch: add null pointer check on upcall
2017-11-09 13:59 [PATCH] openvswitch: add null pointer check on upcall Colin King
@ 2017-11-09 14:06 ` Pravin Shelar
0 siblings, 0 replies; 2+ messages in thread
From: Pravin Shelar @ 2017-11-09 14:06 UTC (permalink / raw)
To: Colin King
Cc: Pravin Shelar, David S . Miller, Linux Kernel Network Developers,
ovs dev, kernel-janitors, linux-kernel
On Thu, Nov 9, 2017 at 7:29 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> upcall may be assigned a NULL pointer as genlmsg_put can potentially
> return a NULL. Add a null check to avoid a null pointer dereference
> on upcall.
>
> Detected by CoverityScan, CID#728404 ("Dereference null return value")
>
> Fixes: commit ccb1352e76cf ("net: Add Open vSwitch kernel components.")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
> net/openvswitch/datapath.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c
> index 4d38ac044cee..e8fb3d76fa6e 100644
> --- a/net/openvswitch/datapath.c
> +++ b/net/openvswitch/datapath.c
> @@ -461,6 +461,10 @@ static int queue_userspace_packet(struct datapath *dp, struct sk_buff *skb,
>
> upcall = genlmsg_put(user_skb, 0, 0, &dp_packet_genl_family,
> 0, upcall_info->cmd);
> + if (!upcall) {
> + err = -ENOBUFS;
> + goto out;
> + }
user_skb is allocated according to all required attributes, so
genlmsg_put() can not return null value.
> upcall->dp_ifindex = dp_ifindex;
>
> err = ovs_nla_put_key(key, key, OVS_PACKET_ATTR_KEY, false, user_skb);
> --
> 2.14.1
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-09 14:06 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-09 13:59 [PATCH] openvswitch: add null pointer check on upcall Colin King
2017-11-09 14:06 ` [ovs-dev] " Pravin Shelar
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).