genodelabs/genode — Issue #73: Libc: potential parameter passing bug for open and fcntl
Author: blitz
Created: 2012-01-09 19:03:55+00:00
State: open

The prototypes for open and fcntl are variadic. Yet the actual implementations use a fixed number of arguments. This breaks for -mregparm on x86. Let's take fcntl as example:

Prototype in fcntl.h is:
int fcntl(int, int, ...);

file_operation.cc defines it as:
extern "C" int fcntl(int libc_fd, int cmd, long arg) {
...
}

With regparm=3 this will generate bad code, since everyone using the prototype will pass parameters via the stack, while the actual implementation will accept parameters as registers.

A fix is in the works.