selinux: use __GFP_NOWARN with GFP_NOWAIT in the AVC
[ Upstream commit 648f2c6100cfa18e7dfe43bc0b9c3b73560d623c ]
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] 476accbe2f
("selinux: use GFP_NOWAIT in the AVC kmem_caches")
Signed-off-by: Minchan Kim <minchan@kernel.org>
[PM: subj fix, line wraps, normalized commit refs]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
0a244be95b
commit
f38371821c
@@ -297,26 +297,27 @@ static struct avc_xperms_decision_node
|
|||||||
struct avc_xperms_decision_node *xpd_node;
|
struct avc_xperms_decision_node *xpd_node;
|
||||||
struct extended_perms_decision *xpd;
|
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)
|
if (!xpd_node)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
xpd = &xpd_node->xpd;
|
xpd = &xpd_node->xpd;
|
||||||
if (which & XPERMS_ALLOWED) {
|
if (which & XPERMS_ALLOWED) {
|
||||||
xpd->allowed = kmem_cache_zalloc(avc_xperms_data_cachep,
|
xpd->allowed = kmem_cache_zalloc(avc_xperms_data_cachep,
|
||||||
GFP_NOWAIT);
|
GFP_NOWAIT | __GFP_NOWARN);
|
||||||
if (!xpd->allowed)
|
if (!xpd->allowed)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (which & XPERMS_AUDITALLOW) {
|
if (which & XPERMS_AUDITALLOW) {
|
||||||
xpd->auditallow = kmem_cache_zalloc(avc_xperms_data_cachep,
|
xpd->auditallow = kmem_cache_zalloc(avc_xperms_data_cachep,
|
||||||
GFP_NOWAIT);
|
GFP_NOWAIT | __GFP_NOWARN);
|
||||||
if (!xpd->auditallow)
|
if (!xpd->auditallow)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
if (which & XPERMS_DONTAUDIT) {
|
if (which & XPERMS_DONTAUDIT) {
|
||||||
xpd->dontaudit = kmem_cache_zalloc(avc_xperms_data_cachep,
|
xpd->dontaudit = kmem_cache_zalloc(avc_xperms_data_cachep,
|
||||||
GFP_NOWAIT);
|
GFP_NOWAIT | __GFP_NOWARN);
|
||||||
if (!xpd->dontaudit)
|
if (!xpd->dontaudit)
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
@@ -344,7 +345,7 @@ static struct avc_xperms_node *avc_xperms_alloc(void)
|
|||||||
{
|
{
|
||||||
struct avc_xperms_node *xp_node;
|
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)
|
if (!xp_node)
|
||||||
return xp_node;
|
return xp_node;
|
||||||
INIT_LIST_HEAD(&xp_node->xpd_head);
|
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;
|
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)
|
if (!node)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user