selinux: use __GFP_NOWARN with GFP_NOWAIT
Subsystems (2)
PATCH 1/1 selinux: use __GFP_NOWARN with GFP_NOWAIT
In the field, we have seen lots of allocation failure from the call path below.
06-03 13:29:12.999 1010315 31557 31557 W Binder : 31542_2: page allocation failure: order:0, mode:0x800(GFP_NOWAIT), nodemask=(null),cpuset=background,mems_allowed=0
...
...
06-03 13:29:12.999 1010315 31557 31557 W Call trace:
06-03 13:29:12.999 1010315 31557 31557 W : dump_backtrace.cfi_jt+0x0/0x8 06-03 13:29:12.999 1010315 31557 31557 W : dump_stack+0xc8/0x14c 06-03 13:29:12.999 1010315 31557 31557 W : warn_alloc+0x158/0x1c8 06-03 13:29:12.999 1010315 31557 31557 W : __alloc_pages_slowpath+0x9d8/0xb80 06-03 13:29:12.999 1010315 31557 31557 W : __alloc_pages_nodemask+0x1c4/0x430 06-03 13:29:12.999 1010315 31557 31557 W : allocate_slab+0xb4/0x390 06-03 13:29:12.999 1010315 31557 31557 W : ___slab_alloc+0x12c/0x3a4 06-03 13:29:12.999 1010315 31557 31557 W : kmem_cache_alloc+0x358/0x5e4 06-03 13:29:12.999 1010315 31557 31557 W : avc_alloc_node+0x30/0x184 06-03 13:29:12.999 1010315 31557 31557 W : avc_update_node+0x54/0x4f0 06-03 13:29:12.999 1010315 31557 31557 W : avc_has_extended_perms+0x1a4/0x460 06-03 13:29:12.999 1010315 31557 31557 W : selinux_file_ioctl+0x320/0x3d0 06-03 13:29:12.999 1010315 31557 31557 W : __arm64_sys_ioctl+0xec/0x1fc 06-03 13:29:12.999 1010315 31557 31557 W : el0_svc_common+0xc0/0x24c 06-03 13:29:12.999 1010315 31557 31557 W : el0_svc+0x28/0x88 06-03 13:29:12.999 1010315 31557 31557 W : el0_sync_handler+0x8c/0xf0 06-03 13:29:12.999 1010315 31557 31557 W : el0_sync+0x1a4/0x1c0 .. .. 06-03 13:29:12.999 1010315 31557 31557 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:12.999 1010315 31557 31557 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0 06-03 13:29:12.999 1010315 31557 31557 W node 0 : slabs: 57, objs: 2907, free: 0 06-03 13:29:12.999 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:12.999 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0 06-03 13:29:12.999 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0 06-03 13:29:12.999 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:12.999 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0 06-03 13:29:12.999 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0 06-03 13:29:12.999 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:12.999 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0 06-03 13:29:12.999 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0 06-03 13:29:13.000 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:13.000 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0 06-03 13:29:13.000 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0 06-03 13:29:13.000 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:13.000 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0 06-03 13:29:13.000 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0 06-03 13:29:13.000 1010161 10686 10686 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:13.000 1010161 10686 10686 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0 06-03 13:29:13.000 1010161 10686 10686 W node 0 : slabs: 57, objs: 2907, free: 0 06-03 13:29:13.000 10230 30892 30892 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:13.000 10230 30892 30892 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0 06-03 13:29:13.000 10230 30892 30892 W node 0 : slabs: 57, objs: 2907, free: 0 06-03 13:29:13.000 10230 30892 30892 W SLUB : Unable to allocate memory on node -1, gfp=0x900(GFP_NOWAIT|__GFP_ZERO) 06-03 13:29:13.000 10230 30892 30892 W cache : avc_node, object size: 72, buffer size: 80, default order: 0, min order: 0
Based on [1], selinux is tolerate for failure of memory allocation. Then, use __GFP_NOWARN together.
[1] 476accbe2f6e, selinux: use GFP_NOWAIT in the AVC kmem_caches
--- security/selinux/avc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
security/selinux/avc.c +7 -6
@@ -297,26 +297,27 @@ static struct avc_xperms_decision_nodestruct avc_xperms_decision_node *xpd_node;struct extended_perms_decision *xpd; - xpd_node =kmem_cache_zalloc (avc_xperms_decision_cachep,GFP_NOWAIT ); + xpd_node =kmem_cache_zalloc (avc_xperms_decision_cachep, +GFP_NOWAIT | __GFP_NOWARN);if (!xpd_node)return NULL ; xpd = &xpd_node->xpd;if (which &XPERMS_ALLOWED ) { xpd->allowed =kmem_cache_zalloc (avc_xperms_data_cachep, -GFP_NOWAIT ); +GFP_NOWAIT | __GFP_NOWARN);if (!xpd->allowed) goto error; }if (which &XPERMS_AUDITALLOW ) { xpd->auditallow =kmem_cache_zalloc (avc_xperms_data_cachep, -GFP_NOWAIT ); +GFP_NOWAIT | __GFP_NOWARN);if (!xpd->auditallow) goto error; }if (which &XPERMS_DONTAUDIT ) { xpd->dontaudit =kmem_cache_zalloc (avc_xperms_data_cachep, -GFP_NOWAIT ); +GFP_NOWAIT | __GFP_NOWARN);if (!xpd->dontaudit) goto error; }
@@ -344,7 +345,7 @@ static struct avc_xperms_node *avc_xperms_alloc(void) {struct avc_xperms_node *xp_node; - xp_node =kmem_cache_zalloc (avc_xperms_cachep,GFP_NOWAIT ); + xp_node =kmem_cache_zalloc (avc_xperms_cachep,GFP_NOWAIT | __GFP_NOWARN);if (!xp_node)return xp_node;INIT_LIST_HEAD (&xp_node->xpd_head);
@@ -500,7 +501,7 @@ static struct avc_node *avc_alloc_node(struct selinux_avc *avc) {struct avc_node *node; - node =kmem_cache_zalloc (avc_node_cachep,GFP_NOWAIT ); + node =kmem_cache_zalloc (avc_node_cachep,GFP_NOWAIT | __GFP_NOWARN);if (!node) goto out;
Signature · 1 line
2.32.0.rc1.229.g3e70b5a671-goog
Andrew Morton
maintainerQuoted 7 lines · On Wed, 9 Jun 2021 09:37:17 -0700 Minchan Kim <[email protected]> wrote:
In the field, we have seen lots of allocation failure from the call path below.
...
Based on [1], selinux is tolerate for failure of memory allocation. Then, use
__GFP_NOWARNtogether.
Thanks. I trust that the selinux developers will process this patch.
Paul Moore
maintainerQuoted 11 lines · Andrew Morton
Quoted 7 lines · On Wed, 9 Jun 2021 09:37:17 -0700 Minchan Kim <[email protected]> wrote:
In the field, we have seen lots of allocation failure from the call path below.
...
Based on [1], selinux is tolerate for failure of memory allocation. Then, use
__GFP_NOWARNtogether.Thanks. I trust that the selinux developers will process this patch.
That's the plan; this is in my review queue for this evening.
Signature · 2 lines
paul moore www.paul-moore.com
Paul Moore
maintainerQuoted 7 lines · Paul Moore
Quoted 6 lines · Andrew Morton
Quoted 4 lines · On Wed, 9 Jun 2021 09:37:17 -0700 Minchan Kim <[email protected]> wrote:
In the field, we have seen lots of allocation failure from the call path below.
...
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Based on [1], selinux is tolerate for failure of memory allocation. Then, use
__GFP_NOWARNtogether.Thanks. I trust that the selinux developers will process this patch.
That's the plan; this is in my review queue for this evening.
Looks fine to me, merged into selinux/next - thanks!
Signature · 2 lines
paul moore www.paul-moore.com