LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH] integrity: add error handling for kmem_cache_create
@ 2018-06-12 4:27 Zhouyang Jia
2018-06-13 20:30 ` Mimi Zohar
0 siblings, 1 reply; 2+ messages in thread
From: Zhouyang Jia @ 2018-06-12 4:27 UTC (permalink / raw)
Cc: Zhouyang Jia, James Morris, Serge E. Hallyn, Mimi Zohar,
Matthew Garrett, Jeff Layton, Thiago Jung Bauermann,
Dmitry Kasatkin, linux-security-module, linux-kernel
When kmem_cache_create fails, the lack of error-handling code may
cause unexpected results.
This patch adds error-handling code after calling kmem_cache_create.
Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
---
security/integrity/iint.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/security/integrity/iint.c b/security/integrity/iint.c
index 149faa8..c074fd8 100644
--- a/security/integrity/iint.c
+++ b/security/integrity/iint.c
@@ -172,6 +172,9 @@ static int __init integrity_iintcache_init(void)
iint_cache =
kmem_cache_create("iint_cache", sizeof(struct integrity_iint_cache),
0, SLAB_PANIC, init_once);
+ if (!iint_cache)
+ return -ENOMEM;
+
return 0;
}
security_initcall(integrity_iintcache_init);
--
2.7.4
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] integrity: add error handling for kmem_cache_create
2018-06-12 4:27 [PATCH] integrity: add error handling for kmem_cache_create Zhouyang Jia
@ 2018-06-13 20:30 ` Mimi Zohar
0 siblings, 0 replies; 2+ messages in thread
From: Mimi Zohar @ 2018-06-13 20:30 UTC (permalink / raw)
To: Zhouyang Jia
Cc: James Morris, Serge E. Hallyn, Matthew Garrett, Jeff Layton,
Thiago Jung Bauermann, Dmitry Kasatkin, linux-security-module,
linux-kernel
On Tue, 2018-06-12 at 12:27 +0800, Zhouyang Jia wrote:
> When kmem_cache_create fails, the lack of error-handling code may
> cause unexpected results.
>
> This patch adds error-handling code after calling kmem_cache_create.
The slab is being create during __init. Under what circumstances do
you expect the allocation to fail? Have you tested what happens if it
fails with/without at least an IMA measurement policy?
Mimi
>
> Signed-off-by: Zhouyang Jia <jiazhouyang09@gmail.com>
> ---
> security/integrity/iint.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/security/integrity/iint.c b/security/integrity/iint.c
> index 149faa8..c074fd8 100644
> --- a/security/integrity/iint.c
> +++ b/security/integrity/iint.c
> @@ -172,6 +172,9 @@ static int __init integrity_iintcache_init(void)
> iint_cache =
> kmem_cache_create("iint_cache", sizeof(struct integrity_iint_cache),
> 0, SLAB_PANIC, init_once);
> + if (!iint_cache)
> + return -ENOMEM;
> +
> return 0;
> }
> security_initcall(integrity_iintcache_init);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-06-13 20:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-12 4:27 [PATCH] integrity: add error handling for kmem_cache_create Zhouyang Jia
2018-06-13 20:30 ` Mimi Zohar
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).