lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <61A44AAD.9050002@huawei.com>
Date:   Mon, 29 Nov 2021 11:36:13 +0800
From:   yebin <yebin10@...wei.com>
To:     Jens Axboe <axboe@...nel.dk>, <asml.silence@...il.com>,
        <io-uring@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -next] io_uring: Fix undefined-behaviour in io_issue_sqe



On 2021/11/27 21:45, Jens Axboe wrote:
> On 11/17/21 6:59 PM, Ye Bin wrote:
>> We got issue as follows:
>> ================================================================================
>> UBSAN: Undefined behaviour in ./include/linux/ktime.h:42:14
>> signed integer overflow:
>> -4966321760114568020 * 1000000000 cannot be represented in type 'long long int'
>> CPU: 1 PID: 2186 Comm: syz-executor.2 Not tainted 4.19.90+ #12
>> Hardware name: linux,dummy-virt (DT)
>> Call trace:
>>   dump_backtrace+0x0/0x3f0 arch/arm64/kernel/time.c:78
>>   show_stack+0x28/0x38 arch/arm64/kernel/traps.c:158
>>   __dump_stack lib/dump_stack.c:77 [inline]
>>   dump_stack+0x170/0x1dc lib/dump_stack.c:118
>>   ubsan_epilogue+0x18/0xb4 lib/ubsan.c:161
>>   handle_overflow+0x188/0x1dc lib/ubsan.c:192
>>   __ubsan_handle_mul_overflow+0x34/0x44 lib/ubsan.c:213
>>   ktime_set include/linux/ktime.h:42 [inline]
>>   timespec64_to_ktime include/linux/ktime.h:78 [inline]
>>   io_timeout fs/io_uring.c:5153 [inline]
>>   io_issue_sqe+0x42c8/0x4550 fs/io_uring.c:5599
>>   __io_queue_sqe+0x1b0/0xbc0 fs/io_uring.c:5988
>>   io_queue_sqe+0x1ac/0x248 fs/io_uring.c:6067
>>   io_submit_sqe fs/io_uring.c:6137 [inline]
>>   io_submit_sqes+0xed8/0x1c88 fs/io_uring.c:6331
>>   __do_sys_io_uring_enter fs/io_uring.c:8170 [inline]
>>   __se_sys_io_uring_enter fs/io_uring.c:8129 [inline]
>>   __arm64_sys_io_uring_enter+0x490/0x980 fs/io_uring.c:8129
>>   invoke_syscall arch/arm64/kernel/syscall.c:53 [inline]
>>   el0_svc_common+0x374/0x570 arch/arm64/kernel/syscall.c:121
>>   el0_svc_handler+0x190/0x260 arch/arm64/kernel/syscall.c:190
>>   el0_svc+0x10/0x218 arch/arm64/kernel/entry.S:1017
>> ================================================================================
>>
>> As ktime_set only judge 'secs' if big than KTIME_SEC_MAX, but if we pass
>> negative value maybe lead to overflow.
>> To address this issue, we must check if 'sec' is negative.
>>
>> Signed-off-by: Ye Bin <yebin10@...wei.com>
>> ---
>>   fs/io_uring.c | 3 +++
>>   1 file changed, 3 insertions(+)
>>
>> diff --git a/fs/io_uring.c b/fs/io_uring.c
>> index f9e720595860..d8a6446a7921 100644
>> --- a/fs/io_uring.c
>> +++ b/fs/io_uring.c
>> @@ -6157,6 +6157,9 @@ static int io_timeout_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe,
>>   	if (get_timespec64(&data->ts, u64_to_user_ptr(sqe->addr)))
>>   		return -EFAULT;
>>   
>> +	if (data->ts.tv_sec < 0 || data->ts.tv_nsec < 0)
>> +		return -EINVAL;
>> +
>>   	data->mode = io_translate_timeout_mode(flags);
>>   	hrtimer_init(&data->timer, io_timeout_get_clock(data), data->mode);
> This seems to only fix one instance of when a timespec is copied in, what
> about the ones in io_timeout_remove_prep()?
I will send another new patch to fix the scene you said

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ