From: Hillf Danton <hdanton@sina.com>
To: syzbot <syzbot+6105ffc1ded71d194d6d@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] [keyrings?] [lsm?] KASAN: slab-use-after-free Read in key_put
Date: Wed, 20 Nov 2024 18:42:12 +0800 [thread overview]
Message-ID: <20241120104212.1462-1-hdanton@sina.com> (raw)
In-Reply-To: <673b6aec.050a0220.87769.004a.GAE@google.com>
On Mon, 18 Nov 2024 08:27:24 -0800
> syzbot found the following issue on:
>
> HEAD commit: adc218676eef Linux 6.12
> git tree: upstream
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=11c672e8580000
#syz test
--- x/security/keys/key.c
+++ y/security/keys/key.c
@@ -645,21 +645,30 @@ EXPORT_SYMBOL(key_reject_and_link);
*/
void key_put(struct key *key)
{
+ int quota_flag;
+ unsigned short len;
+ struct key_user *user;
+
if (key) {
key_check(key);
+ quota_flag = test_bit(KEY_FLAG_IN_QUOTA, &key->flags);
+ len = key->quotalen;
+ user = key->user;
+ refcount_inc(&user->usage);
if (refcount_dec_and_test(&key->usage)) {
unsigned long flags;
/* deal with the user's key tracking and quota */
- if (test_bit(KEY_FLAG_IN_QUOTA, &key->flags)) {
- spin_lock_irqsave(&key->user->lock, flags);
- key->user->qnkeys--;
- key->user->qnbytes -= key->quotalen;
- spin_unlock_irqrestore(&key->user->lock, flags);
+ if (quota_flag) {
+ spin_lock_irqsave(&user->lock, flags);
+ user->qnkeys--;
+ user->qnbytes -= len;
+ spin_unlock_irqrestore(&user->lock, flags);
}
schedule_work(&key_gc_work);
}
+ key_user_put(user);
}
}
EXPORT_SYMBOL(key_put);
--
next prev parent reply other threads:[~2024-11-20 10:43 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-18 16:27 [syzbot] [keyrings?] [lsm?] KASAN: slab-use-after-free Read in key_put syzbot
2024-11-18 21:27 ` Suraj Sonawane
2024-11-18 21:37 ` syzbot
2024-11-19 10:36 ` syzbot
2024-11-20 10:42 ` Hillf Danton [this message]
2024-11-20 11:15 ` syzbot
2025-03-19 15:20 ` David Howells
2025-03-19 15:49 ` syzbot
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=20241120104212.1462-1-hdanton@sina.com \
--to=hdanton@sina.com \
--cc=linux-kernel@vger.kernel.org \
--cc=syzbot+6105ffc1ded71d194d6d@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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