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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 22 Sep 2021 11:39:18 +0800
From:   Huang Jianan <huangjianan@...o.com>
To:     Chengguang Xu <cgxu519@....com>, linux-unionfs@...r.kernel.org,
        miklos@...redi.hu, linux-erofs@...ts.ozlabs.org, xiang@...nel.org,
        chao@...nel.org
Cc:     guoweichao@...o.com, yh@...o.com, zhangshiming@...o.com,
        guanyuwei@...o.com, jnhuang95@...il.com,
        linux-kernel@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH] ovl: fix null pointer when filesystem doesn't support
 direct IO

在 2021/9/22 9:56, Chengguang Xu 写道:
> 在 2021/9/18 20:13, Huang Jianan 写道:
>> From: Huang Jianan <huangjianan@...o.com>
>>
>> At present, overlayfs provides overlayfs inode to users. Overlayfs
>> inode provides ovl_aops with noop_direct_IO to avoid open failure
>> with O_DIRECT. But some compressed filesystems, such as erofs and
>> squashfs, don't support direct_IO.
>>
>> Users who use f_mapping->a_ops->direct_IO to check O_DIRECT support,
>> will read file through this way. This will cause overlayfs to access
>> a non-existent direct_IO function and cause panic due to null pointer:
>>
>> Kernel panic - not syncing: CFI failure (target: 0x0)
>> CPU: 6 PID: 247 Comm: loop0
>> Call Trace:
>>   panic+0x188/0x45c
>>   __cfi_slowpath+0x0/0x254
>>   __cfi_slowpath+0x200/0x254
>>   generic_file_read_iter+0x14c/0x150
>>   vfs_iocb_iter_read+0xac/0x164
>>   ovl_read_iter+0x13c/0x2fc
>>   lo_rw_aio+0x2bc/0x458
>>   loop_queue_work+0x4a4/0xbc0
>>   kthread_worker_fn+0xf8/0x1d0
>>   loop_kthread_worker_fn+0x24/0x38
>>   kthread+0x29c/0x310
>>   ret_from_fork+0x10/0x30
>>
>> The filesystem may only support direct_IO for some file types. For
>> example, erofs supports direct_IO for uncompressed files. So fall
>> back to buffered io only when the file doesn't support direct_IO to
>> fix this problem.
>
>
> IMO, return error to user seems better option than fall back to
>
> buffered io directly.
>
Agreed, I will send v2 to fix it.

Thanks,
Jianan
>
> Thanks,
>
> Chengguang
>
>
>>
>> Fixes: 5b910bd615ba ("ovl: fix GPF in swapfile_activate of file from 
>> overlayfs over xfs")
>> Signed-off-by: Huang Jianan <huangjianan@...o.com>
>> ---
>>   fs/overlayfs/file.c | 4 ++++
>>   1 file changed, 4 insertions(+)
>>
>> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
>> index d081faa55e83..998c60770b81 100644
>> --- a/fs/overlayfs/file.c
>> +++ b/fs/overlayfs/file.c
>> @@ -296,6 +296,10 @@ static ssize_t ovl_read_iter(struct kiocb *iocb, 
>> struct iov_iter *iter)
>>       if (ret)
>>           return ret;
>>   +    if ((iocb->ki_flags & IOCB_DIRECT) && 
>> (!real.file->f_mapping->a_ops ||
>> +        !real.file->f_mapping->a_ops->direct_IO))
>> +        iocb->ki_flags &= ~IOCB_DIRECT;
>> +
>>       old_cred = ovl_override_creds(file_inode(file)->i_sb);
>>       if (is_sync_kiocb(iocb)) {
>>           ret = vfs_iter_read(real.file, iter, &iocb->ki_pos,
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ