]> git.baikalelectronics.ru Git - kernel.git/commit
ceph: properly zero data pages for file holes.
authorYan, Zheng <zyan@redhat.com>
Tue, 6 Jan 2015 07:29:14 +0000 (15:29 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Thu, 19 Feb 2015 10:31:38 +0000 (13:31 +0300)
commit8a70659be48387e6fed277282e4f4852b82f7db6
tree43bb2d70b4d933183fcf56ab1eb9ac8e3d83f1ab
parentc5485d0e548d1a6ad1376302578dd971de335ad1
ceph: properly zero data pages for file holes.

A bug is found in striped_read() of fs/ceph/file.c. striped_read() calls
ceph_zero_pape_vector_range().  The first argument, page_align + read + ret,
passed to ceph_zero_pape_vector_range() is wrong.

When a file has holes, this wrong parameter may cause memory corruption
either in kernal space or user space. Kernel space memory may be corrupted in
the case of non direct IO; user space memory may be corrupted in the case of
direct IO. In the latter case, the application doing direct IO may crash due
to memory corruption, as we have experienced.

The correct value should be initial_align + read + ret, where intial_align =
o_direct ? buf_align : io_align.  Compared with page_align, the current page
offest, initial_align is the initial page offest, which should be used to
calculate the page and offset in ceph_zero_pape_vector_range().

Reported-by: caifeng zhu <zhucaifeng@unissoft-nj.com>
Signed-off-by: Yan, Zheng <zyan@redhat.com>
fs/ceph/file.c