* [PATCH nf-next] netfilter: nf_tables: use nla_memdup to copy udata
@ 2020-09-28 12:24 Jose M. Guisado Gomez
2020-09-30 9:59 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Jose M. Guisado Gomez @ 2020-09-28 12:24 UTC (permalink / raw)
To: pablo; +Cc: netfilter-devel
When userdata support was added to tables and objects, user data coming
from user space was allocated and copied using kzalloc + nla_memcpy.
Use nla_memdup to copy userdata of tables and objects.
Signed-off-by: Jose M. Guisado Gomez <guigom@riseup.net>
---
net/netfilter/nf_tables_api.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index b3c3c3fc1969..a4393eddaffd 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -1024,11 +1024,10 @@ static int nf_tables_newtable(struct net *net, struct sock *nlsk,
if (nla[NFTA_TABLE_USERDATA]) {
udlen = nla_len(nla[NFTA_TABLE_USERDATA]);
- table->udata = kzalloc(udlen, GFP_KERNEL);
+ table->udata = nla_memdup(nla[NFTA_TABLE_USERDATA], GFP_KERNEL);
if (table->udata == NULL)
goto err_table_udata;
- nla_memcpy(table->udata, nla[NFTA_TABLE_USERDATA], udlen);
table->udlen = udlen;
}
@@ -5958,11 +5957,10 @@ static int nf_tables_newobj(struct net *net, struct sock *nlsk,
if (nla[NFTA_OBJ_USERDATA]) {
udlen = nla_len(nla[NFTA_OBJ_USERDATA]);
- obj->udata = kzalloc(udlen, GFP_KERNEL);
+ obj->udata = nla_memdup(nla[NFTA_OBJ_USERDATA], GFP_KERNEL);
if (obj->udata == NULL)
goto err_userdata;
- nla_memcpy(obj->udata, nla[NFTA_OBJ_USERDATA], udlen);
obj->udlen = udlen;
}
--
2.28.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH nf-next] netfilter: nf_tables: use nla_memdup to copy udata
2020-09-28 12:24 [PATCH nf-next] netfilter: nf_tables: use nla_memdup to copy udata Jose M. Guisado Gomez
@ 2020-09-30 9:59 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2020-09-30 9:59 UTC (permalink / raw)
To: Jose M. Guisado Gomez; +Cc: netfilter-devel
On Mon, Sep 28, 2020 at 02:24:57PM +0200, Jose M. Guisado Gomez wrote:
> When userdata support was added to tables and objects, user data coming
> from user space was allocated and copied using kzalloc + nla_memcpy.
>
> Use nla_memdup to copy userdata of tables and objects.
Applied, thanks.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-30 9:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-28 12:24 [PATCH nf-next] netfilter: nf_tables: use nla_memdup to copy udata Jose M. Guisado Gomez
2020-09-30 9:59 ` 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).