mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
relay: prevent integer overflow in relay_open()
commit f6302f1bcd
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: Willy Tarreau <w@1wt.eu>
This commit is contained in:
parent
15edbd9f8b
commit
aa6333a71f
@ -171,10 +171,14 @@ static void *relay_alloc_buf(struct rchan_buf *buf, size_t *size)
|
||||
*/
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user