This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch, master, updated. glibc-2.15-64-gd9a216c


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, master has been updated
       via  d9a216c037590c414e4069afde01fde84794e0d6 (commit)
       via  15cfed3f93f60e79508043047065f189754f8e35 (commit)
      from  ac097f5cd08c8e60097297bd51e04f4fe1b25cc0 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d9a216c037590c414e4069afde01fde84794e0d6

commit d9a216c037590c414e4069afde01fde84794e0d6
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sun Jan 8 11:55:32 2012 -0500

    Add checking versions of poll and ppoll

diff --git a/ChangeLog b/ChangeLog
index 776323a..85b8420 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 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.
 
diff --git a/NEWS b/NEWS
index 01f55dc..7d5de0a 100644
--- a/NEWS
+++ b/NEWS
@@ -36,6 +36,9 @@ Version 2.16
 * 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.
 
 Version 2.15
 
diff --git a/debug/Makefile b/debug/Makefile
index 579fce6..dca4e97 100644
--- a/debug/Makefile
+++ b/debug/Makefile
@@ -44,7 +44,7 @@ routines  = backtrace backtracesyms backtracesymsfd noophooks \
 	    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
diff --git a/debug/Versions b/debug/Versions
index 3db4a29..c1722fa 100644
--- a/debug/Versions
+++ b/debug/Versions
@@ -52,6 +52,9 @@ libc {
   GLIBC_2.15 {
     __fdelt_chk; __fdelt_warn;
   }
+  GLIBC_2.16 {
+    __poll_chk; __ppoll_chk;
+  }
   GLIBC_PRIVATE {
     __fortify_fail;
   }
diff --git a/sysdeps/mach/hurd/ppoll.c b/debug/poll_chk.c
similarity index 71%
copy from sysdeps/mach/hurd/ppoll.c
copy to debug/poll_chk.c
index 693bc13..df795e8 100644
--- a/sysdeps/mach/hurd/ppoll.c
+++ b/debug/poll_chk.c
@@ -1,5 +1,4 @@
-/* poll file descriptors.  Hurd version.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+/* 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
@@ -18,13 +17,13 @@
    02111-1307 USA.  */
 
 #include <sys/poll.h>
-#include <sys/time.h>
-#include <hurd.h>
-#include <hurd/fd.h>
+
 
 int
-ppoll (struct pollfd *fds, nfds_t nfds,
-       const struct timespec *timeout, const sigset_t *sigmask)
+__poll_chk (struct pollfd *fds, nfds_t nfds, int timeout, __SIZE_TYPE__ fdslen)
 {
-  return _hurd_select (nfds, fds, NULL, NULL, NULL, timeout, sigmask);
+  if (fdslen / sizeof (*fds) < nfds)
+    __chk_fail ();
+
+  return __poll (fds, nfds, timeout);
 }
diff --git a/sysdeps/mach/hurd/ppoll.c b/debug/ppoll_chk.c
similarity index 71%
copy from sysdeps/mach/hurd/ppoll.c
copy to debug/ppoll_chk.c
index 693bc13..63f9223 100644
--- a/sysdeps/mach/hurd/ppoll.c
+++ b/debug/ppoll_chk.c
@@ -1,5 +1,4 @@
-/* poll file descriptors.  Hurd version.
-   Copyright (C) 2006 Free Software Foundation, Inc.
+/* 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
@@ -18,13 +17,14 @@
    02111-1307 USA.  */
 
 #include <sys/poll.h>
-#include <sys/time.h>
-#include <hurd.h>
-#include <hurd/fd.h>
+
 
 int
-ppoll (struct pollfd *fds, nfds_t nfds,
-       const struct timespec *timeout, const sigset_t *sigmask)
+__ppoll_chk (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
+	     const __sigset_t *ss, __SIZE_TYPE__ fdslen)
 {
-  return _hurd_select (nfds, fds, NULL, NULL, NULL, timeout, sigmask);
+  if (fdslen / sizeof (*fds) < nfds)
+    __chk_fail ();
+
+  return ppoll (fds, nfds, timeout, ss);
 }
diff --git a/debug/tst-chk1.c b/debug/tst-chk1.c
index 7f0186e..2593ab9 100644
--- a/debug/tst-chk1.c
+++ b/debug/tst-chk1.c
@@ -1,4 +1,4 @@
-/* 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.
 
@@ -29,6 +29,7 @@
 #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>
@@ -1476,5 +1477,21 @@ do_test (void)
   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;
 }
diff --git a/include/bits/poll2.h b/include/bits/poll2.h
new file mode 100644
index 0000000..51a0812
--- /dev/null
+++ b/include/bits/poll2.h
@@ -0,0 +1 @@
+#include "../../io/bits/poll2.h"
diff --git a/include/sys/poll.h b/include/sys/poll.h
index 7d12e1c..4285eee 100644
--- a/include/sys/poll.h
+++ b/include/sys/poll.h
@@ -4,5 +4,6 @@
 extern int __poll (struct pollfd *__fds, unsigned long int __nfds,
 		   int __timeout);
 libc_hidden_proto (__poll)
+libc_hidden_proto (ppoll)
 
 #endif
diff --git a/io/bits/poll2.h b/io/bits/poll2.h
new file mode 100644
index 0000000..7a9dd8a
--- /dev/null
+++ b/io/bits/poll2.h
@@ -0,0 +1,78 @@
+/* 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
diff --git a/io/ppoll.c b/io/ppoll.c
index a035cfe..b161a47 100644
--- a/io/ppoll.c
+++ b/io/ppoll.c
@@ -1,4 +1,4 @@
-/* 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.
 
@@ -73,4 +73,5 @@ ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
 #ifndef ppoll
 /* __poll handles cancellation.  */
 LIBC_CANCEL_HANDLED ();
+libc_hidden_def (ppoll);
 #endif
diff --git a/io/sys/poll.h b/io/sys/poll.h
index a9bd180..c0a7e04 100644
--- a/io/sys/poll.h
+++ b/io/sys/poll.h
@@ -71,4 +71,10 @@ extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
 
 __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 */
diff --git a/sysdeps/mach/hurd/ppoll.c b/sysdeps/mach/hurd/ppoll.c
index 693bc13..f8db6f0 100644
--- a/sysdeps/mach/hurd/ppoll.c
+++ b/sysdeps/mach/hurd/ppoll.c
@@ -1,5 +1,5 @@
 /* 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
@@ -28,3 +28,4 @@ ppoll (struct pollfd *fds, nfds_t nfds,
 {
   return _hurd_select (nfds, fds, NULL, NULL, NULL, timeout, sigmask);
 }
+libc_hidden_def (ppoll)
diff --git a/sysdeps/unix/sysv/linux/ppoll.c b/sysdeps/unix/sysv/linux/ppoll.c
index 14eb311..b331b3a 100644
--- a/sysdeps/unix/sysv/linux/ppoll.c
+++ b/sysdeps/unix/sysv/linux/ppoll.c
@@ -1,4 +1,4 @@
-/* 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.
 
@@ -67,6 +67,7 @@ ppoll (struct pollfd *fds, nfds_t nfds, const struct timespec *timeout,
 
   return result;
 }
+libc_hidden_def (ppoll)
 
 # ifndef __ASSUME_PPOLL
 #  define ppoll static __generic_ppoll

http://sources.redhat.com/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=15cfed3f93f60e79508043047065f189754f8e35

commit 15cfed3f93f60e79508043047065f189754f8e35
Author: Ulrich Drepper <drepper@gmail.com>
Date:   Sun Jan 8 11:48:44 2012 -0500

    Regenerated

diff --git a/configure b/configure
index 8483b78..71e8de1 100755
--- a/configure
+++ b/configure
@@ -3562,7 +3562,6 @@ else
 fi
 
 
-static=yes
 # Check whether --enable-shared was given.
 if test "${enable_shared+set}" = set; then :
   enableval=$enable_shared; shared=$enableval

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                       |   14 +++++++
 NEWS                            |    3 +
 configure                       |    1 -
 debug/Makefile                  |    2 +-
 debug/Versions                  |    3 +
 debug/poll_chk.c                |   29 ++++++++++++++
 debug/ppoll_chk.c               |   30 +++++++++++++++
 debug/tst-chk1.c                |   19 +++++++++-
 include/bits/poll2.h            |    1 +
 include/sys/poll.h              |    1 +
 io/bits/poll2.h                 |   78 +++++++++++++++++++++++++++++++++++++++
 io/ppoll.c                      |    3 +-
 io/sys/poll.h                   |    6 +++
 sysdeps/mach/hurd/ppoll.c       |    3 +-
 sysdeps/unix/sysv/linux/ppoll.c |    3 +-
 15 files changed, 190 insertions(+), 6 deletions(-)
 create mode 100644 debug/poll_chk.c
 create mode 100644 debug/ppoll_chk.c
 create mode 100644 include/bits/poll2.h
 create mode 100644 io/bits/poll2.h


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]