mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
block: limit vec count in bio_kmalloc() and bio_alloc_map_data()
Reported-by: Dan Rosenberg <drosenberg@vsecurity.com> Cc: stable@kernel.org Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
This commit is contained in:
parent
9f864c8091
commit
f3f63c1c28
1 changed files with 8 additions and 1 deletions
9
fs/bio.c
9
fs/bio.c
|
@ -370,6 +370,9 @@ struct bio *bio_kmalloc(gfp_t gfp_mask, int nr_iovecs)
|
||||||
{
|
{
|
||||||
struct bio *bio;
|
struct bio *bio;
|
||||||
|
|
||||||
|
if (nr_iovecs > UIO_MAXIOV)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
bio = kmalloc(sizeof(struct bio) + nr_iovecs * sizeof(struct bio_vec),
|
bio = kmalloc(sizeof(struct bio) + nr_iovecs * sizeof(struct bio_vec),
|
||||||
gfp_mask);
|
gfp_mask);
|
||||||
if (unlikely(!bio))
|
if (unlikely(!bio))
|
||||||
|
@ -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,
|
static struct bio_map_data *bio_alloc_map_data(int nr_segs, int iov_count,
|
||||||
gfp_t gfp_mask)
|
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)
|
if (!bmd)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue