@@ -726,7 +726,10 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
726726 if (table == NULL )
727727 goto err2 ;
728728
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+
730733 INIT_LIST_HEAD (& table -> chains );
731734 INIT_LIST_HEAD (& table -> sets );
732735 INIT_LIST_HEAD (& table -> objects );
@@ -735,10 +738,12 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
735738 nft_ctx_init (& ctx , net , skb , nlh , afi , table , NULL , nla );
736739 err = nft_trans_table_add (& ctx , NFT_MSG_NEWTABLE );
737740 if (err < 0 )
738- goto err3 ;
741+ goto err4 ;
739742
740743 list_add_tail_rcu (& table -> list , & afi -> tables );
741744 return 0 ;
745+ err4 :
746+ kfree (table -> name );
742747err3 :
743748 kfree (table );
744749err2 :
@@ -865,6 +870,7 @@ static void nf_tables_table_destroy(struct nft_ctx *ctx)
865870{
866871 BUG_ON (ctx -> table -> use > 0 );
867872
873+ kfree (ctx -> table -> name );
868874 kfree (ctx -> table );
869875 module_put (ctx -> afi -> owner );
870876}
@@ -1972,7 +1978,7 @@ static void nf_tables_rule_notify(const struct nft_ctx *ctx,
19721978}
19731979
19741980struct nft_rule_dump_ctx {
1975- char table [ NFT_TABLE_MAXNAMELEN ] ;
1981+ char * table ;
19761982 char chain [NFT_CHAIN_MAXNAMELEN ];
19771983};
19781984
@@ -1997,7 +2003,7 @@ static int nf_tables_dump_rules(struct sk_buff *skb,
19972003 continue ;
19982004
19992005 list_for_each_entry_rcu (table , & afi -> tables , list ) {
2000- if (ctx && ctx -> table [ 0 ] &&
2006+ if (ctx && ctx -> table &&
20012007 strcmp (ctx -> table , table -> name ) != 0 )
20022008 continue ;
20032009
@@ -2037,7 +2043,12 @@ static int nf_tables_dump_rules(struct sk_buff *skb,
20372043
20382044static int nf_tables_dump_rules_done (struct netlink_callback * cb )
20392045{
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+ }
20412052 return 0 ;
20422053}
20432054
@@ -2069,9 +2080,14 @@ static int nf_tables_getrule(struct net *net, struct sock *nlsk,
20692080 if (!ctx )
20702081 return - ENOMEM ;
20712082
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+ }
20752091 if (nla [NFTA_RULE_CHAIN ])
20762092 nla_strlcpy (ctx -> chain , nla [NFTA_RULE_CHAIN ],
20772093 sizeof (ctx -> chain ));
@@ -4410,7 +4426,7 @@ static int nf_tables_fill_obj_info(struct sk_buff *skb, struct net *net,
44104426}
44114427
44124428struct nft_obj_filter {
4413- char table [ NFT_OBJ_MAXNAMELEN ] ;
4429+ char * table ;
44144430 u32 type ;
44154431};
44164432
@@ -4475,7 +4491,10 @@ static int nf_tables_dump_obj(struct sk_buff *skb, struct netlink_callback *cb)
44754491
44764492static int nf_tables_dump_obj_done (struct netlink_callback * cb )
44774493{
4478- kfree (cb -> data );
4494+ struct nft_obj_filter * filter = cb -> data ;
4495+
4496+ kfree (filter -> table );
4497+ kfree (filter );
44794498
44804499 return 0 ;
44814500}
@@ -4489,9 +4508,13 @@ nft_obj_filter_alloc(const struct nlattr * const nla[])
44894508 if (!filter )
44904509 return ERR_PTR (- ENOMEM );
44914510
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+ }
44954518 if (nla [NFTA_OBJ_TYPE ])
44964519 filter -> type = ntohl (nla_get_be32 (nla [NFTA_OBJ_TYPE ]));
44974520
0 commit comments