Skip to content

Commit a09d197

Browse files
Hans Schillstromkaber
authored andcommitted
IPVS: fix NULL ptr dereference in ip_vs_ctl.c ip_vs_genl_dump_daemons()
ipvsadm -ln --daemon will trigger a Null pointer exception because ip_vs_genl_dump_daemons() uses skb_net() instead of skb_sknet(). To prevent others from NULL ptr a check is made in ip_vs.h skb_net(). Signed-off-by: Hans Schillstrom <hans.schillstrom@ericsson.com> Signed-off-by: Simon Horman <horms@verge.net.au> Signed-off-by: Patrick McHardy <kaber@trash.net>
1 parent b4232a2 commit a09d197

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

‎include/net/ip_vs.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static inline struct net *skb_net(const struct sk_buff *skb)
5252
*/
5353
if (likely(skb->dev && skb->dev->nd_net))
5454
return dev_net(skb->dev);
55-
if (skb_dst(skb)->dev)
55+
if (skb_dst(skb) && skb_dst(skb)->dev)
5656
return dev_net(skb_dst(skb)->dev);
5757
WARN(skb->sk, "Maybe skb_sknet should be used in %s() at line:%d\n",
5858
__func__, __LINE__);

‎net/netfilter/ipvs/ip_vs_ctl.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3120,7 +3120,7 @@ static int ip_vs_genl_dump_daemon(struct sk_buff *skb, __be32 state,
31203120
static int ip_vs_genl_dump_daemons(struct sk_buff *skb,
31213121
struct netlink_callback *cb)
31223122
{
3123-
struct net *net = skb_net(skb);
3123+
struct net *net = skb_sknet(skb);
31243124
struct netns_ipvs *ipvs = net_ipvs(net);
31253125

31263126
mutex_lock(&__ip_vs_mutex);

0 commit comments

Comments
 (0)