diff options
author | Dan Carpenter <dan.carpenter@oracle.com> | 2012-02-10 09:03:58 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-03-04 09:49:19 -0800 |
commit | e871c96c42ff9c08d856a757c0176f9381ac67cd (patch) | |
tree | 6f37e1391f1711194569c8c4492778e267da119f /kernel | |
parent | 210e889ab890de2eceb8b650093618937d9c1c45 (diff) | |
download | lwn-e871c96c42ff9c08d856a757c0176f9381ac67cd.tar.gz lwn-e871c96c42ff9c08d856a757c0176f9381ac67cd.zip |
relay: prevent integer overflow in relay_open()
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>
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 760c26209a3c..bf343f5340b1 100644 --- a/kernel/relay.c +++ b/kernel/relay.c @@ -171,10 +171,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; @@ -581,6 +585,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) |