ipset: enable memory accounting for ipset allocations
Subsystems (2)
PATCH 1/1 ipset: enable memory accounting for ipset allocations
Currently netadmin inside non-trusted container can quickly allocate whole node's memory via request of huge ipset hashtable. Other ipset-related memory allocations should be restricted too.
--- net/netfilter/ipset/ip_set_core.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
net/netfilter/ipset/ip_set_core.c +1 -16
@@ -250,22 +250,7 @@ static struct ip_set_net *ip_set_pernet(struct net *net)void *ip_set_alloc (size_t size) { -void *members =NULL ; - -if (size <KMALLOC_MAX_SIZE ) - members =kzalloc (size,GFP_KERNEL | __GFP_NOWARN); - -if (members) { -pr_debug ("%p: allocated with kmalloc\n" , members); -return members; - } - - members =vzalloc (size); -if (!members) -return NULL ; -pr_debug ("%p: allocated with vmalloc\n" , members); - -return members; +return kvzalloc (size,GFP_KERNEL_ALLOC ); }EXPORT_SYMBOL_GPL (ip_set_alloc);
Signature · 1 line
1.8.3.1
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Vasily,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on nf/master]
[also build test ERROR on nf-next/master ipvs/master v5.9-rc6 next-20200924] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Vasily-Averin/ipset-enable-memory-accounting-for-ipset-allocations/20200925-135627 base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master config: xtensa-allyesconfig (attached as .config) compiler: xtensa-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/828ea197585b5e87760b3d5615b52919ab9a3b10
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Vasily-Averin/ipset-enable-memory-accounting-for-ipset-allocations/20200925-135627 git checkout 828ea197585b5e87760b3d5615b52919ab9a3b10
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=xtensa
If you fix the issue, kindly add following tag as appropriate
All error/warnings (new ones prefixed by >>):
net/netfilter/ipset/ip_set_core.c: In function 'ip_set_alloc':
>> net/netfilter/ipset/ip_set_core.c:253:24: error: 'GFP_KERNEL_ALLOC' undeclared (first use in this function); did you mean 'GFP_KERNEL_ACCOUNT'?
253 | return kvzalloc(size, GFP_KERNEL_ALLOC);
| ^~~~~~~~~~~~~~~~
| GFP_KERNEL_ACCOUNT
net/netfilter/ipset/ip_set_core.c:253:24: note: each undeclared identifier is reported only once for each function it appears in
>> net/netfilter/ipset/ip_set_core.c:254:1: warning: control reaches end of non-void function [-Wreturn-type]
254 | }
| ^vim +253 net/netfilter/ipset/ip_set_core.c
248
249 /* Utility functions */
250 void *
251 ip_set_alloc(size_t size)
252 {
> 253 return kvzalloc(size, GFP_KERNEL_ALLOC); > 254 }
255 EXPORT_SYMBOL_GPL(ip_set_alloc);
256
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
PATCH v2 1/1 ipset: enable memory accounting for ipset allocations
Currently netadmin inside non-trusted container can quickly allocate whole node's memory via request of huge ipset hashtable. Other ipset-related memory allocations should be restricted too.
v2: fixed typo ALLOC -> ACCOUNT
--- net/netfilter/ipset/ip_set_core.c | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-)
net/netfilter/ipset/ip_set_core.c +1 -16
@@ -250,22 +250,7 @@ static struct ip_set_net *ip_set_pernet(struct net *net)void *ip_set_alloc (size_t size) { -void *members =NULL ; - -if (size <KMALLOC_MAX_SIZE ) - members =kzalloc (size,GFP_KERNEL | __GFP_NOWARN); - -if (members) { -pr_debug ("%p: allocated with kmalloc\n" , members); -return members; - } - - members =vzalloc (size); -if (!members) -return NULL ; -pr_debug ("%p: allocated with vmalloc\n" , members); - -return members; +return kvzalloc (size,GFP_KERNEL_ACCOUNT ); }EXPORT_SYMBOL_GPL (ip_set_alloc);
Signature · 1 line
1.8.3.1
Quoted 3 lines · Vasily Averin
Currently netadmin inside non-trusted container can quickly allocate whole node's memory via request of huge ipset hashtable. Other ipset-related memory allocations should be restricted too.
Applied, thanks.
kernel test robot
build botThank you for the patch! Yet something to improve:
Hi Vasily,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on nf/master]
[also build test ERROR on nf-next/master ipvs/master v5.9-rc6 next-20200924] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Vasily-Averin/ipset-enable-memory-accounting-for-ipset-allocations/20200925-135627 base: https://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf.git master config: x86_64-rhel (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/828ea197585b5e87760b3d5615b52919ab9a3b10 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Vasily-Averin/ipset-enable-memory-accounting-for-ipset-allocations/20200925-135627 git checkout 828ea197585b5e87760b3d5615b52919ab9a3b10 # save the attached .config to linux build tree make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
net/netfilter/ipset/ip_set_core.c: In function 'ip_set_alloc':
>> net/netfilter/ipset/ip_set_core.c:253:24: error: 'GFP_KERNEL_ALLOC' undeclared (first use in this function); did you mean 'GFP_KERNEL_ACCOUNT'?
253 | return kvzalloc(size, GFP_KERNEL_ALLOC);
| ^~~~~~~~~~~~~~~~
| GFP_KERNEL_ACCOUNT
net/netfilter/ipset/ip_set_core.c:253:24: note: each undeclared identifier is reported only once for each function it appears in
net/netfilter/ipset/ip_set_core.c:254:1: warning: control reaches end of non-void function [-Wreturn-type]
254 | }
| ^
--
>> drivers/gpu/drm/vmwgfx/ttm_object.c:60: error: Cannot parse struct or union! drivers/gpu/drm/vmwgfx/ttm_object.c:98: warning: Function parameter or member 'mem_glob' not described in 'ttm_object_device' drivers/gpu/drm/vmwgfx/ttm_object.c:98: warning: Function parameter or member 'ops' not described in 'ttm_object_device' drivers/gpu/drm/vmwgfx/ttm_object.c:98: warning: Function parameter or member 'dmabuf_release' not described in 'ttm_object_device' drivers/gpu/drm/vmwgfx/ttm_object.c:98: warning: Function parameter or member 'dma_buf_size' not described in 'ttm_object_device' drivers/gpu/drm/vmwgfx/ttm_object.c:98: warning: Function parameter or member 'idr' not described in 'ttm_object_device' drivers/gpu/drm/vmwgfx/ttm_object.c:129: warning: Function parameter or member 'rcu_head' not described in 'ttm_ref_object' drivers/gpu/drm/vmwgfx/ttm_object.c:129: warning: Function parameter or member 'tfile' not described in 'ttm_ref_object' drivers/gpu/drm/vmwgfx/ttm_object.c:583: warning: Function parameter or member 'dmabuf' not described in 'get_dma_buf_unless_doomed' drivers/gpu/drm/vmwgfx/ttm_object.c:583: warning: Excess function parameter 'dma_buf' description in 'get_dma_buf_unless_doomed'
vim +253 net/netfilter/ipset/ip_set_core.c
248
249 /* Utility functions */
250 void *
251 ip_set_alloc(size_t size)
252 {
> 253 return kvzalloc(size, GFP_KERNEL_ALLOC);
254 }
255 EXPORT_SYMBOL_GPL(ip_set_alloc);
256
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org