From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: Naresh Kamboju <naresh.kamboju@linaro.org>
Cc: Nathan Chancellor <natechancellor@gmail.com>,
Nick Desaulniers <ndesaulniers@google.com>,
Baokun Li <libaokun1@huawei.com>,
open list <linux-kernel@vger.kernel.org>,
linux-stable <stable@vger.kernel.org>,
Hulk Robot <hulkci@huawei.com>,
Josef Bacik <josef@toxicpanda.com>, Jens Axboe <axboe@kernel.dk>,
Sasha Levin <sashal@kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>,
lkft-triage@lists.linaro.org, llvm@lists.linux.dev
Subject: Re: [PATCH 5.14 018/334] nbd: add the check to prevent overflow in __nbd_ioctl()
Date: Mon, 13 Sep 2021 19:58:01 +0200 [thread overview]
Message-ID: <YT+RKemKfg6GFq0S@kroah.com> (raw)
In-Reply-To: <CA+G9fYtdPnwf+fi4Oyxng65pWjW9ujZ7dd2Z-EEEHyJimNHN6g@mail.gmail.com>
On Mon, Sep 13, 2021 at 09:52:33PM +0530, Naresh Kamboju wrote:
> On Mon, 13 Sept 2021 at 19:51, Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > From: Baokun Li <libaokun1@huawei.com>
> >
> > [ Upstream commit fad7cd3310db3099f95dd34312c77740fbc455e5 ]
> >
> > If user specify a large enough value of NBD blocks option, it may trigger
> > signed integer overflow which may lead to nbd->config->bytesize becomes a
> > large or small value, zero in particular.
> >
> > UBSAN: Undefined behaviour in drivers/block/nbd.c:325:31
> > signed integer overflow:
> > 1024 * 4611686155866341414 cannot be represented in type 'long long int'
> > [...]
> > Call trace:
> > [...]
> > handle_overflow+0x188/0x1dc lib/ubsan.c:192
> > __ubsan_handle_mul_overflow+0x34/0x44 lib/ubsan.c:213
> > nbd_size_set drivers/block/nbd.c:325 [inline]
> > __nbd_ioctl drivers/block/nbd.c:1342 [inline]
> > nbd_ioctl+0x998/0xa10 drivers/block/nbd.c:1395
> > __blkdev_driver_ioctl block/ioctl.c:311 [inline]
> > [...]
> >
> > Although it is not a big deal, still silence the UBSAN by limit
> > the input value.
> >
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Baokun Li <libaokun1@huawei.com>
> > Reviewed-by: Josef Bacik <josef@toxicpanda.com>
> > Link: https://lore.kernel.org/r/20210804021212.990223-1-libaokun1@huawei.com
> > [axboe: dropped unlikely()]
> > Signed-off-by: Jens Axboe <axboe@kernel.dk>
> > Signed-off-by: Sasha Levin <sashal@kernel.org>
> > ---
> > drivers/block/nbd.c | 6 ++++--
> > 1 file changed, 4 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> > index 19f5d5a8b16a..acf3f85bf3c7 100644
> > --- a/drivers/block/nbd.c
> > +++ b/drivers/block/nbd.c
> > @@ -1388,6 +1388,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
> > unsigned int cmd, unsigned long arg)
> > {
> > struct nbd_config *config = nbd->config;
> > + loff_t bytesize;
> >
> > switch (cmd) {
> > case NBD_DISCONNECT:
> > @@ -1402,8 +1403,9 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
> > case NBD_SET_SIZE:
> > return nbd_set_size(nbd, arg, config->blksize);
> > case NBD_SET_SIZE_BLOCKS:
> > - return nbd_set_size(nbd, arg * config->blksize,
> > - config->blksize);
> > + if (check_mul_overflow((loff_t)arg, config->blksize, &bytesize))
> > + return -EINVAL;
> > + return nbd_set_size(nbd, bytesize, config->blksize);
> > case NBD_SET_TIMEOUT:
> > nbd_set_cmd_timeout(nbd, arg);
> > return 0;
>
> arm clang-10, clang-11, clang-12 and clang-13 builds failed.
> due to this commit on 5.14 and 5.13 on following configs,
> - footbridge_defconfig
> - mini2440_defconfig
> - s3c2410_defconfig
>
> This was already reported on the mailing list.
>
> ERROR: modpost: "__mulodi4" [drivers/block/nbd.ko] undefined! #1438
> https://github.com/ClangBuiltLinux/linux/issues/1438
>
> [PATCH 00/10] raise minimum GCC version to 5.1
> https://lore.kernel.org/lkml/20210910234047.1019925-1-ndesaulniers@google.com/
>
> linux-next: build failure while building Linus' tree
> https://lore.kernel.org/all/20210909182525.372ee687@canb.auug.org.au/
>
> Full build log,
> https://gitlab.com/Linaro/lkft/mirrors/stable/linux-stable-rc/-/jobs/1585407346#L1111
Has anyone submitted a fix for this upstream yet? I can't seem to find
one :(
next prev parent reply other threads:[~2021-09-13 17:58 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20210913131113.390368911@linuxfoundation.org>
[not found] ` <20210913131114.028340332@linuxfoundation.org>
2021-09-13 16:22 ` [PATCH 5.14 018/334] nbd: add the check to prevent overflow in __nbd_ioctl() Naresh Kamboju
2021-09-13 17:58 ` Greg Kroah-Hartman [this message]
2021-09-13 18:39 ` Nick Desaulniers
2021-09-13 19:53 ` Nick Desaulniers
2021-09-13 19:57 ` Sedat Dilek
2021-09-13 20:02 ` Nick Desaulniers
2021-09-13 20:10 ` Linus Torvalds
2021-09-13 20:16 ` Nick Desaulniers
2021-09-13 20:36 ` Nick Desaulniers
2021-09-13 20:42 ` Linus Torvalds
2021-09-13 20:50 ` Nick Desaulniers
2021-09-13 21:13 ` Nick Desaulniers
2021-09-13 21:15 ` Nick Desaulniers
2021-09-13 23:00 ` Linus Torvalds
2021-09-13 23:23 ` Nick Desaulniers
2021-09-14 2:13 ` libaokun (A)
2021-09-14 3:30 ` Nick Desaulniers
2021-09-14 8:14 ` David Laight
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=YT+RKemKfg6GFq0S@kroah.com \
--to=gregkh@linuxfoundation.org \
--cc=axboe@kernel.dk \
--cc=clang-built-linux@googlegroups.com \
--cc=hulkci@huawei.com \
--cc=josef@toxicpanda.com \
--cc=libaokun1@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkft-triage@lists.linaro.org \
--cc=llvm@lists.linux.dev \
--cc=naresh.kamboju@linaro.org \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/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