[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commits] r13719 - in /fsf/trunk/libc: ./ elf/ include/ resolv/ sysdeps/unix/ sysdeps/unix/sysv/linux/sys/



Author: eglibc
Date: Sun May  8 00:42:11 2011
New Revision: 13719

Log:
Import glibc-mainline for 2011-05-08

Modified:
    fsf/trunk/libc/ChangeLog
    fsf/trunk/libc/NEWS
    fsf/trunk/libc/elf/dl-close.c
    fsf/trunk/libc/elf/dl-load.c
    fsf/trunk/libc/elf/dl-reloc.c
    fsf/trunk/libc/include/dirent.h
    fsf/trunk/libc/resolv/res_debug.c
    fsf/trunk/libc/resolv/res_init.c
    fsf/trunk/libc/resolv/res_query.c
    fsf/trunk/libc/resolv/resolv.h
    fsf/trunk/libc/sysdeps/unix/fdopendir.c
    fsf/trunk/libc/sysdeps/unix/opendir.c
    fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/param.h
    fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/sysmacros.h

Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sun May  8 00:42:11 2011
@@ -1,3 +1,51 @@
+2011-05-08  Ulrich Drepper  <drepper@xxxxxxxxx>
+
+	* include/dirent.h (__alloc_dir): Add flags parameter.
+	* sysdeps/unix/fdopendir.c (__fdopendir): Pass flags to __alloc_dir.
+	* sysdeps/unix/opendir.c (__opendir): Pass 0 in new parameter to
+	__alloc_dir.
+	(__alloc_dir): Take new parameter.  Don't call fcntl for invocations
+	from fdopendir if O_CLOEXEC is already set.
+
+2011-03-15  Alan Modra  <amodra@xxxxxxxxx>
+
+	* elf/dl-reloc.c (_dl_try_allocate_static_tls <TLS_DTV_AT_TP>): Handle
+	l_tls_firstbyte_offset non-zero.  Save padding offset in
+	l_tls_firstbyte_offset for later use.
+	* elf/dl-close.c (_dl_close_worker <TLS_DTV_AT_TP>): Correct code
+	freeing static tls block.
+
+2011-03-05  Jonathan Nieder  <jrnieder@xxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/sys/param.h: Fix an #ifndef __undef_ARG_MAX
+	where #ifdef was intended.  The intent is to prevent ARG_MAX from
+	being defined by the kernel headers.
+
+2011-05-07  Ulrich Drepper  <drepper@xxxxxxxxx>
+
+	[BZ #12734]
+	* resolv/resolv.h: Define RES_NOTLDQUERY.
+	* resolv/res_init.c (res_setoptions): Recognize no_tld_query and
+	no-tld-query and set RES_NOTLDQUERY.
+	* resolv/res_debug.c (p_option): Handle RES_NOTLDQUERY.
+	* resolv/res_query.c (__libc_res_nsearch): Backport changes from
+	modern BIND to search name as TLD unless forbidden.
+
+2011-05-07  Petr Baudis  <pasky@xxxxxxx>
+	    Ulrich Drepper  <drepper@xxxxxxxxx>
+
+	[BZ #12393]
+	* elf/dl-load.c (fillin_rpath): Move trusted path check...
+	(is_trusted_path): ...to here.
+	(is_trusted_path_normalize): Wrapper for /../ and /./ normalization.
+	(_dl_dst_substitute): Verify expanded $ORIGIN path elements
+	using is_trusted_path_normalize() in setuid scripts.
+
+2011-05-06  Paul Pluzhnikov  <ppluzhnikov@xxxxxxxxxx>
+
+	* sysdeps/unix/sysv/linux/sys/sysmacros.h: Add missing
+	__BEGIN/__END_DECLS.
+
 2011-05-06  Ulrich Drepper  <drepper@xxxxxxxxx>
 
 	* nss/nss_files/files-initgroups.c (_nss_files_initgroups_dyn): Return

Modified: fsf/trunk/libc/NEWS
==============================================================================
--- fsf/trunk/libc/NEWS (original)
+++ fsf/trunk/libc/NEWS Sun May  8 00:42:11 2011
@@ -1,4 +1,4 @@
-GNU C Library NEWS -- history of user-visible changes.  2011-5-5
+GNU C Library NEWS -- history of user-visible changes.  2011-5-7
 Copyright (C) 1992-2009, 2010, 2011 Free Software Foundation, Inc.
 See the end for copying conditions.
 
@@ -22,8 +22,9 @@
 
 * The following bugs are resolved with this release:
 
-  11724, 12420, 12445, 12454, 12460, 12469, 12489, 12509, 12510, 12518, 12583,
-  12587, 12597, 12631, 12650, 12653, 12655, 12685, 12714, 12717, 12723
+  11724, 12393, 12420, 12445, 12454, 12460, 12469, 12489, 12509, 12510,
+  12518, 12583, 12587, 12597, 12631, 12650, 12653, 12655, 12685, 12714,
+  12717, 12723, 12734
 
 Version 2.13
 

Modified: fsf/trunk/libc/elf/dl-close.c
==============================================================================
--- fsf/trunk/libc/elf/dl-close.c (original)
+++ fsf/trunk/libc/elf/dl-close.c Sun May  8 00:42:11 2011
@@ -591,21 +591,37 @@
 			}
 		    }
 #elif TLS_DTV_AT_TP
-		  if ((size_t) imap->l_tls_offset == tls_free_end)
+		  if (tls_free_start == NO_TLS_OFFSET)
+		    {
+		      tls_free_start = imap->l_tls_firstbyte_offset;
+		      tls_free_end = (imap->l_tls_offset
+				      + imap->l_tls_blocksize);
+		    }
+		  else if (imap->l_tls_firstbyte_offset == tls_free_end)
 		    /* Extend the contiguous chunk being reclaimed.  */
-		    tls_free_end -= imap->l_tls_blocksize;
+		    tls_free_end = imap->l_tls_offset + imap->l_tls_blocksize;
 		  else if (imap->l_tls_offset + imap->l_tls_blocksize
 			   == tls_free_start)
 		    /* Extend the chunk backwards.  */
-		    tls_free_start = imap->l_tls_offset;
-		  else
+		    tls_free_start = imap->l_tls_firstbyte_offset;
+		  /* This isn't contiguous with the last chunk freed.
+		     One of them will be leaked unless we can free
+		     one block right away.  */
+		  else if (imap->l_tls_offset + imap->l_tls_blocksize
+			   == GL(dl_tls_static_used))
+		    GL(dl_tls_static_used) = imap->l_tls_firstbyte_offset;
+		  else if (tls_free_end == GL(dl_tls_static_used))
 		    {
-		      /* This isn't contiguous with the last chunk freed.
-			 One of them will be leaked.  */
-		      if (tls_free_end == GL(dl_tls_static_used))
-			GL(dl_tls_static_used) = tls_free_start;
-		      tls_free_start = imap->l_tls_offset;
-		      tls_free_end = tls_free_start + imap->l_tls_blocksize;
+		      GL(dl_tls_static_used) = tls_free_start;
+		      tls_free_start = imap->l_tls_firstbyte_offset;
+		      tls_free_end = imap->l_tls_offset + imap->l_tls_blocksize;
+		    }
+		  else if (tls_free_end < imap->l_tls_firstbyte_offset)
+		    {
+		      /* We pick the later block.  It has a chance to
+			 be freed.  */
+		      tls_free_start = imap->l_tls_firstbyte_offset;
+		      tls_free_end = imap->l_tls_offset + imap->l_tls_blocksize;
 		    }
 #else
 # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"

Modified: fsf/trunk/libc/elf/dl-load.c
==============================================================================
--- fsf/trunk/libc/elf/dl-load.c (original)
+++ fsf/trunk/libc/elf/dl-load.c Sun May  8 00:42:11 2011
@@ -1,5 +1,5 @@
 /* Map in a shared object's segments from the file.
-   Copyright (C) 1995-2005, 2006, 2007, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1995-2007, 2009, 2010, 2011 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
@@ -168,6 +168,71 @@
 }
 
 
+static bool
+is_trusted_path (const char *path, size_t len)
+{
+  /* All trusted directories must be complete names.  */
+  if (path[0] != '/')
+    return false;
+
+  const char *trun = system_dirs;
+
+  for (size_t idx = 0; idx < nsystem_dirs_len; ++idx)
+    {
+      if (len == system_dirs_len[idx] && memcmp (trun, path, len) == 0)
+	/* Found it.  */
+	return true;
+
+      trun += system_dirs_len[idx] + 1;
+    }
+
+  return false;
+}
+
+
+static bool
+is_trusted_path_normalize (const char *path, size_t len)
+{
+  char *npath = (char *) alloca (len + 2);
+  char *wnp = npath;
+
+  while (*path != '\0')
+    {
+      if (path[0] == '/')
+	{
+	  if (path[1] == '.')
+	    {
+	      if (path[2] == '.' && (path[3] == '/' || path[3] == '\0'))
+		{
+		  while (wnp > npath && *--wnp != '/')
+		    ;
+		  path += 3;
+		  continue;
+		}
+	      else if (path[2] == '/' || path[2] == '\0')
+		{
+		  path += 2;
+		  continue;
+		}
+	    }
+
+	  if (wnp > npath && wnp[-1] == '/')
+	    {
+	      ++path;
+	      continue;
+	    }
+	}
+
+      *wnp++ = *path++;
+    }
+  if (wnp > npath && wnp[-1] != '/')
+    *wnp++ = '/';
+  *wnp = '\0';
+
+  return is_trusted_path (npath, wnp - npath);
+}
+
+
 static size_t
 is_dst (const char *start, const char *name, const char *str,
 	int is_path, int secure)
@@ -240,13 +305,14 @@
 		    int is_path)
 {
   const char *const start = name;
-  char *last_elem, *wp;
 
   /* Now fill the result path.  While copying over the string we keep
      track of the start of the last path element.  When we come accross
      a DST we copy over the value or (if the value is not available)
      leave the entire path element out.  */
-  last_elem = wp = result;
+  char *wp = result;
+  char *last_elem = result;
+  bool check_for_trusted = false;
 
   do
     {
@@ -265,6 +331,9 @@
 	      else
 #endif
 		repl = l->l_origin;
+
+	      check_for_trusted = (INTUSE(__libc_enable_secure)
+				   && l->l_type == lt_executable);
 	    }
 	  else if ((len = is_dst (start, name, "PLATFORM", is_path, 0)) != 0)
 	    repl = GLRO(dl_platform);
@@ -297,10 +366,28 @@
 	{
 	  *wp++ = *name++;
 	  if (is_path && *name == ':')
-	    last_elem = wp;
+	    {
+	      /* In SUID/SGID programs, after $ORIGIN expansion the
+		 normalized path must be rooted in one of the trusted
+		 directories.  */
+	      if (__builtin_expect (check_for_trusted, false)
+		  && is_trusted_path_normalize (last_elem, wp - last_elem))
+		{
+		  wp = last_elem;
+		  check_for_trusted = false;
+		}
+	      else
+		last_elem = wp;
+	    }
 	}
     }
   while (*name != '\0');
+
+  /* In SUID/SGID programs, after $ORIGIN expansion the normalized
+     path must be rooted in one of the trusted directories.  */
+  if (__builtin_expect (check_for_trusted, false)
+      && is_trusted_path_normalize (last_elem, wp - last_elem))
+    wp = last_elem;
 
   *wp = '\0';
 
@@ -411,33 +498,8 @@
 	cp[len++] = '/';
 
       /* Make sure we don't use untrusted directories if we run SUID.  */
-      if (__builtin_expect (check_trusted, 0))
-	{
-	  const char *trun = system_dirs;
-	  size_t idx;
-	  int unsecure = 1;
-
-	  /* All trusted directories must be complete names.  */
-	  if (cp[0] == '/')
-	    {
-	      for (idx = 0; idx < nsystem_dirs_len; ++idx)
-		{
-		  if (len == system_dirs_len[idx]
-		      && memcmp (trun, cp, len) == 0)
-		    {
-		      /* Found it.  */
-		      unsecure = 0;
-		      break;
-		    }
-
-		  trun += system_dirs_len[idx] + 1;
-		}
-	    }
-
-	  if (unsecure)
-	    /* Simply drop this directory.  */
-	    continue;
-	}
+      if (__builtin_expect (check_trusted, 0) && !is_trusted_path (cp, len))
+	continue;
 
       /* See if this directory is already known.  */
       for (dirp = GL(dl_all_dirs); dirp != NULL; dirp = dirp->next)

Modified: fsf/trunk/libc/elf/dl-reloc.c
==============================================================================
--- fsf/trunk/libc/elf/dl-reloc.c (original)
+++ fsf/trunk/libc/elf/dl-reloc.c Sun May  8 00:42:11 2011
@@ -1,5 +1,5 @@
 /* Relocate a shared object and resolve its references to other loaded objects.
-   Copyright (C) 1995-2006, 2008, 2009, 2010 Free Software Foundation, Inc.
+   Copyright (C) 1995-2006, 2008-2010, 2011 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
@@ -57,38 +57,34 @@
     }
 
 #if TLS_TCB_AT_TP
-  size_t freebytes;
-  size_t n;
-  size_t blsize;
-
-  freebytes = GL(dl_tls_static_size) - GL(dl_tls_static_used);
+  size_t freebytes = GL(dl_tls_static_size) - GL(dl_tls_static_used);
   if (freebytes < TLS_TCB_SIZE)
     goto fail;
   freebytes -= TLS_TCB_SIZE;
 
-  blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset;
+  size_t blsize = map->l_tls_blocksize + map->l_tls_firstbyte_offset;
   if (freebytes < blsize)
     goto fail;
 
-  n = (freebytes - blsize) / map->l_tls_align;
+  size_t n = (freebytes - blsize) / map->l_tls_align;
 
   size_t offset = GL(dl_tls_static_used) + (freebytes - n * map->l_tls_align
 					    - map->l_tls_firstbyte_offset);
 
   map->l_tls_offset = GL(dl_tls_static_used) = offset;
 #elif TLS_DTV_AT_TP
-  size_t used;
-  size_t check;
-
-  size_t offset = roundup (GL(dl_tls_static_used), map->l_tls_align);
-  used = offset + map->l_tls_blocksize;
-  check = used;
   /* dl_tls_static_used includes the TCB at the beginning.  */
-
-  if (check > GL(dl_tls_static_size))
+  size_t offset = (((GL(dl_tls_static_used)
+		     - map->l_tls_firstbyte_offset
+		     + map->l_tls_align - 1) & -map->l_tls_align)
+		   + map->l_tls_firstbyte_offset);
+  size_t used = offset + map->l_tls_blocksize;
+
+  if (used > GL(dl_tls_static_size))
     goto fail;
 
   map->l_tls_offset = offset;
+  map->l_tls_firstbyte_offset = GL(dl_tls_static_used);
   GL(dl_tls_static_used) = used;
 #else
 # error "Either TLS_TCB_AT_TP or TLS_DTV_AT_TP must be defined"

Modified: fsf/trunk/libc/include/dirent.h
==============================================================================
--- fsf/trunk/libc/include/dirent.h (original)
+++ fsf/trunk/libc/include/dirent.h Sun May  8 00:42:11 2011
@@ -28,7 +28,8 @@
 extern int __versionsort64 (const struct dirent64 **a,
 			    const struct dirent64 **b)
      __attribute_pure__;
-extern DIR *__alloc_dir (int fd, bool close_fd, const struct stat64 *statp)
+extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
+			 const struct stat64 *statp)
      internal_function;
 
 #endif

Modified: fsf/trunk/libc/resolv/res_debug.c
==============================================================================
--- fsf/trunk/libc/resolv/res_debug.c (original)
+++ fsf/trunk/libc/resolv/res_debug.c Sun May  8 00:42:11 2011
@@ -189,7 +189,7 @@
 						buf = malloc(buflen += 1024);
 					if (buf == NULL) {
 						fprintf(file,
-				              ";; memory allocation failure\n");
+					      ";; memory allocation failure\n");
 					      return;
 					}
 					continue;
@@ -356,7 +356,7 @@
 	{C_HS,		"HESIOD"},
 	{C_ANY,		"ANY"},
 	{C_NONE,	"NONE"},
-	{C_IN, 		(char *)0}
+	{C_IN,		(char *)0}
 };
 libresolv_hidden_data_def (__p_class_syms)
 
@@ -588,6 +588,7 @@
 	case RES_USEBSTRING:	return "ip6-bytstring";
 	case RES_USE_EDNS0:	return "edns0";
 	case RES_USE_DNSSEC:	return "dnssec";
+	case RES_NOTLDQUERY:	return "no-tld-query";
 				/* XXX nonreentrant */
 	default:		sprintf(nbuf, "?0x%lx?", (u_long)option);
 				return (nbuf);

Modified: fsf/trunk/libc/resolv/res_init.c
==============================================================================
--- fsf/trunk/libc/resolv/res_init.c (original)
+++ fsf/trunk/libc/resolv/res_init.c Sun May  8 00:42:11 2011
@@ -545,6 +545,11 @@
 		} else if (!strncmp(cp, "single-request",
 				    sizeof("single-request") - 1)) {
 			statp->options |= RES_SNGLKUP;
+		} else if (!strncmp(cp, "no_tld_query",
+				    sizeof("no_tld_query") - 1) ||
+			   !strncmp(cp, "no-tld-query",
+				    sizeof("no-tld-query") - 1)) {
+			statp->options |= RES_NOTLDQUERY;
 		} else {
 			/* XXX - print a warning here? */
 		}

Modified: fsf/trunk/libc/resolv/res_query.c
==============================================================================
--- fsf/trunk/libc/resolv/res_query.c (original)
+++ fsf/trunk/libc/resolv/res_query.c Sun May  8 00:42:11 2011
@@ -123,7 +123,7 @@
 {
 	HEADER *hp = (HEADER *) answer;
 	int n, use_malloc = 0;
-        u_int oflags = statp->_flags;
+	u_int oflags = statp->_flags;
 
 	size_t bufsize = (type == T_UNSPEC ? 2 : 1) * QUERYSIZE;
 	u_char *buf = alloca (bufsize);
@@ -210,7 +210,7 @@
 			if (statp->options & RES_DEBUG)
 				printf(";; res_nquery: retry without EDNS0\n");
 #endif
-                        goto again;
+			goto again;
 		}
 #ifdef DEBUG
 		if (statp->options & RES_DEBUG)
@@ -344,6 +344,7 @@
 	int trailing_dot, ret, saved_herrno;
 	int got_nodata = 0, got_servfail = 0, root_on_list = 0;
 	int tried_as_is = 0;
+	int searched = 0;
 
 	__set_errno (0);
 	RES_SET_H_ERRNO(statp, HOST_NOT_FOUND);  /* True if we never query. */
@@ -406,6 +407,7 @@
 		for (domain = (const char * const *)statp->dnsrch;
 		     *domain && !done;
 		     domain++) {
+			searched = 1;
 
 			if (domain[0][0] == '\0' ||
 			    (domain[0][0] == '.' && domain[0][1] == '\0'))
@@ -477,11 +479,11 @@
 	}
 
 	/*
-	 * If the name has any dots at all, and no earlier 'as-is' query
-	 * for the name, and "." is not on the search list, then try an as-is
-	 * query now.
+	 * f the query has not already been tried as is then try it
+	 * unless RES_NOTLDQUERY is set and there were no dots.
 	 */
-	if (dots && !(tried_as_is || root_on_list)) {
+	if ((dots || !searched || (statp->options & RES_NOTLDQUERY) == 0)
+	    && !(tried_as_is || root_on_list)) {
 		ret = __libc_res_nquerydomain(statp, name, NULL, class, type,
 					      answer, anslen, answerp,
 					      answerp2, nanswerp2, resplen2);

Modified: fsf/trunk/libc/resolv/resolv.h
==============================================================================
--- fsf/trunk/libc/resolv/resolv.h (original)
+++ fsf/trunk/libc/resolv/resolv.h Sun May  8 00:42:11 2011
@@ -102,7 +102,7 @@
 # define RES_MAXTIME		65535	/* Infinity, in milliseconds. */
 
 struct __res_state {
-	int	retrans;	 	/* retransmition time interval */
+	int	retrans;		/* retransmition time interval */
 	int	retry;			/* number of times to retransmit */
 	u_long	options;		/* option flags - see below. */
 	int	nscount;		/* number of name servers */
@@ -219,6 +219,8 @@
 #define RES_SNGLKUPREOP	0x00400000	/* -"-, but open new socket for each
 					   request */
 #define RES_USE_DNSSEC	0x00800000	/* use DNSSEC using OK bit in OPT */
+#define RES_NOTLDQUERY	0x01000000	/* Do not look up unqualified name
+					   as a TLD.  */
 
 #define RES_DEFAULT	(RES_RECURSE|RES_DEFNAMES|RES_DNSRCH|RES_NOIP6DOTINT)
 

Modified: fsf/trunk/libc/sysdeps/unix/fdopendir.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/fdopendir.c (original)
+++ fsf/trunk/libc/sysdeps/unix/fdopendir.c Sun May  8 00:42:11 2011
@@ -1,4 +1,4 @@
-/* Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+/* Copyright (C) 2005, 2006, 2011 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
@@ -47,6 +47,6 @@
       return NULL;
     }
 
-  return __alloc_dir (fd, false, &statbuf);
+  return __alloc_dir (fd, false, flags, &statbuf);
 }
 weak_alias (__fdopendir, fdopendir)

Modified: fsf/trunk/libc/sysdeps/unix/opendir.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/opendir.c (original)
+++ fsf/trunk/libc/sysdeps/unix/opendir.c Sun May  8 00:42:11 2011
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-1996,98,2000-2003,2005,2007,2009
+/* Copyright (C) 1991-1996,98,2000-2003,2005,2007,2009,2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -138,7 +138,7 @@
       statp = &statbuf;
     }
 
-  return __alloc_dir (fd, true, statp);
+  return __alloc_dir (fd, true, 0, statp);
 }
 weak_alias (__opendir, opendir)
 
@@ -158,13 +158,14 @@
 
 DIR *
 internal_function
-__alloc_dir (int fd, bool close_fd, const struct stat64 *statp)
+__alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp)
 {
   /* We always have to set the close-on-exit flag if the user provided
      the file descriptor.  Otherwise only if we have no working
      O_CLOEXEC support.  */
 #ifdef O_CLOEXEC
-  if (! close_fd || ! check_have_o_cloexec (fd))
+  if ((! close_fd && (flags & O_CLOEXEC) == 0)
+      || ! check_have_o_cloexec (fd))
 #endif
     {
       if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0)

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/param.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/param.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/param.h Sun May  8 00:42:11 2011
@@ -1,4 +1,5 @@
-/* Copyright (C) 1995-1997,2000,2001,2003,2008 Free Software Foundation, Inc.
+/* Copyright (C) 1995-1997,2000,2001,2003,2008,2011
+   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,7 +29,7 @@
 #include <linux/param.h>
 
 /* The kernel headers defines ARG_MAX.  The value is wrong, though.  */
-#ifndef __undef_ARG_MAX
+#ifdef __undef_ARG_MAX
 # undef ARG_MAX
 # undef __undef_ARG_MAX
 #endif

Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/sysmacros.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/sysmacros.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/sys/sysmacros.h Sun May  8 00:42:11 2011
@@ -1,5 +1,5 @@
 /* Definitions of macros to access `dev_t' values.
-   Copyright (C) 1996, 1997, 1999, 2003, 2004, 2007
+   Copyright (C) 1996, 1997, 1999, 2003, 2004, 2007, 2011
    Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -27,6 +27,8 @@
    not going to hack weird hacks to support the dev_t representation
    they need.  */
 #ifdef __GLIBC_HAVE_LONG_LONG
+__BEGIN_DECLS
+
 __extension__
 extern unsigned int gnu_dev_major (unsigned long long int __dev)
      __THROW;
@@ -59,7 +61,7 @@
 	  | (((unsigned long long int) (__major & ~0xfff)) << 32));
 }
 # endif
-
+__END_DECLS
 
 /* Access the functions with their traditional names.  */
 # define major(dev) gnu_dev_major (dev)