summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/sparc/fork.S
diff options
context:
space:
mode:
authorYuriy Kolerov <yuriy.kolerov@synopsys.com>2015-09-23 15:43:38 +0300
committerWaldemar Brodkorb <wbx@openadk.org>2015-10-05 22:07:08 +0200
commit4480f9b5558906fce2c35f1819d4e1fe5922a9fa (patch)
treee45235bb31e74618c26fc3d1db1ced3d129c24f6 /libc/sysdeps/linux/sparc/fork.S
parent2eb8070e678937e7e7835d167cffb11628b8862e (diff)
libc: fix sign extension in fallocate()
For common generic syscall ABI fallocate syscall handler in kernel expects a 64-bit signed arguments for offset and len. However uClibc has 2 wrappers for this syscall: fallocate and fallocate64. On 32-bit machines fallocate (not fallocate64) expects 32-bit values of offset and len. Thus in this case uClibc's fallocate must pass to the syscall those values with sign extension. High word of 64-bit value must be 0 or 0xFFFFFFFF depending on sign of the original 32-bit value (offset or len). It is how sign extansion works - all high bits of the negative value must be 1. So on 32-bit machines uClibc's fallocate does sign extension incorrectly when 32-bit values are passed (offset or len). It just fills the second word of 64-bit value by zeros. E.g. fallocate works incorrectly when offset or length is negative value - in this case kernel thinks that positive values are passed. Solution is to call fallocate64 from fallocate and pass 32-bit values of offset and len to fallocate64. off_t type is automatically converted to off64_t with an appropriate sign extension. Then fallocate64 invokes kernel's system call properly. This error is detected in LTP's test kernel/syscalls/fallocate02: ----------->8---------- fallocate(..., 1, -1024, 1024) failed, expected errno:22: TEST_ERRNO=0 fallocate(..., 1, 1024, -1024) failed, expected errno:22: TEST_ERRNO=0 fallocate(..., 1, 12288, -1024) failed, expected errno:22: TEST_ERRNO=0 fallocate(..., 1, -24576, 1024) failed, expected errno:22: TEST_ERRNO=0 ----------->8---------- fallocate does not emit an error because negative values are passed to the kernel without sign extension and kernel thinks that it got valid positive values. Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com>
Diffstat (limited to 'libc/sysdeps/linux/sparc/fork.S')
0 files changed, 0 insertions, 0 deletions