lkml.org 
[lkml]   [2018]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Date
    Subject[PATCH 3.16 190/328] nbd: don't allow invalid blocksize settings
    3.16.62-rc1 review patch.  If anyone has any objections, please let me know.

    ------------------

    From: Jens Axboe <axboe@kernel.dk>

    commit bc811f05d77f47059c197a98b6ad242eb03999cb upstream.

    syzbot reports a divide-by-zero off the NBD_SET_BLKSIZE ioctl.
    We need proper validation of the input here. Not just if it's
    zero, but also if the value is a power-of-2 and in a valid
    range. Add that.

    Reported-by: syzbot <syzbot+25dbecbec1e62c6b0dd4@syzkaller.appspotmail.com>
    Reviewed-by: Josef Bacik <josef@toxicpanda.com>
    Signed-off-by: Jens Axboe <axboe@kernel.dk>
    [bwh: Backported to 3.16: adjust context]
    Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
    ---
    drivers/block/nbd.c | 3 +++
    1 file changed, 3 insertions(+)

    --- a/drivers/block/nbd.c
    +++ b/drivers/block/nbd.c
    @@ -667,6 +667,9 @@ static int __nbd_ioctl(struct block_devi
    }

    case NBD_SET_BLKSIZE:
    + if (!arg || !is_power_of_2(arg) || arg < 512 ||
    + arg > PAGE_SIZE)
    + return -EINVAL;
    nbd->blksize = arg;
    nbd->bytesize &= ~(nbd->blksize-1);
    bdev->bd_inode->i_size = nbd->bytesize;
    \
     
     \ /
      Last update: 2018-12-09 22:56    [W:7.399 / U:0.100 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site