@@ -726,7 +726,10 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
726
726
if (table == NULL )
727
727
goto err2 ;
728
728
729
- nla_strlcpy (table -> name , name , NFT_TABLE_MAXNAMELEN );
729
+ table -> name = nla_strdup (name , GFP_KERNEL );
730
+ if (table -> name == NULL )
731
+ goto err3 ;
732
+
730
733
INIT_LIST_HEAD (& table -> chains );
731
734
INIT_LIST_HEAD (& table -> sets );
732
735
INIT_LIST_HEAD (& table -> objects );
@@ -735,10 +738,12 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
735
738
nft_ctx_init (& ctx , net , skb , nlh , afi , table , NULL , nla );
736
739
err = nft_trans_table_add (& ctx , NFT_MSG_NEWTABLE );
737
740
if (err < 0 )
738
- goto err3 ;
741
+ goto err4 ;
739
742
740
743
list_add_tail_rcu (& table -> list , & afi -> tables );
741
744
return 0 ;
745
+ err4 :
746
+ kfree (table -> name );
742
747
err3 :
743
748
kfree (table );
744
749
err2 :
@@ -865,6 +870,7 @@ static void nf_tables_table_destroy(struct nft_ctx *ctx)
865
870
{
866
871
BUG_ON (ctx -> table -> use > 0 );
867
872
873
+ kfree (ctx -> table -> name );
868
874
kfree (ctx -> table );
869
875
module_put (ctx -> afi -> owner );
870
876
}
@@ -1972,7 +1978,7 @@ static void nf_tables_rule_notify(const struct nft_ctx *ctx,
1972
1978
}
1973
1979
1974
1980
struct nft_rule_dump_ctx {
1975
- char table [ NFT_TABLE_MAXNAMELEN ] ;
1981
+ char * table ;
1976
1982
char chain [NFT_CHAIN_MAXNAMELEN ];
1977
1983
};
1978
1984
@@ -1997,7 +2003,7 @@ static int nf_tables_dump_rules(struct sk_buff *skb,
1997
2003
continue ;
1998
2004
1999
2005
list_for_each_entry_rcu (table , & afi -> tables , list ) {
2000
- if (ctx && ctx -> table [ 0 ] &&
2006
+ if (ctx && ctx -> table &&
2001
2007
strcmp (ctx -> table , table -> name ) != 0 )
2002
2008
continue ;
2003
2009
@@ -2037,7 +2043,12 @@ static int nf_tables_dump_rules(struct sk_buff *skb,
2037
2043
2038
2044
static int nf_tables_dump_rules_done (struct netlink_callback * cb )
2039
2045
{
2040
- kfree (cb -> data );
2046
+ struct nft_rule_dump_ctx * ctx = cb -> data ;
2047
+
2048
+ if (ctx ) {
2049
+ kfree (ctx -> table );
2050
+ kfree (ctx );
2051
+ }
2041
2052
return 0 ;
2042
2053
}
2043
2054
@@ -2069,9 +2080,14 @@ static int nf_tables_getrule(struct net *net, struct sock *nlsk,
2069
2080
if (!ctx )
2070
2081
return - ENOMEM ;
2071
2082
2072
- if (nla [NFTA_RULE_TABLE ])
2073
- nla_strlcpy (ctx -> table , nla [NFTA_RULE_TABLE ],
2074
- sizeof (ctx -> table ));
2083
+ if (nla [NFTA_RULE_TABLE ]) {
2084
+ ctx -> table = nla_strdup (nla [NFTA_RULE_TABLE ],
2085
+ GFP_KERNEL );
2086
+ if (!ctx -> table ) {
2087
+ kfree (ctx );
2088
+ return - ENOMEM ;
2089
+ }
2090
+ }
2075
2091
if (nla [NFTA_RULE_CHAIN ])
2076
2092
nla_strlcpy (ctx -> chain , nla [NFTA_RULE_CHAIN ],
2077
2093
sizeof (ctx -> chain ));
@@ -4410,7 +4426,7 @@ static int nf_tables_fill_obj_info(struct sk_buff *skb, struct net *net,
4410
4426
}
4411
4427
4412
4428
struct nft_obj_filter {
4413
- char table [ NFT_OBJ_MAXNAMELEN ] ;
4429
+ char * table ;
4414
4430
u32 type ;
4415
4431
};
4416
4432
@@ -4475,7 +4491,10 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
4475
4491
4476
4492
static int nf_tables_dump_obj_done (struct netlink_callback * cb )
4477
4493
{
4478
- kfree (cb -> data );
4494
+ struct nft_obj_filter * filter = cb -> data ;
4495
+
4496
+ kfree (filter -> table );
4497
+ kfree (filter );
4479
4498
4480
4499
return 0 ;
4481
4500
}
@@ -4489,9 +4508,13 @@ nft_obj_filter_alloc(const struct nlattr * const nla[])
4489
4508
if (!filter )
4490
4509
return ERR_PTR (- ENOMEM );
4491
4510
4492
- if (nla [NFTA_OBJ_TABLE ])
4493
- nla_strlcpy (filter -> table , nla [NFTA_OBJ_TABLE ],
4494
- NFT_TABLE_MAXNAMELEN );
4511
+ if (nla [NFTA_OBJ_TABLE ]) {
4512
+ filter -> table = nla_strdup (nla [NFTA_OBJ_TABLE ], GFP_KERNEL );
4513
+ if (!filter -> table ) {
4514
+ kfree (filter );
4515
+ return ERR_PTR (- ENOMEM );
4516
+ }
4517
+ }
4495
4518
if (nla [NFTA_OBJ_TYPE ])
4496
4519
filter -> type = ntohl (nla_get_be32 (nla [NFTA_OBJ_TYPE ]));
4497
4520
0 commit comments