summaryrefslogtreecommitdiff
path: root/fs/bio.c
diff options
context:
space:
mode:
authorJens Axboe <jaxboe@fusionio.com>2010-10-29 11:46:56 -0600
committerGreg Kroah-Hartman <gregkh@suse.de>2010-12-09 13:26:29 -0800
commit870cd3681836a2e822090522c8cb6fce19cf9e5c (patch)
tree7eff63873b623a171210b82efb6c3c1f0854fb0f /fs/bio.c
parenta4340113f9a3a4ebcbf988f1c1a27c07d70185b9 (diff)
block: limit vec count in bio_kmalloc() and bio_alloc_map_data()
commit f3f63c1c28bc861a931fac283b5bc3585efb8967 upstream. Reported-by: Dan Rosenberg <drosenberg@vsecurity.com> Signed-off-by: Jens Axboe <jaxboe@fusionio.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/bio.c')
-rw-r--r--fs/bio.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/bio.c b/fs/bio.c
index e0c9e71cc404..4c96a60a7db2 100644
--- a/fs/bio.c
+++ b/fs/bio.c
@@ -371,6 +371,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))
@@ -701,8 +704,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;