2012-01-08 Ulrich Drepper <drepper@gmail.com>
+ * debug/Makefile (routines): Add poll_chk and ppoll_chk.
+ * debug/Versions: Export __pool_chk and __ppoll_chk from libc for
+ GLIBC_2.16.
+ * debug/tst-chk1.c: Add poll and ppoll tests.
+ * io/sys/poll.h: Include bits/poll2.h for _FORTIFY_SOURCE.
+ * include/sys/poll.h: Add hidden proto for ppoll.
+ * sysdeps/unix/sysv/linux/ppoll.c: Add hidden def.
+ * sysdeps/mach/hurd/ppoll.c: Likewise.
+ * io/ppoll.c: Likewise.
+ * debug/poll_chk.c: New file.
+ * debug/ppoll_chk.c: New file.
+ * include/bits/poll2.h: New file.
+ * io/bits/poll2.h: New file.
+
[BZ #1350]
* math/complex.h (CMPLX, CMPLXF, CMPLXL): Define.
* Support for the IA-64 is removed and could live in ports.
* Remove support for anything but ELF binary format
+
+* Checking versions of poll, ppoll added.
+ Implemented by Ulrich Drepper.
\f
Version 2.15
wcstombs_chk asprintf_chk vasprintf_chk dprintf_chk \
vdprintf_chk obprintf_chk \
longjmp_chk ____longjmp_chk \
- fdelt_chk \
+ fdelt_chk poll_chk ppoll_chk \
stack_chk_fail fortify_fail \
$(static-only-routines)
static-only-routines := warning-nop stack_chk_fail_local
GLIBC_2.15 {
__fdelt_chk; __fdelt_warn;
}
+ GLIBC_2.16 {
+ __poll_chk; __ppoll_chk;
+ }
GLIBC_PRIVATE {
__fortify_fail;
}
--- /dev/null
+/* Copyright (C) 2012 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/poll.h>
+
+
+int
+__poll_chk (struct pollfd *fds, nfds_t nfds, int timeout, __SIZE_TYPE__ fdslen)
+{
+ if (fdslen / sizeof (*fds) < nfds)
+ __chk_fail ();
+
+ return __poll (fds, nfds, timeout);
+}
--- /dev/null
+/* Copyright (C) 2012 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <sys/poll.h>
+
+
+int
+__ppoll_chk (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+ const __sigset_t *ss, __SIZE_TYPE__ fdslen)
+{
+ if (fdslen / sizeof (*fds) < nfds)
+ __chk_fail ();
+
+ return ppoll (fds, nfds, timeout, ss);
+}
-/* Copyright (C) 2004,2005,2006,2007,2008,2011 Free Software Foundation, Inc.
+/* Copyright (C) 2004-2008,2011,2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Jakub Jelinek <jakub@redhat.com>, 2004.
#include <string.h>
#include <unistd.h>
#include <wchar.h>
+#include <sys/poll.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
CHK_FAIL_END
#endif
+ struct pollfd fds[1];
+ fds[0].fd = STDOUT_FILENO;
+ fds[0].events = POLLOUT;
+ poll (fds, 1, 0);
+#if __USE_FORTIFY_LEVEL >= 1
+ CHK_FAIL_START
+ poll (fds, 2, 0);
+ CHK_FAIL_END
+#endif
+ ppoll (fds, 1, NULL, NULL);
+#if __USE_FORTIFY_LEVEL >= 1
+ CHK_FAIL_START
+ ppoll (fds, 2, NULL, NULL);
+ CHK_FAIL_END
+#endif
+
return ret;
}
--- /dev/null
+#include "../../io/bits/poll2.h"
extern int __poll (struct pollfd *__fds, unsigned long int __nfds,
int __timeout);
libc_hidden_proto (__poll)
+libc_hidden_proto (ppoll)
#endif
--- /dev/null
+/* Checking macros for poll functions.
+ Copyright (C) 2012 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
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#ifndef _SYS_POLL_H
+# error "Never include <bits/poll2.h> directly; use <sys/poll.h> instead."
+#endif
+
+
+extern int __REDIRECT (__poll_alias, (struct pollfd *__fds, nfds_t __nfds,
+ int __timeout), poll);
+extern int __poll_chk (struct pollfd *__fds, nfds_t __nfds, int __timeout,
+ __SIZE_TYPE__ __fdslen);
+extern int __REDIRECT (__poll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
+ int __timeout, __SIZE_TYPE__ __fdslen),
+ __poll_chk)
+ __warnattr ("poll called with fds buffer too small file nfds entries");
+
+__extern_always_inline int
+poll (struct pollfd *__fds, nfds_t __nfds, int __timeout)
+{
+ if (__bos (__fds) != (__SIZE_TYPE__) -1)
+ {
+ if (! __builtin_constant_p (__nfds))
+ return __poll_chk (__fds, __nfds, __timeout, __bos (__fds));
+ else if (__bos (__fds) / sizeof (*__fds) < __nfds)
+ return __poll_chk_warn (__fds, __nfds, __timeout, __bos (__fds));
+ }
+
+ return __poll_alias (__fds, __nfds, __timeout);
+}
+
+
+#ifdef __USE_GNU
+extern int __REDIRECT (__ppoll_alias, (struct pollfd *__fds, nfds_t __nfds,
+ const struct timespec *__timeout,
+ const __sigset_t *__ss), ppoll);
+extern int __ppoll_chk (struct pollfd *__fds, nfds_t __nfds,
+ const struct timespec *__timeout,
+ const __sigset_t *__ss, __SIZE_TYPE__ __fdslen);
+extern int __REDIRECT (__ppoll_chk_warn, (struct pollfd *__fds, nfds_t __nfds,
+ const struct timespec *__timeout,
+ const __sigset_t *__ss,
+ __SIZE_TYPE__ __fdslen),
+ __ppoll_chk)
+ __warnattr ("ppoll called with fds buffer too small file nfds entries");
+
+__extern_always_inline int
+ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
+ const __sigset_t *__ss)
+{
+ if (__bos (__fds) != (__SIZE_TYPE__) -1)
+ {
+ if (! __builtin_constant_p (__nfds))
+ return __ppoll_chk (__fds, __nfds, __timeout, __ss, __bos (__fds));
+ else if (__bos (__fds) / sizeof (*__fds) < __nfds)
+ return __ppoll_chk_warn (__fds, __nfds, __timeout, __ss,
+ __bos (__fds));
+ }
+
+ return __ppoll_alias (__fds, __nfds, __timeout, __ss);
+}
+#endif
-/* Copyright (C) 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2006, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2006.
#ifndef ppoll
/* __poll handles cancellation. */
LIBC_CANCEL_HANDLED ();
+libc_hidden_def (ppoll);
#endif
__END_DECLS
+
+/* Define some inlines helping to catch common problems. */
+#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
+# include <bits/poll2.h>
+#endif
+
#endif /* sys/poll.h */
/* poll file descriptors. Hurd version.
- Copyright (C) 2006 Free Software Foundation, Inc.
+ Copyright (C) 2006, 2012 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
{
return _hurd_select (nfds, fds, NULL, NULL, NULL, timeout, sigmask);
}
+libc_hidden_def (ppoll)
-/* Copyright (C) 2006, 2007 Free Software Foundation, Inc.
+/* Copyright (C) 2006, 2007, 2012 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2006.
return result;
}
+libc_hidden_def (ppoll)
# ifndef __ASSUME_PPOLL
# define ppoll static __generic_ppoll