[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0e2b7b6c-ae2e-45b1-aefc-f33864208c33@I-love.SAKURA.ne.jp>
Date: Mon, 16 Dec 2024 19:06:01 +0900
From: Tetsuo Handa <penguin-kernel@...ove.SAKURA.ne.jp>
To: Lizhi Xu <lizhi.xu@...driver.com>,
syzbot+7536f77535e5210a5c76@...kaller.appspotmail.com
Cc: jmorris@...ei.org, linux-kernel@...r.kernel.org,
linux-security-module@...r.kernel.org, paul@...l-moore.com,
serge@...lyn.com, syzkaller-bugs@...glegroups.com,
takedakn@...data.co.jp
Subject: Re: [PATCH] tomoyo: prevent bad buffer size in tracing_cpumask_write
On 2024/12/16 17:19, Lizhi Xu wrote:
> User input a too large buffer size 0xfffffdeful, although it is truncated to
> MAX_RW_COUNT in vfs_write, its value is still too large, causing warning when
> allocating memory in tomoyo_write_control.
>
> Add a check for it to avoid this case.
Thank you for a patch. But I don't think this fix is correct, for one can make
head->writebuf_size too large by writing chunks without new line for many times.
>
> Reported-by: syzbot+7536f77535e5210a5c76@...kaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=7536f77535e5210a5c76
> Tested-by: syzbot+7536f77535e5210a5c76@...kaller.appspotmail.com
> Signed-off-by: Lizhi Xu <lizhi.xu@...driver.com>
> ---
> security/tomoyo/common.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
> index 5c7b059a332a..f63388c2fffd 100644
> --- a/security/tomoyo/common.c
> +++ b/security/tomoyo/common.c
> @@ -2654,6 +2654,8 @@ ssize_t tomoyo_write_control(struct tomoyo_io_buffer *head,
>
> if (!head->write)
> return -EINVAL;
> + if (avail_len > KMALLOC_MAX_SIZE)
> + return -EINVAL;
> if (mutex_lock_interruptible(&head->io_sem))
> return -EINTR;
> cp0 = head->write_buf;
Powered by blists - more mailing lists