|
|
Subscribe / Log in / New account

Rethinking fsinfo()

Rethinking fsinfo()

Posted Aug 24, 2020 18:29 UTC (Mon) by josh (subscriber, #17465)
In reply to: Rethinking fsinfo() by SEJeff
Parent article: Rethinking fsinfo()

"double copy"? I understand why it might require one copy (to deserialize to an in-memory format), but why two?


to post comments

Rethinking fsinfo()

Posted Aug 24, 2020 19:07 UTC (Mon) by Cyberax (✭ supporter ✭, #52523) [Link] (2 responses)

I would guess to avoid racing with the userspace while unmarshalling the data? Though it might be possible to create a race-safe parser for protobufs, they are not complicated.

Rethinking fsinfo()

Posted Aug 24, 2020 20:15 UTC (Mon) by excors (subscriber, #95769) [Link] (1 responses)

I think Nanopb (a protobuf implementation for embedded systems) is already race-safe, since the decoder just reads linearly from an input stream, so that does seem possible.

When decoding strings or byte arrays, it can read directly from the stream into the decoded message struct (if the field is configured with a fixed max size) or into a malloced buffer (if configured with variable size) or can pass a substream object representing the value into a callback function. Using the callback interface would let the kernel copy directly from the userspace input buffer into the appropriate internal kernel struct.

It looks like FlatBuffers can't do that, because verification (to avoid out-of-bounds reads etc) is a separate operation from reading fields. You'd have to memcpy the whole buffer from userspace to kernel memory before verifying and then copying strings again into kernel structs.

For kernel-to-userspace messages, you don't need to worry about race conditions and you probably don't need the verification step (since you have to trust the kernel anyway), so FlatBuffers could work better there.

For userspace-to-kernel in both protocols, if you really don't want to force the user to pack all their data into a single buffer, you could always encode userspace pointers as integers (like a "fixed64" in protobuf) to point to raw data or encoded messages at other addresses, and the kernel can traverse those pointers manually like it does today. You'd still get the benefit of automatic marshalling for the majority of structs and fields.

Rethinking fsinfo()

Posted Aug 27, 2020 16:50 UTC (Thu) by esemwy (guest, #83963) [Link]

Anybody remember VMS? DEC solved this by passing arguments by *descriptor*, which was a self describing array of parameters. Given how often the syscall vs kernel feature mismatch comes up, it seems it wasn’t such a weird idea after all.

http://h30266.www3.hpe.com/odl/axpos/opsys/vmsos84/5841/5...


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds