From: Pavel Skripkin <paskripkin@gmail.com>
To: syzbot <syzbot+e68c89a9510c159d9684@syzkaller.appspotmail.com>
Cc: linux-kernel@vger.kernel.org, penguin-kernel@I-love.SAKURA.ne.jp,
rostedt@goodmis.org, syzkaller-bugs@googlegroups.com,
tglx@linutronix.de
Subject: Re: [syzbot] UBSAN: shift-out-of-bounds in profile_init
Date: Fri, 16 Jul 2021 16:55:26 +0300 [thread overview]
Message-ID: <20210716165526.20e3c1a9@gmail.com> (raw)
In-Reply-To: <000000000000610af005c714c1d1@google.com>
[-- Attachment #1: Type: text/plain, Size: 922 bytes --]
On Wed, 14 Jul 2021 05:47:21 -0700
syzbot <syzbot+e68c89a9510c159d9684@syzkaller.appspotmail.com> wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 3dbdb38e Merge branch 'for-5.14' of
> git://git.kernel.org/p.. git tree: upstream
> console output:
> https://syzkaller.appspot.com/x/log.txt?x=11342328300000 kernel
> config: https://syzkaller.appspot.com/x/.config?x=a1fcf15a09815757
> dashboard link:
> https://syzkaller.appspot.com/bug?extid=e68c89a9510c159d9684 syz
> repro:
> https://syzkaller.appspot.com/x/repro.syz?x=149a96d2300000 C
> reproducer: https://syzkaller.appspot.com/x/repro.c?x=114e5bc4300000
>
> IMPORTANT: if you fix the issue, please add the following tag to the
> commit: Reported-by:
> syzbot+e68c89a9510c159d9684@syzkaller.appspotmail.com
>
#syz test
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
With regards,
Pavel Skripkin
[-- Attachment #2: 0001-profiling-fix-shift-out-of-bounds.patch --]
[-- Type: text/x-patch, Size: 2491 bytes --]
From 52652f42abee7eadcdf52fd38ee6cfb0b025448d Mon Sep 17 00:00:00 2001
From: Pavel Skripkin <paskripkin@gmail.com>
Date: Fri, 16 Jul 2021 16:47:17 +0300
Subject: [PATCH] profiling: fix shift-out-of bounds
/** ... **/
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
---
kernel/ksysfs.c | 4 +++-
kernel/profile.c | 18 +++++++++++++++---
2 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
index 35859da8bd4f..ca075d9f671a 100644
--- a/kernel/ksysfs.c
+++ b/kernel/ksysfs.c
@@ -76,7 +76,9 @@ static ssize_t profiling_store(struct kobject *kobj,
* has a ton of callers and is not const. It is
* easiest to cast it away here.
*/
- profile_setup((char *)buf);
+ ret = profile_setup((char *)buf);
+ if (!ret)
+ return -EINVAL;
ret = profile_init();
if (ret)
return ret;
diff --git a/kernel/profile.c b/kernel/profile.c
index c2ebddb5e974..5c61677030f4 100644
--- a/kernel/profile.c
+++ b/kernel/profile.c
@@ -42,6 +42,7 @@ struct profile_hit {
static atomic_t *prof_buffer;
static unsigned long prof_len, prof_shift;
+#define MAX_PROF_SHIFT sizeof(prof_shift) * 8
int prof_on __read_mostly;
EXPORT_SYMBOL_GPL(prof_on);
@@ -66,8 +67,11 @@ int profile_setup(char *str)
prof_on = SLEEP_PROFILING;
if (str[strlen(sleepstr)] == ',')
str += strlen(sleepstr) + 1;
- if (get_option(&str, &par))
+ if (get_option(&str, &par)) {
+ if (par >= MAX_PROF_SHIFT)
+ return 0;
prof_shift = par;
+ }
pr_info("kernel sleep profiling enabled (shift: %ld)\n",
prof_shift);
#else
@@ -77,19 +81,27 @@ int profile_setup(char *str)
prof_on = SCHED_PROFILING;
if (str[strlen(schedstr)] == ',')
str += strlen(schedstr) + 1;
- if (get_option(&str, &par))
+ if (get_option(&str, &par)) {
+ if (par >= MAX_PROF_SHIFT)
+ return 0;
prof_shift = par;
+ }
pr_info("kernel schedule profiling enabled (shift: %ld)\n",
prof_shift);
} else if (!strncmp(str, kvmstr, strlen(kvmstr))) {
prof_on = KVM_PROFILING;
if (str[strlen(kvmstr)] == ',')
str += strlen(kvmstr) + 1;
- if (get_option(&str, &par))
+ if (get_option(&str, &par)) {
+ if (par >= MAX_PROF_SHIFT)
+ return 0;
prof_shift = par;
+ }
pr_info("kernel KVM profiling enabled (shift: %ld)\n",
prof_shift);
} else if (get_option(&str, &par)) {
+ if (par >= MAX_PROF_SHIFT)
+ return 0;
prof_shift = par;
prof_on = CPU_PROFILING;
pr_info("kernel profiling enabled (shift: %ld)\n",
--
2.32.0
next prev parent reply other threads:[~2021-07-16 13:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-14 12:47 [syzbot] UBSAN: shift-out-of-bounds in profile_init syzbot
2021-07-16 12:24 ` Pavel Skripkin
2021-07-16 14:10 ` Tetsuo Handa
2021-07-16 14:18 ` Pavel Skripkin
2021-07-16 13:55 ` Pavel Skripkin [this message]
2021-07-16 16:19 ` syzbot
2021-07-16 14:38 ` Pavel Skripkin
2021-07-16 16:36 ` 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=20210716165526.20e3c1a9@gmail.com \
--to=paskripkin@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=penguin-kernel@I-love.SAKURA.ne.jp \
--cc=rostedt@goodmis.org \
--cc=syzbot+e68c89a9510c159d9684@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tglx@linutronix.de \
/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