summaryrefslogtreecommitdiffstats
path: root/kernel/relay.c
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2012-02-10 09:03:58 +0100
committerJens Axboe <axboe@kernel.dk>2012-02-10 09:04:49 +0100
commitf6302f1bcd75a042df69866d98b8d775a668f8f1 (patch)
tree06319873d688c602ef353120f94f63c3da85dfd1 /kernel/relay.c
parent306df0716aa285d378cc948fafed53c6ed895fe6 (diff)
downloadlinux-stable-f6302f1bcd75a042df69866d98b8d775a668f8f1.tar.gz
linux-stable-f6302f1bcd75a042df69866d98b8d775a668f8f1.tar.bz2
linux-stable-f6302f1bcd75a042df69866d98b8d775a668f8f1.zip
relay: prevent integer overflow in relay_open()
"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> Cc: stable@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'kernel/relay.c')
-rw-r--r--kernel/relay.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/kernel/relay.c b/kernel/relay.c
index 4335e1d7ee2d..ab56a1764d4d 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -164,10 +164,14 @@ depopulate:
*/
static struct rchan_buf *relay_create_buf(struct rchan *chan)
{
- struct rchan_buf *buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
- if (!buf)
+ struct rchan_buf *buf;
+
+ if (chan->n_subbufs > UINT_MAX / sizeof(size_t *))
return NULL;
+ buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
+ if (!buf)
+ return NULL;
buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL);
if (!buf->padding)
goto free_buf;
@@ -574,6 +578,8 @@ struct rchan *relay_open(const char *base_filename,
if (!(subbuf_size && n_subbufs))
return NULL;
+ if (subbuf_size > UINT_MAX / n_subbufs)
+ return NULL;
chan = kzalloc(sizeof(struct rchan), GFP_KERNEL);
if (!chan)