* Re: [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse
2023-12-14 8:15 [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse syzbot
@ 2023-12-14 13:59 ` syzbot
2023-12-14 14:18 ` syzbot
` (3 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: syzbot @ 2023-12-14 13:59 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse
Author: eadavis@qq.com
please test slab-out-of-bounds Read in dns_resolver_preparse
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 48e8992e33ab
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 10ba439968f7..f28ba8a703fe 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -83,7 +83,7 @@ SYSCALL_DEFINE5(add_key, const char __user *, _type,
long ret;
ret = -EINVAL;
- if (plen > 1024 * 1024 - 1)
+ if (plen > 1024 * 1024 - 1 || plen < 48)
goto error;
/* draw all the data into kernel space */
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse
2023-12-14 8:15 [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse syzbot
2023-12-14 13:59 ` syzbot
@ 2023-12-14 14:18 ` syzbot
2023-12-14 14:33 ` [PATCH next] keys/dns: datalen must greater than sizeof(*v1) Edward Adam Davis
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: syzbot @ 2023-12-14 14:18 UTC (permalink / raw)
To: linux-kernel
For archival purposes, forwarding an incoming command email to
linux-kernel@vger.kernel.org.
***
Subject: [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse
Author: eadavis@qq.com
please test slab-out-of-bounds Read in dns_resolver_preparse
#syz test https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git 48e8992e33ab
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 3233f4f25fed..15f19521021c 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -104,7 +104,7 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
if (data[0] == 0) {
/* It may be a server list. */
- if (datalen <= sizeof(*bin))
+ if (datalen <= sizeof(*v1))
return -EINVAL;
bin = (const struct dns_payload_header *)data;
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH next] keys/dns: datalen must greater than sizeof(*v1)
2023-12-14 8:15 [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse syzbot
2023-12-14 13:59 ` syzbot
2023-12-14 14:18 ` syzbot
@ 2023-12-14 14:33 ` Edward Adam Davis
2023-12-14 14:46 ` [PATCH V2 next] keys/dns: fix slab-out-of-bounds in dns_resolver_preparse Edward Adam Davis
2023-12-15 3:00 ` [PATCH next] keys/dns: datalen must greater than sizeof(*v1) Jarkko Sakkinen
2023-12-23 23:17 ` [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse David Howells
2023-12-23 23:34 ` David Howells
4 siblings, 2 replies; 11+ messages in thread
From: Edward Adam Davis @ 2023-12-14 14:33 UTC (permalink / raw)
To: syzbot+94bbb75204a05da3d89f
Cc: davem, dhowells, edumazet, jarkko, jmorris, keyrings, kuba,
linux-kernel, linux-security-module, netdev, pabeni, paul, serge,
syzkaller-bugs
bin will be forcibly converted to "struct dns_server_list_v1_header *", so it
is necessary to compare datalen with sizeof(*v1).
Fixes: b946001d3bb1 ("keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry")
Reported-and-tested-by: syzbot+94bbb75204a05da3d89f@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
net/dns_resolver/dns_key.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 3233f4f25fed..15f19521021c 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -104,7 +104,7 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
if (data[0] == 0) {
/* It may be a server list. */
- if (datalen <= sizeof(*bin))
+ if (datalen <= sizeof(*v1))
return -EINVAL;
bin = (const struct dns_payload_header *)data;
^ permalink raw reply related [flat|nested] 11+ messages in thread* [PATCH V2 next] keys/dns: fix slab-out-of-bounds in dns_resolver_preparse
2023-12-14 14:33 ` [PATCH next] keys/dns: datalen must greater than sizeof(*v1) Edward Adam Davis
@ 2023-12-14 14:46 ` Edward Adam Davis
2023-12-16 21:06 ` Simon Horman
2023-12-15 3:00 ` [PATCH next] keys/dns: datalen must greater than sizeof(*v1) Jarkko Sakkinen
1 sibling, 1 reply; 11+ messages in thread
From: Edward Adam Davis @ 2023-12-14 14:46 UTC (permalink / raw)
To: eadavis
Cc: davem, dhowells, edumazet, jarkko, jmorris, keyrings, kuba,
linux-kernel, linux-security-module, netdev, pabeni, paul, serge,
syzbot+94bbb75204a05da3d89f, syzkaller-bugs
bin will be forcibly converted to "struct dns_server_list_v1_header *", so it
is necessary to compare datalen with sizeof(*v1).
Fixes: b946001d3bb1 ("keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry")
Reported-and-tested-by: syzbot+94bbb75204a05da3d89f@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
net/dns_resolver/dns_key.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 3233f4f25fed..15f19521021c 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -104,7 +104,7 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
if (data[0] == 0) {
/* It may be a server list. */
- if (datalen <= sizeof(*bin))
+ if (datalen <= sizeof(*v1))
return -EINVAL;
bin = (const struct dns_payload_header *)data;
--
2.43.0
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [PATCH V2 next] keys/dns: fix slab-out-of-bounds in dns_resolver_preparse
2023-12-14 14:46 ` [PATCH V2 next] keys/dns: fix slab-out-of-bounds in dns_resolver_preparse Edward Adam Davis
@ 2023-12-16 21:06 ` Simon Horman
0 siblings, 0 replies; 11+ messages in thread
From: Simon Horman @ 2023-12-16 21:06 UTC (permalink / raw)
To: Edward Adam Davis
Cc: davem, dhowells, edumazet, jarkko, jmorris, keyrings, kuba,
linux-kernel, linux-security-module, netdev, pabeni, paul, serge,
syzbot+94bbb75204a05da3d89f, syzkaller-bugs
On Thu, Dec 14, 2023 at 10:46:10PM +0800, Edward Adam Davis wrote:
> bin will be forcibly converted to "struct dns_server_list_v1_header *", so it
> is necessary to compare datalen with sizeof(*v1).
>
> Fixes: b946001d3bb1 ("keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry")
> Reported-and-tested-by: syzbot+94bbb75204a05da3d89f@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> net/dns_resolver/dns_key.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
This change looks correct to me.
And I agree that it addresses a problem introduced by the cited commit.
I also note that it depends on the cited commit, which is not present in net.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH next] keys/dns: datalen must greater than sizeof(*v1)
2023-12-14 14:33 ` [PATCH next] keys/dns: datalen must greater than sizeof(*v1) Edward Adam Davis
2023-12-14 14:46 ` [PATCH V2 next] keys/dns: fix slab-out-of-bounds in dns_resolver_preparse Edward Adam Davis
@ 2023-12-15 3:00 ` Jarkko Sakkinen
1 sibling, 0 replies; 11+ messages in thread
From: Jarkko Sakkinen @ 2023-12-15 3:00 UTC (permalink / raw)
To: Edward Adam Davis, syzbot+94bbb75204a05da3d89f
Cc: davem, dhowells, edumazet, jmorris, keyrings, kuba, linux-kernel,
linux-security-module, netdev, pabeni, paul, serge,
syzkaller-bugs
On Thu Dec 14, 2023 at 4:33 PM EET, Edward Adam Davis wrote:
> bin will be forcibly converted to "struct dns_server_list_v1_header *", so it
> is necessary to compare datalen with sizeof(*v1).
>
> Fixes: b946001d3bb1 ("keys, dns: Allow key types (eg. DNS) to be reclaimed immediately on expiry")
> Reported-and-tested-by: syzbot+94bbb75204a05da3d89f@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
> net/dns_resolver/dns_key.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
> index 3233f4f25fed..15f19521021c 100644
> --- a/net/dns_resolver/dns_key.c
> +++ b/net/dns_resolver/dns_key.c
> @@ -104,7 +104,7 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
>
> if (data[0] == 0) {
> /* It may be a server list. */
> - if (datalen <= sizeof(*bin))
> + if (datalen <= sizeof(*v1))
> return -EINVAL;
>
> bin = (const struct dns_payload_header *)data;
Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
BR, Jarkko
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse
2023-12-14 8:15 [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse syzbot
` (2 preceding siblings ...)
2023-12-14 14:33 ` [PATCH next] keys/dns: datalen must greater than sizeof(*v1) Edward Adam Davis
@ 2023-12-23 23:17 ` David Howells
2023-12-23 23:17 ` syzbot
2023-12-23 23:34 ` David Howells
4 siblings, 1 reply; 11+ messages in thread
From: David Howells @ 2023-12-23 23:17 UTC (permalink / raw)
To: syzbot
Cc: dhowells, davem, edumazet, jarkko, jmorris, keyrings, kuba,
linux-kernel, linux-security-module, netdev, pabeni, paul, serge,
syzkaller-bugs
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 2a6d363763a2..f18ca02aa95a 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -91,8 +91,6 @@ const struct cred *dns_resolver_cache;
static int
dns_resolver_preparse(struct key_preparsed_payload *prep)
{
- const struct dns_server_list_v1_header *v1;
- const struct dns_payload_header *bin;
struct user_key_payload *upayload;
unsigned long derrno;
int ret;
@@ -103,27 +101,28 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
return -EINVAL;
if (data[0] == 0) {
+ const struct dns_server_list_v1_header *v1;
+
/* It may be a server list. */
- if (datalen <= sizeof(*bin))
+ if (datalen <= sizeof(*v1))
return -EINVAL;
- bin = (const struct dns_payload_header *)data;
- kenter("[%u,%u],%u", bin->content, bin->version, datalen);
- if (bin->content != DNS_PAYLOAD_IS_SERVER_LIST) {
+ v1 = (const struct dns_server_list_v1_header *)data;
+ kenter("[%u,%u],%u", v1->hdr.content, v1->hdr.version, datalen);
+ if (v1->hdr.content != DNS_PAYLOAD_IS_SERVER_LIST) {
pr_warn_ratelimited(
"dns_resolver: Unsupported content type (%u)\n",
- bin->content);
+ v1->hdr.content);
return -EINVAL;
}
- if (bin->version != 1) {
+ if (v1->hdr.version != 1) {
pr_warn_ratelimited(
"dns_resolver: Unsupported server list version (%u)\n",
- bin->version);
+ v1->hdr.version);
return -EINVAL;
}
- v1 = (const struct dns_server_list_v1_header *)bin;
if ((v1->status != DNS_LOOKUP_GOOD &&
v1->status != DNS_LOOKUP_GOOD_WITH_BAD)) {
if (prep->expiry == TIME64_MAX)
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse
2023-12-23 23:17 ` [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse David Howells
@ 2023-12-23 23:17 ` syzbot
0 siblings, 0 replies; 11+ messages in thread
From: syzbot @ 2023-12-23 23:17 UTC (permalink / raw)
To: dhowells
Cc: davem, dhowells, edumazet, jarkko, jmorris, keyrings, kuba,
linux-kernel, linux-security-module, netdev, pabeni, paul, serge,
syzkaller-bugs
> #syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
want either no args or 2 args (repo, branch), got 5
>
> diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
> index 2a6d363763a2..f18ca02aa95a 100644
> --- a/net/dns_resolver/dns_key.c
> +++ b/net/dns_resolver/dns_key.c
> @@ -91,8 +91,6 @@ const struct cred *dns_resolver_cache;
> static int
> dns_resolver_preparse(struct key_preparsed_payload *prep)
> {
> - const struct dns_server_list_v1_header *v1;
> - const struct dns_payload_header *bin;
> struct user_key_payload *upayload;
> unsigned long derrno;
> int ret;
> @@ -103,27 +101,28 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
> return -EINVAL;
>
> if (data[0] == 0) {
> + const struct dns_server_list_v1_header *v1;
> +
> /* It may be a server list. */
> - if (datalen <= sizeof(*bin))
> + if (datalen <= sizeof(*v1))
> return -EINVAL;
>
> - bin = (const struct dns_payload_header *)data;
> - kenter("[%u,%u],%u", bin->content, bin->version, datalen);
> - if (bin->content != DNS_PAYLOAD_IS_SERVER_LIST) {
> + v1 = (const struct dns_server_list_v1_header *)data;
> + kenter("[%u,%u],%u", v1->hdr.content, v1->hdr.version, datalen);
> + if (v1->hdr.content != DNS_PAYLOAD_IS_SERVER_LIST) {
> pr_warn_ratelimited(
> "dns_resolver: Unsupported content type (%u)\n",
> - bin->content);
> + v1->hdr.content);
> return -EINVAL;
> }
>
> - if (bin->version != 1) {
> + if (v1->hdr.version != 1) {
> pr_warn_ratelimited(
> "dns_resolver: Unsupported server list version (%u)\n",
> - bin->version);
> + v1->hdr.version);
> return -EINVAL;
> }
>
> - v1 = (const struct dns_server_list_v1_header *)bin;
> if ((v1->status != DNS_LOOKUP_GOOD &&
> v1->status != DNS_LOOKUP_GOOD_WITH_BAD)) {
> if (prep->expiry == TIME64_MAX)
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse
2023-12-14 8:15 [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse syzbot
` (3 preceding siblings ...)
2023-12-23 23:17 ` [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse David Howells
@ 2023-12-23 23:34 ` David Howells
2023-12-23 23:59 ` syzbot
4 siblings, 1 reply; 11+ messages in thread
From: David Howells @ 2023-12-23 23:34 UTC (permalink / raw)
To: syzbot
Cc: dhowells, davem, edumazet, jarkko, jmorris, keyrings, kuba,
linux-kernel, linux-security-module, netdev, pabeni, paul, serge,
syzkaller-bugs
#syz test: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
diff --git a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
index 2a6d363763a2..f18ca02aa95a 100644
--- a/net/dns_resolver/dns_key.c
+++ b/net/dns_resolver/dns_key.c
@@ -91,8 +91,6 @@ const struct cred *dns_resolver_cache;
static int
dns_resolver_preparse(struct key_preparsed_payload *prep)
{
- const struct dns_server_list_v1_header *v1;
- const struct dns_payload_header *bin;
struct user_key_payload *upayload;
unsigned long derrno;
int ret;
@@ -103,27 +101,28 @@ dns_resolver_preparse(struct key_preparsed_payload *prep)
return -EINVAL;
if (data[0] == 0) {
+ const struct dns_server_list_v1_header *v1;
+
/* It may be a server list. */
- if (datalen <= sizeof(*bin))
+ if (datalen <= sizeof(*v1))
return -EINVAL;
- bin = (const struct dns_payload_header *)data;
- kenter("[%u,%u],%u", bin->content, bin->version, datalen);
- if (bin->content != DNS_PAYLOAD_IS_SERVER_LIST) {
+ v1 = (const struct dns_server_list_v1_header *)data;
+ kenter("[%u,%u],%u", v1->hdr.content, v1->hdr.version, datalen);
+ if (v1->hdr.content != DNS_PAYLOAD_IS_SERVER_LIST) {
pr_warn_ratelimited(
"dns_resolver: Unsupported content type (%u)\n",
- bin->content);
+ v1->hdr.content);
return -EINVAL;
}
- if (bin->version != 1) {
+ if (v1->hdr.version != 1) {
pr_warn_ratelimited(
"dns_resolver: Unsupported server list version (%u)\n",
- bin->version);
+ v1->hdr.version);
return -EINVAL;
}
- v1 = (const struct dns_server_list_v1_header *)bin;
if ((v1->status != DNS_LOOKUP_GOOD &&
v1->status != DNS_LOOKUP_GOOD_WITH_BAD)) {
if (prep->expiry == TIME64_MAX)
^ permalink raw reply related [flat|nested] 11+ messages in thread* Re: [syzbot] [net?] KASAN: slab-out-of-bounds Read in dns_resolver_preparse
2023-12-23 23:34 ` David Howells
@ 2023-12-23 23:59 ` syzbot
0 siblings, 0 replies; 11+ messages in thread
From: syzbot @ 2023-12-23 23:59 UTC (permalink / raw)
To: davem, dhowells, edumazet, jarkko, jmorris, keyrings, kuba,
linux-kernel, linux-security-module, netdev, pabeni, paul, serge,
syzkaller-bugs
Hello,
syzbot has tested the proposed patch and the reproducer did not trigger any issue:
Reported-and-tested-by: syzbot+94bbb75204a05da3d89f@syzkaller.appspotmail.com
Tested on:
commit: 3f82f1c3 Merge tag 'x86-urgent-2023-12-23' of git://gi..
git tree: upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=132be7e9e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=9f7c7b3fa354ead9
dashboard link: https://syzkaller.appspot.com/bug?extid=94bbb75204a05da3d89f
compiler: gcc (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=15ef6e26e80000
Note: testing is done by a robot and is best-effort only.
^ permalink raw reply [flat|nested] 11+ messages in thread