* [PATCH 6.1] netfilter: Null pointer dereference in nf_tables_updobj
@ 2023-01-17 13:45 Alok Tiwari
2023-01-17 14:17 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Alok Tiwari @ 2023-01-17 13:45 UTC (permalink / raw)
To: linux-kernel, netfilter-devel; +Cc: alok.a.tiwari
static analyzer detect null pointer dereference case for 'type'
function __nft_obj_type_get() can return NULL value which require to handle
if type is NULL pointer return -ENOENT
Signed-off-by: Alok Tiwari <alok.a.tiwari@oracle.com>
---
net/netfilter/nf_tables_api.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 3ba8c291fcaa..e20f1de1c216 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -6951,6 +6951,9 @@ static int nf_tables_newobj(struct sk_buff *skb, const struct nfnl_info *info,
return -EOPNOTSUPP;
type = __nft_obj_type_get(objtype);
+ if (!WARN_ON_ONCE(type))
+ return -ENOENT;
+
nft_ctx_init(&ctx, net, skb, info->nlh, family, table, NULL, nla);
return nf_tables_updobj(&ctx, type, nla[NFTA_OBJ_DATA], obj);
--
2.38.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 6.1] netfilter: Null pointer dereference in nf_tables_updobj
2023-01-17 13:45 [PATCH 6.1] netfilter: Null pointer dereference in nf_tables_updobj Alok Tiwari
@ 2023-01-17 14:17 ` Pablo Neira Ayuso
2023-01-17 15:27 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2023-01-17 14:17 UTC (permalink / raw)
To: Alok Tiwari; +Cc: linux-kernel, netfilter-devel
On Tue, Jan 17, 2023 at 05:45:38AM -0800, Alok Tiwari wrote:
> static analyzer detect null pointer dereference case for 'type'
> function __nft_obj_type_get() can return NULL value which require to handle
> if type is NULL pointer return -ENOENT
This should not ever happen, but it is good to have a failsafe in this
path.
I'll take this into nf.git, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 6.1] netfilter: Null pointer dereference in nf_tables_updobj
2023-01-17 14:17 ` Pablo Neira Ayuso
@ 2023-01-17 15:27 ` Pablo Neira Ayuso
0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2023-01-17 15:27 UTC (permalink / raw)
To: Alok Tiwari; +Cc: linux-kernel, netfilter-devel
On Tue, Jan 17, 2023 at 03:17:11PM +0100, Pablo Neira Ayuso wrote:
> On Tue, Jan 17, 2023 at 05:45:38AM -0800, Alok Tiwari wrote:
> > static analyzer detect null pointer dereference case for 'type'
> > function __nft_obj_type_get() can return NULL value which require to handle
> > if type is NULL pointer return -ENOENT
>
> This should not ever happen, but it is good to have a failsafe in this
> path.
>
> I'll take this into nf.git, thanks.
BTW, easier to read:
if (WARN_ON_ONCE(!type))
instead of:
if (!WARN_ON_ONCE(type))
I'll mangle the patch here before applying, unless you prefer to send a v2.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-17 15:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-17 13:45 [PATCH 6.1] netfilter: Null pointer dereference in nf_tables_updobj Alok Tiwari
2023-01-17 14:17 ` Pablo Neira Ayuso
2023-01-17 15:27 ` Pablo Neira Ayuso
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).