* [PATCH] keys: correctly check failed allocation for kmemdup @ 2015-10-15 16:22 ` Insu Yun 2015-10-15 18:57 ` David Howells 0 siblings, 1 reply; 3+ messages in thread From: Insu Yun @ 2015-10-15 16:22 UTC (permalink / raw) To: dhowells, james.l.morris, serge, keyrings, linux-security-module, linux-kernel Cc: taesoo, yeongjin.jang, insu, Insu Yun kmemdup return value is saved in 'key->index_key.description', not 'key->descrption' and kmemdup can be failed in memory pressure. Therefore, key->index_key.description should be checked. Signed-off-by: Insu Yun <wuninsu@gmail.com> --- security/keys/key.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/security/keys/key.c b/security/keys/key.c index aee2ec5..c047846 100644 --- a/security/keys/key.c +++ b/security/keys/key.c @@ -278,7 +278,7 @@ struct key *key_alloc(struct key_type *type, const char *desc, key->index_key.desc_len = desclen; key->index_key.description = kmemdup(desc, desclen + 1, GFP_KERNEL); - if (!key->description) + if (!key->index_key.description) goto no_memory_3; atomic_set(&key->usage, 1); -- 1.9.1 ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] keys: correctly check failed allocation for kmemdup 2015-10-15 16:22 ` [PATCH] keys: correctly check failed allocation for kmemdup Insu Yun @ 2015-10-15 18:57 ` David Howells 2015-10-15 19:40 ` David Howells 0 siblings, 1 reply; 3+ messages in thread From: David Howells @ 2015-10-15 18:57 UTC (permalink / raw) To: Insu Yun Cc: dhowells, james.l.morris, serge, keyrings, linux-security-module, linux-kernel, taesoo, yeongjin.jang, insu Insu Yun <wuninsu@gmail.com> wrote: > kmemdup return value is saved in 'key->index_key.description', not > 'key->descrption' and kmemdup can be failed in memory pressure. > Therefore, key->index_key.description should be checked. The fields are unioned. It makes no difference. David ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] keys: correctly check failed allocation for kmemdup 2015-10-15 18:57 ` David Howells @ 2015-10-15 19:40 ` David Howells 0 siblings, 0 replies; 3+ messages in thread From: David Howells @ 2015-10-15 19:40 UTC (permalink / raw) To: Insu Yun Cc: dhowells, james.l.morris, serge, keyrings, linux-security-module, linux-kernel, Taesoo Kim, Yeongjin Jang, Yun, Insu Insu Yun <wuninsu@gmail.com> wrote: > Thanks David. Then it is not a bug. > It's a pure question. > Why use different name for allocation and check? > For me, it is quite confusing. Either I didn't notice at the time, or the shorter variant is the original. If you want to give me a patch making it consistent, feel free. David ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-10-15 19:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <CAGoFzNe6VAQZd_jYb_rXSB=DhSW4bMm1vgtqwPadHbZLWav42w@mail.gmail.com>
2015-10-15 16:22 ` [PATCH] keys: correctly check failed allocation for kmemdup Insu Yun
2015-10-15 18:57 ` David Howells
2015-10-15 19:40 ` David Howells
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®