Skip to content

Commit

Permalink
block: limit vec count in bio_kmalloc() and bio_alloc_map_data()
Browse files Browse the repository at this point in the history
Reported-by: Dan Rosenberg <drosenberg@vsecurity.com>
Cc: stable@kernel.org
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
  • Loading branch information
Jens Axboe committed Nov 10, 2010
1 parent 9f864c8 commit f3f63c1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion fs/bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ struct bio *bio_kmalloc(gfp_t gfp_mask, int nr_iovecs)
{
struct bio *bio;

if (nr_iovecs > UIO_MAXIOV)
return NULL;

bio = kmalloc(sizeof(struct bio) + nr_iovecs * sizeof(struct bio_vec),
gfp_mask);
if (unlikely(!bio))
Expand Down Expand Up @@ -697,8 +700,12 @@ static void bio_free_map_data(struct bio_map_data *bmd)
static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count,
gfp_t gfp_mask)
{
struct bio_map_data *bmd = kmalloc(sizeof(*bmd), gfp_mask);
struct bio_map_data *bmd;

if (iov_count > UIO_MAXIOV)
return NULL;

bmd = kmalloc(sizeof(*bmd), gfp_mask);
if (!bmd)
return NULL;

Expand Down

0 comments on commit f3f63c1

Please sign in to comment.