From: piaojun <piaojun@huawei.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] ocfs2: fix sparse file & data ordering issue in direct io
Date: Sat, 19 Nov 2016 11:49:39 +0800 [thread overview]
Message-ID: <582FCBD3.7020708@huawei.com> (raw)
In-Reply-To: <582D9B6D.8080205@huawei.com>
sorry, my analysis is wrong. -EAGAIN will be eaten only when 'type' is
OCFS2_WRITE_MMAP in ocfs2_write_begin_nolock(). so uninitialized 'wc'
will not be dereferenced in ocfs2_dio_get_block() as abnormal branch
can catch error 'ret'.
thanks,
Jun
On 2016-11-17 19:58, piaojun wrote:
> Hi Carpenter,
>
> I guess this may cause illegal memory access error as follows:
>
> generic_perform_write
> --a_ops->write_begin(file, mapping, pos, bytes, flags, &page, &fsdata);
> --ocfs2_write_begin_nolock
> --ocfs2_grab_pages_for_write
> --return -EAGAIN if not enough pages
> --'fsdata' will be uninitialized
>
> --a_ops->write_end(file, mapping, pos, bytes, copied, page, fsdata);
> --ocfs2_write_end_nolock
> --the access of wc->w_di_bh->b_data will cause error.
>
> if so, I suggest not eating error code and let upper level to handle
> this problem.
>
> On 2016-3-9 18:25, Dan Carpenter wrote:
>> Hello Ryan Ding,
>>
>> The patch fbe25fb91af5: "ocfs2: fix sparse file & data ordering issue
>> in direct io" from Feb 25, 2016, leads to the following static
>> checker warning:
>>
>> fs/ocfs2/aops.c:2242 ocfs2_dio_get_block()
>> error: potentially dereferencing uninitialized 'wc'.
>>
>> fs/ocfs2/aops.c
>> 2235
>> 2236 ret = ocfs2_write_begin_nolock(inode->i_mapping, pos, len,
>> 2237 OCFS2_WRITE_DIRECT, NULL,
>> 2238 (void **)&wc, di_bh, NULL);
>> ^^^^^^^^^^^^
>>
>> See commit 5cffff9e2986 ('ocfs2: Fix ocfs2_page_mkwrite()') for an
>> explanation why a zero return here does not imply that "wc" has been
>> initialized.
>>
>> 2239 if (ret) {
>> 2240 mlog_errno(ret);
>> 2241 goto unlock;
>> 2242 }
>> 2243
>> 2244 desc = &wc->w_desc[0];
>> 2245
>> 2246 p_blkno = ocfs2_clusters_to_blocks(inode->i_sb, desc->c_phys);
>>
>> regards,
>> dan carpenter
>>
>> _______________________________________________
>> Ocfs2-devel mailing list
>> Ocfs2-devel at oss.oracle.com
>> https://oss.oracle.com/mailman/listinfo/ocfs2-devel
>>
>>
prev parent reply other threads:[~2016-11-19 3:49 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-09 10:25 [Ocfs2-devel] ocfs2: fix sparse file & data ordering issue in direct io Dan Carpenter
2016-11-15 10:33 ` Dan Carpenter
2016-11-15 10:36 ` Dan Carpenter
2016-11-16 2:33 ` Eric Ren
2016-11-16 10:45 ` Dan Carpenter
2016-11-17 3:08 ` Eric Ren
2016-11-17 10:03 ` Dan Carpenter
2016-11-22 2:29 ` Junxiao Bi
2016-11-24 14:21 ` Dan Carpenter
2016-11-17 11:58 ` piaojun
2016-11-19 3:49 ` piaojun [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=582FCBD3.7020708@huawei.com \
--to=piaojun@huawei.com \
--cc=ocfs2-devel@oss.oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.