mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-10 07:10:06 +00:00
ccf970c7a7
This patch follows commit 5554304f0
(posix: Allow glob to match dangling
symlinks [BZ #866]) by adding a compat symbol that follow previous
semantic of not following dangling symlinks and thus avoiding call
gl_lstat with GLOB_ALTDIRFUNC.
It avoids failure with old binaries that not set the alternate function
pointer for lstat (GNUmake for instance). The following scenario, for
instance, fails with current GNUmake because glibc will access unitialized
memory when calling gl_lstat:
$ cat src/t/t.c
int main ()
{
return 0;
}
$ cat Makefile
SRC = $(wildcard src/*/t.c)
OBJ = $(patsubst src/%.c, obj/%.o, $(SRC))
prog: $(OBJ)
$(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) $(OBJ) -o prog
obj/%.o: src/%.c
$(CC) $(CFLAGS) -c $< -o $@
$ make
This works as expected with the patch applied. Since it is for generic
ABI, default compat symbols are added with override for Linux due LFS.
Now we have two compat symbols for glob on Linux:
1. sysdeps/unix/sysv/linux/oldglob.c which implements glob64 with
the old dirent layout. For this implementation I also set it to
not follow dangling symlinks (which is the safest path).
2. sysdeps/unix/sysv/linux/glob{64}-lstat-compat.c which implements
the compat symbol for dangling symlinks. As for generic glob,
the implementation uses XSTAT_IS_XSTAT64 to define whether
both __glob_lstat_compat and __glob64_lstat_compat should be
different implementations. For archictures that define
XSTAT_IS_XSTAT64, __glob_lstat_compat is aliased to
__glob64_lstat_compat.
3. sysdeps/unix/sysv/linux/alpha/oldglob.c with a different glob_t
layout. As for 1. this patch changes it to not follow dangling
symlinks.
The patch also bumps _GNU_GLOB_INTERFACE_VERSION to 2 to advertise the
new semantic. On GNUmake, for instance, it will force to it use its
internal glob implementation instead and avoiding triggering the same
failure on builds against newer GLIBCs.
Checked on x86_64-linux-gnu and i686-linux-gnu. I also checked
with a build against the major ABIs required to check for the abilist.
The changes should also work on gnulib (I run gnulib-tool.py check glob
and it shown no regressions).
[BZ #22183]
* include/gnu-versions.h (_GNU_GLOB_INTERFACE_VERSION): Increase
version to 2.
* posix/Makefile (routines): Add glob-lstat-compat and
glob64-lstat-compat.
* posix/Versions (GLIBC_2.27, glob, glob64): Add symbol version.
* posix/glob-lstat-compat.c: New file.
* posix/glob64-lstat-compat.c: Likewise.
* posix/tst-glob_lstat_compat.c: Likewise.
* sysdeps/unix/sysv/linux/glob-lstat-compat.c: Likewise.
* sysdeps/unix/sysv/linux/alpha/glob-lstat-compat.c: Likewise.
* sysdeps/unix/sysv/linux/glob64-lstat-compat.c: Likewise.
* sysdeps/unix/sysv/linux/alpha/glob.c: Remove file.
* posix/glob.c (glob_lstat): New function.
(glob): Rename to __glob and add versioned symbol to 2.27.
(glob_in_dir): Use glob_lstat.
* posix/glob64.c (glob64): Add GLOB_ATTRIBUTE.
* sysdeps/unix/sysv/linux/arm/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/glob.c (glob): Add versioned symbol for
2.27.
* sysdeps/unix/sysv/linux/glob64.c (glob64): Likewise.
* sysdeps/unix/sysv/linux/oldglob.c (GLOB_NO_LSTAT): Define.
* sysdeps/unix/sysv/linux/alpha/oldglob.c (__old_glob): Do not use
gl_lstat on glob call.
* sysdeps/unix/sysv/linux/aarch64/libc.abilist: Add GLIBC_2.27 glob
and glob64 symbols.
* sysdeps/unix/sysv/linux/alpha/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/hppa/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/i386/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/ia64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/microblaze/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/nios2/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist:
Likewise.
* sysdeps/unix/linux/powerpc/powerpc32/nofpu/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sh/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist: Likewise.
* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist: Likewise.
53 lines
2.3 KiB
C
53 lines
2.3 KiB
C
/* Header with interface version macros for library pieces copied elsewhere.
|
|
Copyright (C) 1995-2017 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, see
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
#ifndef _GNU_VERSIONS_H
|
|
#define _GNU_VERSIONS_H 1
|
|
|
|
/* This file exists to define these few macros. Each specifies a version
|
|
number associated with the library interface of a piece of the C library
|
|
which is also distributed with other GNU packages. These pieces are
|
|
both part of the GNU C library and also distributed with other GNU
|
|
packages so those packages may use their facilities on systems lacking
|
|
the GNU C library. The source files for each piece surround all their
|
|
code with `#ifndef ELIDE_CODE' after defining it with this:
|
|
|
|
#define OBSTACK_INTERFACE_VERSION 1
|
|
#if !defined (_LIBC) && defined (__GNU_LIBRARY__) && __GNU_LIBRARY__ > 1
|
|
#include <gnu-versions.h>
|
|
#if _GNU_OBSTACK_INTERFACE_VERSION == OBSTACK_INTERFACE_VERSION
|
|
#define ELIDE_CODE
|
|
#endif
|
|
#endif
|
|
|
|
This allows those one to avoid compiling those files when part of a GNU
|
|
package not libc, on a system using a GNU C library that supports the
|
|
same interface.
|
|
|
|
Please preserve the format of the comments after each macro. And
|
|
remember, if any of these versions change, the libc.so major version
|
|
number must change too (so avoid it)! */
|
|
|
|
#define _GNU_OBSTACK_INTERFACE_VERSION 1 /* vs malloc/obstack.c */
|
|
#define _GNU_REGEX_INTERFACE_VERSION 1 /* vs posix/regex.c */
|
|
#define _GNU_GLOB_INTERFACE_VERSION 2 /* vs posix/glob.c */
|
|
#define _GNU_GETOPT_INTERFACE_VERSION 2 /* vs posix/getopt.c and
|
|
posix/getopt1.c */
|
|
|
|
#endif /* gnu-versions.h */
|