diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-02-10 03:03:58 -0500 |
---|---|---|
committer | Luis Henriques <luis.henriques@canonical.com> | 2012-03-08 07:23:33 -0500 |
commit | bfb12935261a9e3d5e50abe5daf64e97131c1835 (patch) | |
tree | 81cf18d529d1492f879584ffac08e20c4470a978 /kernel | |
parent | b186ea1419e22b8f2531aaa04843a4d2e3f0c1d6 (diff) |
relay: prevent integer overflow in relay_open()
BugLink: http://bugs.launchpad.net/bugs/937915
commit f6302f1bcd75a042df69866d98b8d775a668f8f1 upstream.
"subbuf_size" and "n_subbufs" come from the user and they need to be
capped to prevent an integer overflow.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Brad Figg <brad.figg@canonical.com>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/relay.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/relay.c b/kernel/relay.c index 859ea5a9605..2c242fb2368 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
@@ -164,10 +164,14 @@ depopulate: | |||
164 | */ | 164 | */ |
165 | static struct rchan_buf *relay_create_buf(struct rchan *chan) | 165 | static struct rchan_buf *relay_create_buf(struct rchan *chan) |
166 | { | 166 | { |
167 | struct rchan_buf *buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); | 167 | struct rchan_buf *buf; |
168 | if (!buf) | 168 | |
169 | if (chan->n_subbufs > UINT_MAX / sizeof(size_t *)) | ||
169 | return NULL; | 170 | return NULL; |
170 | 171 | ||
172 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); | ||
173 | if (!buf) | ||
174 | return NULL; | ||
171 | buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL); | 175 | buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL); |
172 | if (!buf->padding) | 176 | if (!buf->padding) |
173 | goto free_buf; | 177 | goto free_buf; |
@@ -574,6 +578,8 @@ struct rchan *relay_open(const char *base_filename, | |||
574 | 578 | ||
575 | if (!(subbuf_size && n_subbufs)) | 579 | if (!(subbuf_size && n_subbufs)) |
576 | return NULL; | 580 | return NULL; |
581 | if (subbuf_size > UINT_MAX / n_subbufs) | ||
582 | return NULL; | ||
577 | 583 | ||
578 | chan = kzalloc(sizeof(struct rchan), GFP_KERNEL); | 584 | chan = kzalloc(sizeof(struct rchan), GFP_KERNEL); |
579 | if (!chan) | 585 | if (!chan) |