diff options
author | Greg McGary <greg@mcgary.org> | 2000-07-07 02:19:06 +0000 |
---|---|---|
committer | Greg McGary <greg@mcgary.org> | 2000-07-07 02:19:06 +0000 |
commit | 4bbb61e414b377b647bcbff13dcd77cc323b3645 (patch) | |
tree | 6e0019e43e58a30861802991cb93f5d2d1f21ecf /sysdeps/unix/sysv/linux/i386 | |
parent | c0f53cdd08913ef09f9bb66fb1b14cd88598cff9 (diff) | |
download | glibc-4bbb61e414b377b647bcbff13dcd77cc323b3645.tar.gz glibc-4bbb61e414b377b647bcbff13dcd77cc323b3645.tar.xz glibc-4bbb61e414b377b647bcbff13dcd77cc323b3645.zip |
* sysdeps/generic/bp-checks.h (CHECK_SIGSET, CHECK_SIGSETopt):
New macros. * sysdeps/generic/strcpy.c: Add bounds checks. * sysdeps/unix/fxstat.c: Likewise. * sysdeps/unix/xstat.c: Likewise. * sysdeps/unix/common/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/aio_sigqueue.c: Likewise. * sysdeps/unix/sysv/linux/execve.c: Likewise. * sysdeps/unix/sysv/linux/fxstat.c: Likewise. * sysdeps/unix/sysv/linux/fxstat64.c: Likewise. * sysdeps/unix/sysv/linux/getcwd.c: Likewise. * sysdeps/unix/sysv/linux/getdents.c: Likewise. * sysdeps/unix/sysv/linux/llseek.c: Likewise. * sysdeps/unix/sysv/linux/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/lxstat64.c: Likewise. * sysdeps/unix/sysv/linux/poll.c: Likewise. * sysdeps/unix/sysv/linux/pread.c: Likewise. * sysdeps/unix/sysv/linux/pread64.c: Likewise. * sysdeps/unix/sysv/linux/ptrace.c: Likewise. * sysdeps/unix/sysv/linux/pwrite.c: Likewise. * sysdeps/unix/sysv/linux/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/readv.c: Likewise. * sysdeps/unix/sysv/linux/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/sigpending.c: Likewise. * sysdeps/unix/sysv/linux/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/sigqueue.c: Likewise. * sysdeps/unix/sysv/linux/sigsuspend.c: Likewise. * sysdeps/unix/sysv/linux/sigtimedwait.c: Likewise. * sysdeps/unix/sysv/linux/sigwaitinfo.c: Likewise. * sysdeps/unix/sysv/linux/sysctl.c: Likewise. * sysdeps/unix/sysv/linux/truncate64.c: Likewise. * sysdeps/unix/sysv/linux/ustat.c: Likewise. * sysdeps/unix/sysv/linux/writev.c: Likewise. * sysdeps/unix/sysv/linux/xmknod.c: Likewise. * sysdeps/unix/sysv/linux/xstat.c: Likewise. * sysdeps/unix/sysv/linux/xstat64.c: Likewise. * sysdeps/unix/sysv/linux/arm/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/i386/brk.c: Likewise. * sysdeps/unix/sysv/linux/i386/chown.c: Likewise. * sysdeps/unix/sysv/linux/i386/fxstat.c: Likewise. * sysdeps/unix/sysv/linux/i386/getgroups.c: Likewise. * sysdeps/unix/sysv/linux/i386/getresgid.c: Likewise. * sysdeps/unix/sysv/linux/i386/getresuid.c: Likewise. * sysdeps/unix/sysv/linux/i386/getrlimit.c: Likewise. * sysdeps/unix/sysv/linux/i386/lchown.c: Likewise. * sysdeps/unix/sysv/linux/i386/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/i386/setgroups.c: Likewise. * sysdeps/unix/sysv/linux/i386/setrlimit.c: Likewise. * sysdeps/unix/sysv/linux/i386/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/i386/xstat.c: Likewise. * sysdeps/unix/sysv/linux/ia64/fxstat.c: Likewise. * sysdeps/unix/sysv/linux/ia64/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/ia64/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/ia64/sigpending.c: Likewise. * sysdeps/unix/sysv/linux/ia64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/ia64/sigsuspend.c: Likewise. * sysdeps/unix/sysv/linux/ia64/xstat.c: Likewise. * sysdeps/unix/sysv/linux/m68k/chown.c: Likewise. * sysdeps/unix/sysv/linux/mips/pread.c: Likewise. * sysdeps/unix/sysv/linux/mips/pread64.c: Likewise. * sysdeps/unix/sysv/linux/mips/pwrite.c: Likewise. * sysdeps/unix/sysv/linux/mips/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/mips/truncate64.c: Likewise. * sysdeps/unix/sysv/linux/mips/ustat.c: Likewise. * sysdeps/unix/sysv/linux/mips/xmknod.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/mmap64.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigpending.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigsuspend.c: Likewise. * sysdeps/generic/bp-checks.h (CHECK_SIGSET, CHECK_SIGSETopt): New macros. * sysdeps/generic/strcpy.c: Add bounds checks. * sysdeps/unix/fxstat.c: Likewise. * sysdeps/unix/xstat.c: Likewise. * sysdeps/unix/common/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/aio_sigqueue.c: Likewise. * sysdeps/unix/sysv/linux/execve.c: Likewise. * sysdeps/unix/sysv/linux/fxstat.c: Likewise. * sysdeps/unix/sysv/linux/fxstat64.c: Likewise. * sysdeps/unix/sysv/linux/getcwd.c: Likewise. * sysdeps/unix/sysv/linux/getdents.c: Likewise. * sysdeps/unix/sysv/linux/llseek.c: Likewise. * sysdeps/unix/sysv/linux/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/lxstat64.c: Likewise. * sysdeps/unix/sysv/linux/poll.c: Likewise. * sysdeps/unix/sysv/linux/pread.c: Likewise. * sysdeps/unix/sysv/linux/pread64.c: Likewise. * sysdeps/unix/sysv/linux/ptrace.c: Likewise. * sysdeps/unix/sysv/linux/pwrite.c: Likewise. * sysdeps/unix/sysv/linux/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/readv.c: Likewise. * sysdeps/unix/sysv/linux/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/sigpending.c: Likewise. * sysdeps/unix/sysv/linux/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/sigqueue.c: Likewise. * sysdeps/unix/sysv/linux/sigsuspend.c: Likewise. * sysdeps/unix/sysv/linux/sigtimedwait.c: Likewise. * sysdeps/unix/sysv/linux/sigwaitinfo.c: Likewise. * sysdeps/unix/sysv/linux/sysctl.c: Likewise. * sysdeps/unix/sysv/linux/truncate64.c: Likewise. * sysdeps/unix/sysv/linux/ustat.c: Likewise. * sysdeps/unix/sysv/linux/writev.c: Likewise. * sysdeps/unix/sysv/linux/xmknod.c: Likewise. * sysdeps/unix/sysv/linux/xstat.c: Likewise. * sysdeps/unix/sysv/linux/xstat64.c: Likewise. * sysdeps/unix/sysv/linux/arm/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/i386/brk.c: Likewise. * sysdeps/unix/sysv/linux/i386/chown.c: Likewise. * sysdeps/unix/sysv/linux/i386/fxstat.c: Likewise. * sysdeps/unix/sysv/linux/i386/getgroups.c: Likewise. * sysdeps/unix/sysv/linux/i386/getresgid.c: Likewise. * sysdeps/unix/sysv/linux/i386/getresuid.c: Likewise. * sysdeps/unix/sysv/linux/i386/getrlimit.c: Likewise. * sysdeps/unix/sysv/linux/i386/lchown.c: Likewise. * sysdeps/unix/sysv/linux/i386/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/i386/setgroups.c: Likewise. * sysdeps/unix/sysv/linux/i386/setrlimit.c: Likewise. * sysdeps/unix/sysv/linux/i386/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/i386/xstat.c: Likewise. * sysdeps/unix/sysv/linux/ia64/fxstat.c: Likewise. * sysdeps/unix/sysv/linux/ia64/lxstat.c: Likewise. * sysdeps/unix/sysv/linux/ia64/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/ia64/sigpending.c: Likewise. * sysdeps/unix/sysv/linux/ia64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/ia64/sigsuspend.c: Likewise. * sysdeps/unix/sysv/linux/ia64/xstat.c: Likewise. * sysdeps/unix/sysv/linux/m68k/chown.c: Likewise. * sysdeps/unix/sysv/linux/mips/pread.c: Likewise. * sysdeps/unix/sysv/linux/mips/pread64.c: Likewise. * sysdeps/unix/sysv/linux/mips/pwrite.c: Likewise. * sysdeps/unix/sysv/linux/mips/pwrite64.c: Likewise. * sysdeps/unix/sysv/linux/mips/truncate64.c: Likewise. * sysdeps/unix/sysv/linux/mips/ustat.c: Likewise. * sysdeps/unix/sysv/linux/mips/xmknod.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc32/mmap64.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigaction.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigpending.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigprocmask.c: Likewise. * sysdeps/unix/sysv/linux/sparc/sparc64/sigsuspend.c: Likewise.
Diffstat (limited to 'sysdeps/unix/sysv/linux/i386')
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/brk.c | 8 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/chown.c | 18 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/fxstat.c | 21 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/getgroups.c | 15 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/getresgid.c | 23 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/getresuid.c | 20 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/getrlimit.c | 13 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/lchown.c | 11 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/lxstat.c | 22 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/setgroups.c | 15 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/setrlimit.c | 15 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/sigaction.c | 12 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/xstat.c | 25 |
13 files changed, 125 insertions, 93 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/brk.c b/sysdeps/unix/sysv/linux/i386/brk.c index 5bb9d59d5c..e528b9bf39 100644 --- a/sysdeps/unix/sysv/linux/i386/brk.c +++ b/sysdeps/unix/sysv/linux/i386/brk.c @@ -1,5 +1,5 @@ /* brk system call for Linux/i386. - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 2000 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -21,6 +21,8 @@ #include <unistd.h> #include <sysdep.h> +#include <bp-checks.h> + /* This must be initialized data because commons can't have aliases. */ void *__curbrk = 0; @@ -32,14 +34,14 @@ weak_alias (__curbrk, ___brk_addr) int __brk (void *addr) { - void *newbrk, *scratch; + void *__unbounded newbrk, *__unbounded scratch; asm ("movl %%ebx, %1\n" /* Save %ebx in scratch register. */ "movl %3, %%ebx\n" /* Put ADDR in %ebx to be syscall arg. */ "int $0x80 # %2\n" /* Perform the system call. */ "movl %1, %%ebx\n" /* Restore %ebx from scratch register. */ : "=a" (newbrk), "=r" (scratch) - : "0" (SYS_ify (brk)), "g" (addr)); + : "0" (SYS_ify (brk)), "g" (__ptrvalue (addr))); __curbrk = newbrk; diff --git a/sysdeps/unix/sysv/linux/i386/chown.c b/sysdeps/unix/sysv/linux/i386/chown.c index 1dce31495b..ce44338d5e 100644 --- a/sysdeps/unix/sysv/linux/i386/chown.c +++ b/sysdeps/unix/sysv/linux/i386/chown.c @@ -21,11 +21,11 @@ #include <sysdep.h> #include <sys/syscall.h> - -#include <kernel-features.h> -#include <linux/posix_types.h> #include <shlib-compat.h> +#include <bp-checks.h> +#include <linux/posix_types.h> +#include "kernel-features.h" /* In Linux 2.1.x the chown functions have been changed. A new function lchown @@ -68,7 +68,7 @@ __real_chown (const char *file, uid_t owner, gid_t group) int result; int saved_errno = errno; - result = INLINE_SYSCALL (chown32, 3, file, owner, group); + result = INLINE_SYSCALL (chown32, 3, CHECK_STRING (file), owner, group); if (result == 0 || errno != ENOSYS) return result; @@ -83,7 +83,7 @@ __real_chown (const char *file, uid_t owner, gid_t group) return -1; } - result = INLINE_SYSCALL (chown, 3, file, owner, group); + result = INLINE_SYSCALL (chown, 3, CHECK_STRING (file), owner, group); if (result >= 0 || errno != ENOSYS) return result; @@ -95,7 +95,7 @@ __real_chown (const char *file, uid_t owner, gid_t group) return __lchown (file, owner, group); # elif __ASSUME_32BITUIDS /* This implies __ASSUME_LCHOWN_SYSCALL. */ - return INLINE_SYSCALL (chown32, 3, file, owner, group); + return INLINE_SYSCALL (chown32, 3, CHECK_STRING (file), owner, group); # else /* !__ASSUME_32BITUIDS && ASSUME_LCHOWN_SYSCALL */ # ifdef __NR_chown32 @@ -104,7 +104,7 @@ __real_chown (const char *file, uid_t owner, gid_t group) int result; int saved_errno = errno; - result = INLINE_SYSCALL (chown32, 3, file, owner, group); + result = INLINE_SYSCALL (chown32, 3, CHECK_STRING (file), owner, group); if (result == 0 || errno != ENOSYS) return result; @@ -119,7 +119,7 @@ __real_chown (const char *file, uid_t owner, gid_t group) return -1; } - return INLINE_SYSCALL (chown, 3, file, owner, group); + return INLINE_SYSCALL (chown, 3, CHECK_STRING (file), owner, group); # endif } #endif @@ -130,7 +130,7 @@ __real_chown (const char *file, uid_t owner, gid_t group) int __chown_is_lchown (const char *file, uid_t owner, gid_t group) { - return INLINE_SYSCALL (chown, 3, file, owner, group); + return INLINE_SYSCALL (chown, 3, CHECK_STRING (file), owner, group); } #elif SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1) /* Compiling for compatibiity. */ diff --git a/sysdeps/unix/sysv/linux/i386/fxstat.c b/sysdeps/unix/sysv/linux/i386/fxstat.c index c4e24cf1e0..e88570c6cf 100644 --- a/sysdeps/unix/sysv/linux/i386/fxstat.c +++ b/sysdeps/unix/sysv/linux/i386/fxstat.c @@ -28,14 +28,16 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <bp-checks.h> + #include "kernel-features.h" #include <xstatconv.c> -extern int __syscall_fstat (int, struct kernel_stat *); +extern int __syscall_fstat (int, struct kernel_stat *__unbounded); #ifdef __NR_stat64 -extern int __syscall_fstat64 (int, struct stat64 *); +extern int __syscall_fstat64 (int, struct stat64 *__unbounded); # if __ASSUME_STAT64_SYSCALL == 0 /* The variable is shared between all wrappers around *stat64 calls. */ extern int __have_no_stat64; @@ -52,14 +54,13 @@ __fxstat (int vers, int fd, struct stat *buf) int result; if (vers == _STAT_VER_KERNEL) - { - return INLINE_SYSCALL (fstat, 2, fd, (struct kernel_stat *) buf); - } + return INLINE_SYSCALL (fstat, 2, fd, CHECK_1 ((struct kernel_stat *) buf)); + #if __ASSUME_STAT64_SYSCALL > 0 { struct stat64 buf64; - result = INLINE_SYSCALL (fstat64, 2, fd, &buf64); + result = INLINE_SYSCALL (fstat64, 2, fd, __ptrvalue (&buf64)); if (result == 0) result = xstat32_conv (vers, &buf64, buf); return result; @@ -73,19 +74,19 @@ __fxstat (int vers, int fd, struct stat *buf) { struct stat64 buf64; - result = INLINE_SYSCALL (fstat64, 2, fd, &buf64); + result = INLINE_SYSCALL (fstat64, 2, fd, __ptrvalue (&buf64)); if (result == 0) result = xstat32_conv (vers, &buf64, buf); - + if (result != -1 || errno != ENOSYS) return result; __have_no_stat64 = 1; } -# endif +# endif - result = INLINE_SYSCALL (fstat, 2, fd, &kbuf); + result = INLINE_SYSCALL (fstat, 2, fd, __ptrvalue (&kbuf)); if (result == 0) result = xstat_conv (vers, &kbuf, buf); diff --git a/sysdeps/unix/sysv/linux/i386/getgroups.c b/sysdeps/unix/sysv/linux/i386/getgroups.c index 071be4f4b7..2efe341e0d 100644 --- a/sysdeps/unix/sysv/linux/i386/getgroups.c +++ b/sysdeps/unix/sysv/linux/i386/getgroups.c @@ -23,14 +23,16 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <bp-checks.h> + #include <linux/posix_types.h> #include <kernel-features.h> -extern int __syscall_getgroups(int, __kernel_gid_t *); +extern int __syscall_getgroups (int, __kernel_gid_t *__unbounded); #ifdef __NR_getgroups32 -extern int __syscall_getgroups32 (int, __kernel_gid32_t *); +extern int __syscall_getgroups32 (int, __kernel_gid32_t *__unbounded); # if __ASSUME_32BITUIDS == 0 /* This variable is shared with all files that need to check for 32bit uids. */ @@ -51,7 +53,7 @@ __getgroups (int n, gid_t *groups) else { #if __ASSUME_32BITUIDS > 0 - return INLINE_SYSCALL (getgroups32, 2, n, groups); + return INLINE_SYSCALL (getgroups32, 2, n, CHECK_N (groups, n)); #else int i, ngids; __kernel_gid_t kernel_groups[n = MIN (n, __sysconf (_SC_NGROUPS_MAX))]; @@ -61,7 +63,7 @@ __getgroups (int n, gid_t *groups) int result; int saved_errno = errno; - result = INLINE_SYSCALL (getgroups32, 2, n, groups); + result = INLINE_SYSCALL (getgroups32, 2, n, CHECK_N (groups, n)); if (result == 0 || errno != ENOSYS) return result; @@ -70,11 +72,10 @@ __getgroups (int n, gid_t *groups) } # endif /* __NR_getgroups32 */ - ngids = INLINE_SYSCALL (getgroups, 2, n, kernel_groups); + ngids = INLINE_SYSCALL (getgroups, 2, n, CHECK_N (kernel_groups, n)); if (n != 0 && ngids > 0) for (i = 0; i < ngids; i++) - groups[i] = kernel_groups[i]; - + (__ptrvalue (groups))[i] = kernel_groups[i]; return ngids; #endif } diff --git a/sysdeps/unix/sysv/linux/i386/getresgid.c b/sysdeps/unix/sysv/linux/i386/getresgid.c index f4bd14da22..da07372595 100644 --- a/sysdeps/unix/sysv/linux/i386/getresgid.c +++ b/sysdeps/unix/sysv/linux/i386/getresgid.c @@ -24,16 +24,20 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <bp-checks.h> + #include "kernel-features.h" #ifdef __NR_getresgid -extern int __syscall_getresgid (__kernel_gid_t *rgid, __kernel_gid_t *egid, - __kernel_gid_t *sgid); +extern int __syscall_getresgid (__kernel_gid_t *__unbounded rgid, + __kernel_gid_t *__unbounded egid, + __kernel_gid_t *__unbounded sgid); # ifdef __NR_getresgid32 -extern int __syscall_getresgid32 (__kernel_gid32_t *rgid, __kernel_gid32_t *egid, - __kernel_gid32_t *sgid); +extern int __syscall_getresgid32 (__kernel_gid32_t *__unbounded rgid, + __kernel_gid32_t *__unbounded egid, + __kernel_gid32_t *__unbounded sgid); # if __ASSUME_32BITUIDS == 0 /* This variable is shared with all files that need to check for 32bit @@ -47,8 +51,9 @@ int getresgid (gid_t *rgid, gid_t *egid, gid_t *sgid) { # if __ASSUME_32BITUIDS > 0 - return INLINE_SYSCALL (getresgid32, 3, rgid, egid, sgid); -# else + return INLINE_SYSCALL (getresgid32, 3, CHECK_1 (rgid), + CHECK_1 (egid), CHECK_1 (sgid)); +# else __kernel_gid_t k_rgid, k_egid, k_sgid; int result; # ifdef __NR_getresgid32 @@ -57,7 +62,8 @@ getresgid (gid_t *rgid, gid_t *egid, gid_t *sgid) int r; int saved_errno = errno; - r = INLINE_SYSCALL (getresgid32, 3, rgid, egid, sgid); + r = INLINE_SYSCALL (getresgid32, 3, CHECK_1 (rgid), + CHECK_1 (egid), CHECK_1 (sgid)); if (r == 0 || errno != ENOSYS) return r; @@ -66,7 +72,8 @@ getresgid (gid_t *rgid, gid_t *egid, gid_t *sgid) } # endif /* __NR_getresgid32 */ - result = INLINE_SYSCALL (getresgid, 3, &k_rgid, &k_egid, &k_sgid); + result = INLINE_SYSCALL (getresgid, 3, __ptrvalue (&k_rgid), + __ptrvalue (&k_egid), __ptrvalue (&k_sgid)); if (result == 0) { diff --git a/sysdeps/unix/sysv/linux/i386/getresuid.c b/sysdeps/unix/sysv/linux/i386/getresuid.c index 27eca40745..0f9c0640df 100644 --- a/sysdeps/unix/sysv/linux/i386/getresuid.c +++ b/sysdeps/unix/sysv/linux/i386/getresuid.c @@ -24,17 +24,20 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <bp-checks.h> #include "kernel-features.h" #ifdef __NR_getresuid -extern int __syscall_getresuid (__kernel_uid_t *ruid, __kernel_uid_t *euid, - __kernel_uid_t *suid); +extern int __syscall_getresuid (__kernel_uid_t *__unbounded ruid, + __kernel_uid_t *__unbounded euid, + __kernel_uid_t *__unbounded suid); # ifdef __NR_getresuid32 -extern int __syscall_getresuid32 (__kernel_uid32_t *ruid, __kernel_uid32_t *euid, - __kernel_uid32_t *suid); +extern int __syscall_getresuid32 (__kernel_uid32_t *__unbounded ruid, + __kernel_uid32_t *__unbounded euid, + __kernel_uid32_t *__unbounded suid); # if __ASSUME_32BITUIDS == 0 /* This variable is shared with all files that need to check for 32bit uids. */ @@ -46,7 +49,8 @@ int getresuid (uid_t *ruid, uid_t *euid, uid_t *suid) { # if __ASSUME_32BITUIDS > 0 - return INLINE_SYSCALL (getresuid32, 3, ruid, euid, suid); + return INLINE_SYSCALL (getresuid32, 3, CHECK_1 (ruid), + CHECK_1 (euid), CHECK_1 (suid)); # else __kernel_uid_t k_ruid, k_euid, k_suid; int result; @@ -56,7 +60,8 @@ getresuid (uid_t *ruid, uid_t *euid, uid_t *suid) int r; int saved_errno = errno; - r = INLINE_SYSCALL (getresuid32, 3, ruid, euid, suid); + r = INLINE_SYSCALL (getresuid32, 3, CHECK_1 (ruid), + CHECK_1 (euid), CHECK_1 (suid)); if (r == 0 || errno != ENOSYS) return r; @@ -65,7 +70,8 @@ getresuid (uid_t *ruid, uid_t *euid, uid_t *suid) } # endif /* __NR_getresuid32 */ - result = INLINE_SYSCALL (getresuid, 3, &k_ruid, &k_euid, &k_suid); + result = INLINE_SYSCALL (getresuid, 3, __ptrvalue (&k_ruid), + __ptrvalue (&k_euid), __ptrvalue (&k_suid)); if (result == 0) { diff --git a/sysdeps/unix/sysv/linux/i386/getrlimit.c b/sysdeps/unix/sysv/linux/i386/getrlimit.c index c1af81b312..33d011a72c 100644 --- a/sysdeps/unix/sysv/linux/i386/getrlimit.c +++ b/sysdeps/unix/sysv/linux/i386/getrlimit.c @@ -22,11 +22,14 @@ #include <sysdep.h> #include <sys/syscall.h> #include <shlib-compat.h> +#include <bp-checks.h> + #include "kernel-features.h" extern int __syscall_ugetrlimit (unsigned int resource, - struct rlimit *rlimits); -extern int __syscall_getrlimit (unsigned int resource, struct rlimit *rlimits); + struct rlimit *__unbounded rlimits); +extern int __syscall_getrlimit (unsigned int resource, + struct rlimit *__unbounded rlimits); /* Linux 2.3.25 introduced a new system call since the types used for the limits are now unsigned. */ @@ -38,14 +41,14 @@ int __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits) { #ifdef __ASSUME_NEW_GETRLIMIT_SYSCALL - return INLINE_SYSCALL (ugetrlimit, 2, resource, rlimits); + return INLINE_SYSCALL (ugetrlimit, 2, resource, CHECK_1 (rlimits)); #else int result; # ifdef __NR_ugetrlimit if (__have_no_new_getrlimit <= 0) { - result = INLINE_SYSCALL (ugetrlimit, 2, resource, rlimits); + result = INLINE_SYSCALL (ugetrlimit, 2, resource, CHECK_1 (rlimits)); /* If the system call is available remember this fact and return. */ if (result != -1 || errno != ENOSYS) @@ -60,7 +63,7 @@ __new_getrlimit (enum __rlimit_resource resource, struct rlimit *rlimits) # endif /* Fall back to the old system call. */ - result = INLINE_SYSCALL (getrlimit, 2, resource, rlimits); + result = INLINE_SYSCALL (getrlimit, 2, resource, CHECK_1 (rlimits)); if (result == -1) return result; diff --git a/sysdeps/unix/sysv/linux/i386/lchown.c b/sysdeps/unix/sysv/linux/i386/lchown.c index 6e2bb9d0b9..848978e982 100644 --- a/sysdeps/unix/sysv/linux/i386/lchown.c +++ b/sysdeps/unix/sysv/linux/i386/lchown.c @@ -21,16 +21,17 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <bp-checks.h> #include <linux/posix_types.h> #include "kernel-features.h" #ifdef __NR_lchown -extern int __syscall_lchown (const char *__file, +extern int __syscall_lchown (const char *__unbounded __file, __kernel_uid_t __owner, __kernel_gid_t __group); # ifdef __NR_lchown32 -extern int __syscall_lchown32 (const char *__file, +extern int __syscall_lchown32 (const char *__unbounded __file, __kernel_uid32_t __owner, __kernel_gid32_t __group); # if __ASSUME_32BITUIDS == 0 /* This variable is shared with all files that need to check for 32bit @@ -43,7 +44,7 @@ int __lchown (const char *file, uid_t owner, gid_t group) { # if __ASSUME_32BITUIDS > 0 - return INLINE_SYSCALL (lchown32, 3, file, owner, group); + return INLINE_SYSCALL (lchown32, 3, CHECK_STRING (file), owner, group); # else # ifdef __NR_lchown32 if (__libc_missing_32bit_uids <= 0) @@ -51,7 +52,7 @@ __lchown (const char *file, uid_t owner, gid_t group) int result; int saved_errno = errno; - result = INLINE_SYSCALL (lchown32, 3, file, owner, group); + result = INLINE_SYSCALL (lchown32, 3, CHECK_STRING (file), owner, group); if (result == 0 || errno != ENOSYS) return result; @@ -67,7 +68,7 @@ __lchown (const char *file, uid_t owner, gid_t group) return -1; } - return INLINE_SYSCALL (lchown, 3, file, owner, group); + return INLINE_SYSCALL (lchown, 3, CHECK_STRING (file), owner, group); # endif } diff --git a/sysdeps/unix/sysv/linux/i386/lxstat.c b/sysdeps/unix/sysv/linux/i386/lxstat.c index ee89ec125a..e42dcfe759 100644 --- a/sysdeps/unix/sysv/linux/i386/lxstat.c +++ b/sysdeps/unix/sysv/linux/i386/lxstat.c @@ -28,14 +28,18 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <bp-checks.h> + #include "kernel-features.h" #include <xstatconv.c> -extern int __syscall_lstat (const char *, struct kernel_stat *); +extern int __syscall_lstat (const char *__unbounded, + struct kernel_stat *__unbounded); #ifdef __NR_stat64 -extern int __syscall_lstat64 (const char *, struct stat64 *); +extern int __syscall_lstat64 (const char *__unbounded, + struct stat64 *__unbounded); # if __ASSUME_STAT64_SYSCALL == 0 /* The variable is shared between all wrappers around *stat64 calls. */ extern int __have_no_stat64; @@ -53,15 +57,13 @@ __lxstat (int vers, const char *name, struct stat *buf) int result; if (vers == _STAT_VER_KERNEL) - { - return INLINE_SYSCALL (lstat, 2, name, (struct kernel_stat *) buf); - } + return INLINE_SYSCALL (lstat, 2, CHECK_STRING (name), CHECK_1 ((struct kernel_stat *) buf)); #if __ASSUME_STAT64_SYSCALL > 0 { struct stat64 buf64; - result = INLINE_SYSCALL (lstat64, 2, name, &buf64); + result = INLINE_SYSCALL (lstat64, 2, CHECK_STRING (name), __ptrvalue (&buf64)); if (result == 0) result = xstat32_conv (vers, &buf64, buf); return result; @@ -74,7 +76,7 @@ __lxstat (int vers, const char *name, struct stat *buf) if (! __have_no_stat64) { struct stat64 buf64; - result = INLINE_SYSCALL (lstat64, 2, name, &buf64); + result = INLINE_SYSCALL (lstat64, 2, CHECK_STRING (name), __ptrvalue (&buf64)); if (result == 0) result = xstat32_conv (vers, &buf64, buf); @@ -84,9 +86,9 @@ __lxstat (int vers, const char *name, struct stat *buf) __have_no_stat64 = 1; } -# endif - - result = INLINE_SYSCALL (lstat, 2, name, &kbuf); +# endif + + result = INLINE_SYSCALL (lstat, 2, CHECK_STRING (name), __ptrvalue (&kbuf)); if (result == 0) result = xstat_conv (vers, &kbuf, buf); diff --git a/sysdeps/unix/sysv/linux/i386/setgroups.c b/sysdeps/unix/sysv/linux/i386/setgroups.c index 5e73352a1a..a2553b6a25 100644 --- a/sysdeps/unix/sysv/linux/i386/setgroups.c +++ b/sysdeps/unix/sysv/linux/i386/setgroups.c @@ -23,14 +23,16 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <bp-checks.h> + #include <linux/posix_types.h> #include "kernel-features.h" -extern int __syscall_setgroups (int, const __kernel_gid_t *); +extern int __syscall_setgroups (int, const __kernel_gid_t *__unbounded); #ifdef __NR_setgroups32 -extern int __syscall_setgroups32 (int, const __kernel_gid32_t *); +extern int __syscall_setgroups32 (int, const __kernel_gid32_t *__unbounded); # if __ASSUME_32BITUIDS == 0 /* This variable is shared with all files that need to check for 32bit uids. */ @@ -52,17 +54,18 @@ setgroups (size_t n, const gid_t *groups) else { #if __ASSUME_32BITUIDS > 0 - return INLINE_SYSCALL (setgroups32, 2, n, groups); + return INLINE_SYSCALL (setgroups32, 2, n, CHECK_N (groups, n)); #else size_t i; __kernel_gid_t kernel_groups[n]; + # ifdef __NR_setgroups32 if (__libc_missing_32bit_uids <= 0) { int result; int saved_errno = errno; - result = INLINE_SYSCALL (setgroups32, 2, n, groups); + result = INLINE_SYSCALL (setgroups32, 2, n, CHECK_N (groups, n)); if (result == 0 || errno != ENOSYS) return result; @@ -72,7 +75,7 @@ setgroups (size_t n, const gid_t *groups) # endif /* __NR_setgroups32 */ for (i = 0; i < n; i++) { - kernel_groups[i] = groups[i]; + kernel_groups[i] = (__ptrvalue (groups))[i]; if (groups[i] != (gid_t) ((__kernel_gid_t) groups[i])) { __set_errno (EINVAL); @@ -80,7 +83,7 @@ setgroups (size_t n, const gid_t *groups) } } - return INLINE_SYSCALL (setgroups, 2, n, kernel_groups); + return INLINE_SYSCALL (setgroups, 2, n, CHECK_N (kernel_groups, n)); #endif } } diff --git a/sysdeps/unix/sysv/linux/i386/setrlimit.c b/sysdeps/unix/sysv/linux/i386/setrlimit.c index 5ceae60eb1..04b55d1d1c 100644 --- a/sysdeps/unix/sysv/linux/i386/setrlimit.c +++ b/sysdeps/unix/sysv/linux/i386/setrlimit.c @@ -22,14 +22,15 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <shlib-compat.h> +#include <bp-checks.h> #include "kernel-features.h" -#include <shlib-compat.h> extern int __syscall_setrlimit (unsigned int resource, - const struct rlimit *rlimits); + const struct rlimit *__unbounded rlimits); extern int __syscall_ugetrlimit (unsigned int resource, - const struct rlimit *rlimits); + const struct rlimit *__unbounded rlimits); /* Linux 2.3.25 introduced a new system call since the types used for the limits are now unsigned. */ @@ -41,7 +42,7 @@ int __new_setrlimit (enum __rlimit_resource resource, const struct rlimit *rlimits) { #ifdef __ASSUME_NEW_GETRLIMIT_SYSCALL - return INLINE_SYSCALL (setrlimit, 2, resource, rlimits); + return INLINE_SYSCALL (setrlimit, 2, resource, CHECK_1 (rlimits)); #else struct rlimit rlimits_small; @@ -51,7 +52,7 @@ __new_setrlimit (enum __rlimit_resource resource, const struct rlimit *rlimits) /* Check if the new ugetrlimit syscall exists. We must do this first because older kernels don't reject negative rlimit values in setrlimit. */ - int result = INLINE_SYSCALL (ugetrlimit, 2, resource, &rlimits_small); + int result = INLINE_SYSCALL (ugetrlimit, 2, resource, __ptrvalue (&rlimits_small)); if (result != -1 || errno != ENOSYS) /* The syscall exists. */ __have_no_new_getrlimit = -1; @@ -60,7 +61,7 @@ __new_setrlimit (enum __rlimit_resource resource, const struct rlimit *rlimits) __have_no_new_getrlimit = 1; } if (__have_no_new_getrlimit < 0) - return INLINE_SYSCALL (setrlimit, 2, resource, rlimits); + return INLINE_SYSCALL (setrlimit, 2, resource, CHECK_1 (rlimits)); # endif /* We might have to correct the limits values. Since the old values @@ -71,7 +72,7 @@ __new_setrlimit (enum __rlimit_resource resource, const struct rlimit *rlimits) RLIM_INFINITY >> 1); /* Use the adjusted values. */ - return INLINE_SYSCALL (setrlimit, 2, resource, &rlimits_small); + return INLINE_SYSCALL (setrlimit, 2, resource, __ptrvalue (&rlimits_small)); #endif } diff --git a/sysdeps/unix/sysv/linux/i386/sigaction.c b/sysdeps/unix/sysv/linux/i386/sigaction.c index c7493de6bb..faa9afaddd 100644 --- a/sysdeps/unix/sysv/linux/i386/sigaction.c +++ b/sysdeps/unix/sysv/linux/i386/sigaction.c @@ -37,8 +37,8 @@ #define SA_RESTORER 0x04000000 -extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *, - struct kernel_sigaction *, size_t); +extern int __syscall_rt_sigaction (int, const struct kernel_sigaction *__unbounded, + struct kernel_sigaction *__unbounded, size_t); #if __ASSUME_REALTIME_SIGNALS == 0 /* The variable is shared between all wrappers around signal handling @@ -86,8 +86,9 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) /* XXX The size argument hopefully will have to be changed to the real size of the user-level sigset_t. */ - result = INLINE_SYSCALL (rt_sigaction, 4, sig, act ? &kact : NULL, - oact ? &koact : NULL, _NSIG / 8); + result = INLINE_SYSCALL (rt_sigaction, 4, + sig, act ? __ptrvalue (&kact) : NULL, + oact ? __ptrvalue (&koact) : NULL, _NSIG / 8); # if __ASSUME_REALTIME_SIGNALS == 0 if (result >= 0 || errno != ENOSYS) @@ -126,7 +127,8 @@ __libc_sigaction (int sig, const struct sigaction *act, struct sigaction *oact) "popl %%ebx" : "=a" (result) : "0" (SYS_ify (sigaction)), "r" (sig), - "c" (act ? &k_newact : 0), "d" (oact ? &k_oldact : 0)); + "c" (act ? __ptrvalue (&k_newact) : 0), + "d" (oact ? __ptrvalue (&k_oldact) : 0)); if (result < 0) { diff --git a/sysdeps/unix/sysv/linux/i386/xstat.c b/sysdeps/unix/sysv/linux/i386/xstat.c index 7f71a11d0c..54b0876726 100644 --- a/sysdeps/unix/sysv/linux/i386/xstat.c +++ b/sysdeps/unix/sysv/linux/i386/xstat.c @@ -28,15 +28,19 @@ #include <sysdep.h> #include <sys/syscall.h> +#include <bp-checks.h> + #include "kernel-features.h" #include <xstatconv.c> -extern int __syscall_stat (const char *, struct kernel_stat *); +extern int __syscall_stat (const char *__unbounded, + struct kernel_stat *__unbounded); #ifdef __NR_stat64 -extern int __syscall_stat64 (const char *, struct stat64 *); -# if __ASSUME_STAT64_SYSCALL == 0 +extern int __syscall_stat64 (const char *__unbounded, + struct stat64 *__unbounded); +# if __ASSUME_STAT64_SYSCALL == 0 /* The variable is shared between all wrappers around *stat64 calls. */ extern int __have_no_stat64; # endif @@ -53,14 +57,13 @@ __xstat (int vers, const char *name, struct stat *buf) int result; if (vers == _STAT_VER_KERNEL) - { - return INLINE_SYSCALL (stat, 2, name, (struct kernel_stat *) buf); - } + return INLINE_SYSCALL (stat, 2, CHECK_STRING (name), CHECK_1 ((struct kernel_stat *) buf)); + #if __ASSUME_STAT64_SYSCALL > 0 { struct stat64 buf64; - result = INLINE_SYSCALL (stat64, 2, name, &buf64); + result = INLINE_SYSCALL (stat64, 2, CHECK_STRING (name), __ptrvalue (&buf64)); if (result == 0) result = xstat32_conv (vers, &buf64, buf); return result; @@ -73,7 +76,7 @@ __xstat (int vers, const char *name, struct stat *buf) { struct stat64 buf64; - result = INLINE_SYSCALL (stat64, 2, name, &buf64); + result = INLINE_SYSCALL (stat64, 2, CHECK_STRING (name), __ptrvalue (&buf64)); if (result == 0) result = xstat32_conv (vers, &buf64, buf); @@ -83,8 +86,8 @@ __xstat (int vers, const char *name, struct stat *buf) __have_no_stat64 = 1; } -# endif - result = INLINE_SYSCALL (stat, 2, name, &kbuf); +# endif + result = INLINE_SYSCALL (stat, 2, CHECK_STRING (name), __ptrvalue (&kbuf)); if (result == 0) result = xstat_conv (vers, &kbuf, buf); @@ -94,6 +97,6 @@ __xstat (int vers, const char *name, struct stat *buf) weak_alias (__xstat, _xstat); #ifdef XSTAT_IS_XSTAT64 -#undef __xstat64 +# undef __xstat64 strong_alias (__xstat, __xstat64); #endif |