All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Skripkin <paskripkin@gmail.com>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: linux-kernel@vger.kernel.org, rostedt@goodmis.org,
	syzkaller-bugs@googlegroups.com, tglx@linutronix.de,
	syzbot <syzbot+e68c89a9510c159d9684@syzkaller.appspotmail.com>
Subject: Re: [syzbot] UBSAN: shift-out-of-bounds in profile_init
Date: Fri, 16 Jul 2021 17:18:37 +0300	[thread overview]
Message-ID: <20210716171837.69bcc1b6@gmail.com> (raw)
In-Reply-To: <949a12a0-a0a6-0574-4e87-4ed196ff6d78@i-love.sakura.ne.jp>

On Fri, 16 Jul 2021 23:10:25 +0900
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> wrote:

> On 2021/07/16 21:24, Pavel Skripkin wrote:
> > But this function can be called not only from sysfs and I can't
> > understand will my patch break something or not. And, I think, error
> > message is needed somewhere here to inform callers about wrong shift
> > value.
> > 
> > 
> > Thoughts?
> 
> Subsequent profiling_store() attempts will return -EEXIST if
> profile_setup() once set prof_on to non-zero value. Therefore,
> if you try to return -EINVAL when profile_setup() returns 0,
> you need to make sure that prof_on is set to non-zero value
> only if prof_shift is valid.
> 
> But, the userspace might not be aware of the value of MAX_PROF_SHIFT
> because it is an architecture dependent value, and par might become
> negative value because get_option() accepts negative value.
> Therefore, it might be better to
> 
> +		par = clamp(par, 0, MAX_PROF_SHIFT - 1);
> 
> than
> 
> +		if (par < 0 || par >= MAX_PROF_SHIFT)
> +			return 0;
> 
> .
> 

Yes, this sounds much better, thank you. I will send reworked patch to
syzbot. Do you mind if I add 

Suggested-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>

tag to final patch?



With regards,
Pavel Skripkin

  reply	other threads:[~2021-07-16 14:18 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 [this message]
2021-07-16 13:55 ` Pavel Skripkin
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=20210716171837.69bcc1b6@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.