linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Yafang Shao <laoar.shao@gmail.com>
To: pablo@netfilter.org, kadlec@blackhole.kfki.hu, fw@strlen.de,
	davem@davemloft.net, adobriyan@gmail.com,
	akpm@linux-foundation.org
Cc: netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org,
	linux-kernel@vger.kernel.org, Yafang Shao <laoar.shao@gmail.com>
Subject: [PATCH 4/5] netfilter: fix missed NULL check in nf_conntrack_proto_pernet_init()
Date: Wed,  5 Dec 2018 20:56:29 +0800	[thread overview]
Message-ID: <1544014590-14429-4-git-send-email-laoar.shao@gmail.com> (raw)
In-Reply-To: <1544014590-14429-1-git-send-email-laoar.shao@gmail.com>

nf_ct_l4proto_net() may return NULL.
That may happens if some module forget to set both l4proto->get_net_proto
and l4proto->net_id.
We'd check the return value here, in case crash happens.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 net/netfilter/nf_conntrack_proto.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
index 154e8c0..316fef3 100644
--- a/net/netfilter/nf_conntrack_proto.c
+++ b/net/netfilter/nf_conntrack_proto.c
@@ -946,6 +946,9 @@ int nf_conntrack_proto_pernet_init(struct net *net)
 	struct nf_proto_net *pn = nf_ct_l4proto_net(net,
 					&nf_conntrack_l4proto_generic);
 
+	if (pn == NULL)
+		return -EINVAL;
+
 	err = nf_conntrack_l4proto_generic.init_net(net);
 	if (err < 0)
 		return err;
-- 
1.8.3.1


  parent reply	other threads:[~2018-12-05 12:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05 12:56 [PATCH 1/5] netfilter: fix general protection fault when unregister sysctl table Yafang Shao
2018-12-05 12:56 ` [PATCH 2/5] netfilter: register sysctl table for gre Yafang Shao
2018-12-05 12:56 ` [PATCH 3/5] procfs: fix double drop_sysctl_table() Yafang Shao
2018-12-05 12:56 ` Yafang Shao [this message]
2018-12-12 23:26   ` [PATCH 4/5] netfilter: fix missed NULL check in nf_conntrack_proto_pernet_init() Pablo Neira Ayuso
2018-12-13  9:50     ` Yafang Shao
2018-12-05 12:56 ` [PATCH 5/5] netfilter: fix error return value of nf_ct_l4proto_pernet_register_one() Yafang Shao

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=1544014590-14429-4-git-send-email-laoar.shao@gmail.com \
    --to=laoar.shao@gmail.com \
    --cc=adobriyan@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=fw@strlen.de \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.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).