[xml] [PATCH] Two trivial fixes for Control Flow Integrity support



Hello, I have two small patches to fix function pointer type signature
mismatches in libxml. I've submitted these upstream in chromium [1] as
part of the effort to enable Control Flow Integrity, but it would be
preferable to have them land in libxml itself.

Control Flow Integrity [2] is a security mechanism that checks that
indirect calls only occur to call sites with matching type
information. (As has been mentioned on this list before, some
transpilers like Emscripten also require that function pointers be
called with a type signature matching the called function.)

The patches fix type signature mismatches with xmlNop() and
xmlMemStrdup(). The first patch sets xmlNop() to have the same type
signature as xmlInputReadCallback, which is the only type it's ever
cast to. Under some compiler flags, xmlMemStrdup() is a function
pointer pointing to xmlStrdup() despite a mismatched type signature.
In that case I set it to strdup() instead since it has the correct
type signature and the other xmlMem(Malloc|Realloc|Free) function
pointers around it point directly to the libc implementations as well.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/745034
[2] https://clang.llvm.org/docs/ControlFlowIntegrity.html

Attachment: xmlmemstrdup.patch
Description: Binary data

Attachment: xmlnop.patch
Description: Binary data



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