@@ -93,7 +93,7 @@ int nf_ct_add_helper(struct nf_conn *ct, const char *name, u8 family,
if (!helper)
return -EINVAL;
- help = nf_ct_helper_ext_add(ct, GFP_KERNEL);
+ help = nf_ct_helper_ext_add(ct, GFP_KERNEL_ACCOUNT);
if (!help) {
nf_conntrack_helper_put(helper);
return -ENOMEM;
@@ -91,7 +91,7 @@ xt_ct_set_helper(struct nf_conn *ct, const char *helper_name,
return -ENOENT;
}
- help = nf_ct_helper_ext_add(ct, GFP_KERNEL);
+ help = nf_ct_helper_ext_add(ct, GFP_KERNEL_ACCOUNT);
if (help == NULL) {
nf_conntrack_helper_put(helper);
return -ENOMEM;
@@ -182,7 +182,7 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
if (info->flags & XT_CT_ZONE_MARK)
zone.flags |= NF_CT_FLAG_MARK;
- ct = nf_ct_tmpl_alloc(par->net, &zone, GFP_KERNEL);
+ ct = nf_ct_tmpl_alloc(par->net, &zone, GFP_KERNEL_ACCOUNT);
if (!ct) {
ret = -ENOMEM;
goto err2;
@@ -190,7 +190,7 @@ static int xt_ct_tg_check(const struct xt_tgchk_param *par,
if ((info->ct_events || info->exp_events) &&
!nf_ct_ecache_ext_add(ct, info->ct_events, info->exp_events,
- GFP_KERNEL)) {
+ GFP_KERNEL_ACCOUNT)) {
ret = -EINVAL;
goto err3;
}
@@ -147,7 +147,7 @@ static int idletimer_tg_create(struct idletimer_tg_info *info)
{
int ret;
- info->timer = kzalloc_obj(*info->timer);
+ info->timer = kzalloc_obj(*info->timer, GFP_KERNEL_ACCOUNT);
if (!info->timer) {
ret = -ENOMEM;
goto out;
@@ -158,7 +158,7 @@ static int idletimer_tg_create(struct idletimer_tg_info *info)
goto out_free_timer;
sysfs_attr_init(&info->timer->attr.attr);
- info->timer->attr.attr.name = kstrdup(info->label, GFP_KERNEL);
+ info->timer->attr.attr.name = kstrdup(info->label, GFP_KERNEL_ACCOUNT);
if (!info->timer->attr.attr.name) {
ret = -ENOMEM;
goto out_free_timer;
@@ -196,7 +196,7 @@ static int idletimer_tg_create_v1(struct idletimer_tg_info_v1 *info)
{
int ret;
- info->timer = kmalloc_obj(*info->timer);
+ info->timer = kmalloc_obj(*info->timer, GFP_KERNEL_ACCOUNT);
if (!info->timer) {
ret = -ENOMEM;
goto out;
@@ -207,7 +207,7 @@ static int idletimer_tg_create_v1(struct idletimer_tg_info_v1 *info)
goto out_free_timer;
sysfs_attr_init(&info->timer->attr.attr);
- info->timer->attr.attr.name = kstrdup(info->label, GFP_KERNEL);
+ info->timer->attr.attr.name = kstrdup(info->label, GFP_KERNEL_ACCOUNT);
if (!info->timer->attr.attr.name) {
ret = -ENOMEM;
goto out_free_timer;
@@ -111,11 +111,12 @@ static int led_tg_check(const struct xt_tgchk_param *par)
}
err = -ENOMEM;
- ledinternal = kzalloc_obj(struct xt_led_info_internal);
+ ledinternal = kzalloc_obj(struct xt_led_info_internal,
+ GFP_KERNEL_ACCOUNT);
if (!ledinternal)
goto exit_mutex_only;
- ledinternal->trigger_id = kstrdup(ledinfo->id, GFP_KERNEL);
+ ledinternal->trigger_id = kstrdup(ledinfo->id, GFP_KERNEL_ACCOUNT);
if (!ledinternal->trigger_id)
goto exit_internal_alloc;
@@ -139,7 +139,7 @@ static int xt_rateest_tg_checkentry(const struct xt_tgchk_param *par)
}
ret = -ENOMEM;
- est = kzalloc_obj(*est);
+ est = kzalloc_obj(*est, GFP_KERNEL_ACCOUNT);
if (!est)
goto err1;
@@ -106,7 +106,7 @@ static int tee_tg_check(const struct xt_tgchk_param *par)
if (info->oif[sizeof(info->oif)-1] != '\0')
return -EINVAL;
- priv = kzalloc_obj(*priv);
+ priv = kzalloc_obj(*priv, GFP_KERNEL_ACCOUNT);
if (priv == NULL)
return -ENOMEM;
@@ -319,7 +319,7 @@ static int htable_create(struct net *net, struct hashlimit_cfg3 *cfg,
hinfo->count = 0;
hinfo->family = family;
hinfo->rnd_initialized = false;
- hinfo->name = kstrdup(name, GFP_KERNEL);
+ hinfo->name = kstrdup(name, GFP_KERNEL_ACCOUNT);
if (!hinfo->name) {
kvfree(hinfo);
return -ENOMEM;
@@ -115,7 +115,7 @@ static int limit_mt_check(const struct xt_mtchk_param *par)
return -ERANGE;
}
- priv = kmalloc_obj(*priv);
+ priv = kmalloc_obj(*priv, GFP_KERNEL_ACCOUNT);
if (priv == NULL)
return -ENOMEM;
@@ -50,7 +50,7 @@ static int quota_mt_check(const struct xt_mtchk_param *par)
if (q->flags & ~XT_QUOTA_MASK)
return -EINVAL;
- q->master = kmalloc_obj(*q->master);
+ q->master = kmalloc_obj(*q->master, GFP_KERNEL_ACCOUNT);
if (q->master == NULL)
return -ENOMEM;
@@ -391,7 +391,8 @@ static int recent_mt_check(const struct xt_mtchk_param *par,
goto out;
}
- t = kvzalloc_flex(*t, iphash, ip_list_hash_size);
+ t = kvzalloc_flex(*t, iphash, ip_list_hash_size,
+ GFP_KERNEL_ACCOUNT);
if (t == NULL) {
ret = -ENOMEM;
goto out;
@@ -58,7 +58,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
info->flags & ~XT_STATISTIC_MASK)
return -EINVAL;
- info->master = kzalloc_obj(*info->master);
+ info->master = kzalloc_obj(*info->master, GFP_KERNEL_ACCOUNT);
if (info->master == NULL)
return -ENOMEM;
atomic_set(&info->master->count, info->u.nth.count);
@@ -54,7 +54,7 @@ static int string_mt_check(const struct xt_mtchk_param *par)
if (conf->u.v1.flags & XT_STRING_FLAG_IGNORECASE)
flags |= TS_IGNORECASE;
ts_conf = textsearch_prepare(conf->algo, conf->pattern, conf->patlen,
- GFP_KERNEL, flags);
+ GFP_KERNEL_ACCOUNT, flags);
if (IS_ERR(ts_conf))
return PTR_ERR(ts_conf);
GFP_KERNEL_ACCOUNT is preferred these days for memcg, replace GFP_KERNEL by GFP_KERNEL_ACCOUNT. Use GFP_KERNEL_ACCOUNT for objects that are allocated in the xtables .check path. This includes template ct object with extensions such as helper and timeout. Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> --- net/netfilter/nf_conntrack_ovs.c | 2 +- net/netfilter/xt_CT.c | 6 +++--- net/netfilter/xt_IDLETIMER.c | 8 ++++---- net/netfilter/xt_LED.c | 5 +++-- net/netfilter/xt_RATEEST.c | 2 +- net/netfilter/xt_TEE.c | 2 +- net/netfilter/xt_hashlimit.c | 2 +- net/netfilter/xt_limit.c | 2 +- net/netfilter/xt_quota.c | 2 +- net/netfilter/xt_recent.c | 3 ++- net/netfilter/xt_statistic.c | 2 +- net/netfilter/xt_string.c | 2 +- 12 files changed, 20 insertions(+), 18 deletions(-)