From: Florian Westphal <fw@strlen•de>
To: <netdev@vger•kernel.org>
Cc: steffen.klassert@secunet•com, syzkaller-bugs@googlegroups•com,
Florian Westphal <fw@strlen•de>,
Herbert Xu <herbert@gondor•apana.org.au>,
Timo Teras <timo.teras@iki•fi>,
Christophe Gouault <christophe.gouault@6wind•com>
Subject: [PATCH ipsec] xfrm: skip policies marked as dead while rehashing
Date: Wed, 27 Dec 2017 23:25:45 +0100 [thread overview]
Message-ID: <20171227222545.22219-1-fw@strlen.de> (raw)
In-Reply-To: <001a1140f578d314ec0560d9f29a@google.com>
syzkaller triggered following KASAN splat:
BUG: KASAN: slab-out-of-bounds in xfrm_hash_rebuild+0xdbe/0xf00 net/xfrm/xfrm_policy.c:618
read of size 2 at addr ffff8801c8e92fe4 by task kworker/1:1/23 [..]
Workqueue: events xfrm_hash_rebuild [..]
__asan_report_load2_noabort+0x14/0x20 mm/kasan/report.c:428
xfrm_hash_rebuild+0xdbe/0xf00 net/xfrm/xfrm_policy.c:618
process_one_work+0xbbf/0x1b10 kernel/workqueue.c:2112
worker_thread+0x223/0x1990 kernel/workqueue.c:2246 [..]
The reproducer triggers:
1016 if (error) {
1017 list_move_tail(&walk->walk.all, &x->all);
1018 goto out;
1019 }
in xfrm_policy_walk() via pfkey (it sets tiny rcv space, dump
callback returns -ENOBUFS).
In this case, *walk is located the pfkey socket struct, so this socket
becomes visible in the global policy list.
It looks like this is intentional -- phony walker has walk.dead set to 1
and all other places skip such "policies".
Ccing original authors of the two commits that seem to expose this
issue (first patch missed ->dead check, second patch adds pfkey
sockets to policies dumper list).
Fixes: 880a6fab8f6ba5b ("xfrm: configure policy hash table thresholds by netlink")
Fixes: 12a169e7d8f4b1c ("ipsec: Put dumpers on the dump list")
Cc: Herbert Xu <herbert@gondor•apana.org.au>
Cc: Timo Teras <timo.teras@iki•fi>
Cc: Christophe Gouault <christophe.gouault@6wind•com>
Reported-by: syzbot <bot+c028095236fcb6f4348811565b75084c754dc729@syzkaller•appspotmail.com>
Signed-off-by: Florian Westphal <fw@strlen•de>
---
net/xfrm/xfrm_policy.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index 9542975eb2f9..181bc6181789 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -609,7 +609,8 @@ static void xfrm_hash_rebuild(struct work_struct *work)
/* re-insert all policies by order of creation */
list_for_each_entry_reverse(policy, &net->xfrm.policy_all, walk.all) {
- if (xfrm_policy_id2dir(policy->index) >= XFRM_POLICY_MAX) {
+ if (policy->walk.dead ||
+ xfrm_policy_id2dir(policy->index) >= XFRM_POLICY_MAX) {
/* skip socket policies */
continue;
}
--
2.13.6
next prev parent reply other threads:[~2017-12-27 22:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-07 20:28 KASAN: slab-out-of-bounds Read in xfrm_hash_rebuild syzbot
2017-12-21 13:48 ` syzbot
2017-12-27 22:25 ` Florian Westphal [this message]
2017-12-31 7:50 ` [PATCH ipsec] xfrm: skip policies marked as dead while rehashing Steffen Klassert
2018-01-31 1:59 ` Eric Biggers
2018-01-31 1:59 ` syzbot
2018-01-31 2:02 ` KASAN: slab-out-of-bounds Read in xfrm_hash_rebuild Eric Biggers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171227222545.22219-1-fw@strlen.de \
--to=fw@strlen$(echo .)de \
--cc=christophe.gouault@6wind$(echo .)com \
--cc=herbert@gondor$(echo .)apana.org.au \
--cc=netdev@vger$(echo .)kernel.org \
--cc=steffen.klassert@secunet$(echo .)com \
--cc=syzkaller-bugs@googlegroups$(echo .)com \
--cc=timo.teras@iki$(echo .)fi \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox