SMB2 AIO with unaligned memory address caused the read data corruption.

Jeremy Allison jra at
Tue Jun 12 19:55:01 UTC 2018

On Mon, Jun 11, 2018 at 12:21:57PM -0700, Partha Sarathi wrote:
>    Hi,
>    We recently come across a read data corruption issue using samba.4.7.x
>    against Linux Fuse FS with DIO enabled.
>    We nailed down the issue was an outcome of samba AIO preads were
>    reusing the unaligned buffer address allocated by talloc library.  The
>    kernel FUSE with DIO path (Direct IO) was not handling the unaligned
>    memory correctly.  We are trying to fix this issue from both the ends.
>    For samba, I provided the attached patch as workaround patch i.e for
>    AIO read path I want to make sure the allocated memory is aligned of
>    the system page size which fixed the issue, but I would like to fix
>    this in as part of talloc library itself.
>    Please take a look at the patch and let me know, if we can fix this in
>    talloc itself i.e guaranteeing the aligned memory allocation for IO
>    calls.

Well hang on a minute, how are you using the kernel FUSE with DIO
from Samba ? We don't call those API's (they're the linux io_XXX()
API calls, yeah ?). Are these calls you have added to Samba ?

Our native AIO code uses an internal pthreadpool which just calls
normal pread/pwrite/fsync without needing aligned memory. The glibc
aio_XXX() API's are horribly broken (last time I looked at the glibc
code, which admittedly was more than 5+ years ago) they had a limitation
of one outstanding aio call per file descriptor, which makes them worse
than useless.

I guess I don't understand how you're getting this problem occurring.


More information about the samba-technical mailing list