kmap + memmove

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Here's a fun bug that's not obvious:

hfs_bnode_move:
                                dst_ptr = kmap_local_page(*dst_page);
                                src_ptr = kmap_local_page(*src_page);
                                memmove(dst_ptr, src_ptr, src);

If both of the pointers are guaranteed to come from diffeerent calls to
kmap_local(), memmove() is probably not going to do what you want.
Worth a smatch or coccinelle rule?

The only time that memmove() is going to do something different from
memcpy() is when src and dst overlap.  But if src and dst both come
from kmap_local(), they're guaranteed to not overlap.  Even if dst_page
and src_page were the same.

Which means the conversion in 6c3014a67a44 was buggy.  Calling kmap()
for the same page twice gives you the same address.  Calling kmap_local()
for the same page twice gives you two different addresses.

Fabio, how many other times did you create this same bug?  Ira, I'm
surprised you didn't catch this one; you created the same bug in
memmove_page() which I got Fabio to delete in 9384d79249d0.




[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux