* [PATCH] crypto: af_alg - add keylen checking to avoid NULL ptr passing down
@ 2017-12-18 11:09 Li Kun
2017-12-18 12:00 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Li Kun @ 2017-12-18 11:09 UTC (permalink / raw)
To: linux-crypto; +Cc: stable
alg_setkey do not check the keylen whether it is zero, so the key
may be ZERO_SIZE_PTR when keylen is 0, which will pass the
copy_from_user's checking and be passed to the lower functions as key.
If the lower functions only check the key if it is NULL, ZERO_SIZE_PTR
will pass the checking, and will cause null ptr dereference, so it's
better to intercept the invalid parameters in the upper functions.
This patch is also suitable to fix CVE-2017-15116 for stable trees.
Signed-off-by: Li Kun <hw.likun@huawei.com>
---
crypto/af_alg.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index 337cf38..10f22f3 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -210,6 +210,8 @@ static int alg_setkey(struct sock *sk, char __user *ukey,
u8 *key;
int err;
+ if (!keylen)
+ return -EINVAL;
key = sock_kmalloc(sk, keylen, GFP_KERNEL);
if (!key)
return -ENOMEM;
--
1.8.3.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: af_alg - add keylen checking to avoid NULL ptr passing down
2017-12-18 11:09 [PATCH] crypto: af_alg - add keylen checking to avoid NULL ptr passing down Li Kun
@ 2017-12-18 12:00 ` Greg KH
2017-12-18 13:34 ` Li Kun
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2017-12-18 12:00 UTC (permalink / raw)
To: Li Kun; +Cc: linux-crypto, stable
On Mon, Dec 18, 2017 at 11:09:23AM +0000, Li Kun wrote:
> alg_setkey do not check the keylen whether it is zero, so the key
> may be ZERO_SIZE_PTR when keylen is 0, which will pass the
> copy_from_user's checking and be passed to the lower functions as key.
>
> If the lower functions only check the key if it is NULL, ZERO_SIZE_PTR
> will pass the checking, and will cause null ptr dereference, so it's
> better to intercept the invalid parameters in the upper functions.
>
> This patch is also suitable to fix CVE-2017-15116 for stable trees.
>
> Signed-off-by: Li Kun <hw.likun@huawei.com>
> ---
> crypto/af_alg.c | 2 ++
> 1 file changed, 2 insertions(+)
<formletter>
This is not the correct way to submit patches for inclusion in the
stable kernel tree. Please read:
https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
for how to do this properly.
</formletter>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] crypto: af_alg - add keylen checking to avoid NULL ptr passing down
2017-12-18 12:00 ` Greg KH
@ 2017-12-18 13:34 ` Li Kun
0 siblings, 0 replies; 3+ messages in thread
From: Li Kun @ 2017-12-18 13:34 UTC (permalink / raw)
To: Greg KH; +Cc: linux-crypto, stable
在 2017/12/18 20:00, Greg KH 写道:
> On Mon, Dec 18, 2017 at 11:09:23AM +0000, Li Kun wrote:
>> alg_setkey do not check the keylen whether it is zero, so the key
>> may be ZERO_SIZE_PTR when keylen is 0, which will pass the
>> copy_from_user's checking and be passed to the lower functions as key.
>>
>> If the lower functions only check the key if it is NULL, ZERO_SIZE_PTR
>> will pass the checking, and will cause null ptr dereference, so it's
>> better to intercept the invalid parameters in the upper functions.
>>
>> This patch is also suitable to fix CVE-2017-15116 for stable trees.
>>
>> Signed-off-by: Li Kun <hw.likun@huawei.com>
>> ---
>> crypto/af_alg.c | 2 ++
>> 1 file changed, 2 insertions(+)
> <formletter>
>
> This is not the correct way to submit patches for inclusion in the
> stable kernel tree. Please read:
> https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html
> for how to do this properly.
sorry, i will resend this patch with "Cc: stable@vger.kernel.org"
>
> </formletter>
--
Best Regards
Li Kun
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-12-18 13:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-12-18 11:09 [PATCH] crypto: af_alg - add keylen checking to avoid NULL ptr passing down Li Kun
2017-12-18 12:00 ` Greg KH
2017-12-18 13:34 ` Li Kun
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).