Summary: | net/samba47: Samba's vfs_streams_xattr triggers corruption of first byte in AFP_AfpInfo stream/xattr | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Product: | Ports & Packages | Reporter: | slow | ||||||||
Component: | Individual Port(s) | Assignee: | Timur I. Bakeyev <timur> | ||||||||
Status: | Closed FIXED | ||||||||||
Severity: | Affects Many People | CC: | timur | ||||||||
Priority: | --- | ||||||||||
Version: | Latest | ||||||||||
Hardware: | Any | ||||||||||
OS: | Any | ||||||||||
Attachments: |
|
Description
slow
2018-05-24 14:50:14 UTC
Created attachment 193656 [details]
Possible patch for 4.7, may apply to other versions
Thanks a lot, Ralph, for investigating this and for the patch. Much appreciated! Just to make it clear, the provided patch is still WIP... Btw, in case this wasn't clear enough: the patch https://svnweb.freebsd.org/ports/head/net/samba47/files/patch-source3__modules__vfs_streams_xattr.c?revision=464431&view=markup basically corrups the streams as it returns the internal 0 byte to the client. A client which stored an 2 xattr value of 0xbe 0xef, so two bytes, will read an xattr of 3 bytes 0xbe 0xef 0x00 with the patch. Any client who stored xattrs with and without the patch will have a mixup of the old storage format and the new one. Not sure what the best way out of this is. (In reply to slow from comment #4) Unfortunately, it's clear, Ralph. Next question is what to do with it, you are right. (In reply to Timur I. Bakeyev from comment #5) Hi, Ralph! Meanwhile I've slightly modify your proposed patch, see the attachment. Basically, there are two small differences: 1. There is no need to pass address of the `null = \0'` variable to the VFS call, while we set buffer size to 0. It's better/easier to pass NULL and that's also documented behavior for the API, so is more consistent. 2. I've rearranged checks for the AFP_Signature and AFP_Version, as logically version makes sense only if we recognized the format by the signature. Result at the end should be the same, but it's a bit cleaner. Otherwise I think it's a nice catch and good fix for the bug in the current FreeBSD's version of vfs_streams_xattr. Thank you! Created attachment 194034 [details]
Modified version of the proposed fix
The modified patch is applied to samba48 port, as of 4.8.2. Created attachment 194644 [details]
Additional fix
Looks like this one somehow got lost. It takes care of fixing up broken AFP_AfpInfo streams on the fly when the client reads them.
Reopening to pick up additional patch. (In reply to slow from comment #10) Thanks for the update, Ralph! I've added your patch to the newer ports of 4.7.8 and 4.8.3. Much appreciated! |