From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28535 invoked from network); 27 Sep 2022 19:09:09 -0000 Received: from second.openwall.net (193.110.157.125) by inbox.vuxu.org with ESMTPUTF8; 27 Sep 2022 19:09:09 -0000 Received: (qmail 25784 invoked by uid 550); 27 Sep 2022 19:09:07 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 25746 invoked from network); 27 Sep 2022 19:09:06 -0000 Date: Tue, 27 Sep 2022 15:08:54 -0400 From: Rich Felker To: musl@lists.openwall.com Message-ID: <20220927190853.GI9709@brightrain.aerifal.cx> References: <20220926010339.GA9709@brightrain.aerifal.cx> <20220926220449.GE9709@brightrain.aerifal.cx> <20220927122005.GG9709@brightrain.aerifal.cx> <20220927190357.GH9709@brightrain.aerifal.cx> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="K1n7F7fSdjvFAEnM" Content-Disposition: inline In-Reply-To: <20220927190357.GH9709@brightrain.aerifal.cx> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: Re: [musl] Revisiting LFS64 removal --K1n7F7fSdjvFAEnM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Sep 27, 2022 at 03:03:57PM -0400, Rich Felker wrote: > On Tue, Sep 27, 2022 at 08:20:05AM -0400, Rich Felker wrote: > > On Tue, Sep 27, 2022 at 11:09:48AM +0200, Gabriel Ravier wrote: > > > On 9/27/22 00:04, Rich Felker wrote: > > > >On Sun, Sep 25, 2022 at 09:03:40PM -0400, Rich Felker wrote: > > > >>[...] > > > >>Of course these interfaces should not be used, and we never intended > > > >>for them to be used just there for linking-compat. So, I've wanted to > > > >>get rid of them for a long time now. > > > >> > > > >>I believe the simplest short-term way is probably going to be just > > > >>having the dynamic linker symbol lookup error path make one final > > > >>check before bailing out with an error: > > > >> > > > >>- If the symbol to lookup ends in "64".. > > > >>- ..and it's in a hard-coded list of LFS64-compat symbols.. > > > >>- ..and looking up the name with the "64" removed in libc succeeds.. > > > >> > > > >>Then use the version without the "64" suffix and go on with relocation > > > >>processing. > > > >Proposed patch attached. > > > > > > > Looks at though the patch contains a buffer overflow to me, as the > > > length of `name` appears to be unbounded, but it's then copied into > > > `buf` which has its size limited to 16, all without checking for `l > > > >= sizeof buf` until after the copying is done (which might just > > > even get optimized out by GCC since it knows `l` can't be larger > > > than buf without UB occuring) > > > > Thanks for the catch! It was a late change I made to avoid > > re-iterating but indeed it's wrong. (Note that strlen, etc. can't be > > used here because external function calls or even references are not > > valid in the context this can be called in; strcmp is a macro that > > expands to a static function call.) > > Updated version. And the follow-up patch which removes the macro interfaces. Note that there's not necessarily any reason these need to be done together. Removing the macros is not safe without removing the symbols, due to autoconf badness, but once the symbols are gone we're free to choose if/when to remove the macros. Rich --K1n7F7fSdjvFAEnM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="0002-remove-LFS64-programming-interfaces-macro-only-from-.patch" >From aac73f06584ea256eec7724d95622f09f30385bd Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Tue, 27 Sep 2022 15:04:05 -0400 Subject: [PATCH] remove LFS64 programming interfaces (macro-only) from public headers these badly pollute the namespace with macros whenever _GNU_SOURCE is defined, which is always the case with g++, and especially tends to interfere with C++ constructs. as our implementation of these was macro-only, their removal cannot affect any existing binaries. at the source level, portable software should be prepared for them not to exist. --- include/aio.h | 13 ------------- include/dirent.h | 12 ------------ include/fcntl.h | 14 -------------- include/ftw.h | 5 ----- include/glob.h | 6 ------ include/stdio.h | 12 ------------ include/stdlib.h | 9 --------- include/sys/mman.h | 5 ----- include/sys/resource.h | 10 ---------- include/sys/sendfile.h | 5 ----- include/sys/stat.h | 12 ------------ include/sys/statfs.h | 7 ------- include/sys/statvfs.h | 7 ------- include/sys/types.h | 8 -------- include/sys/uio.h | 5 ----- include/unistd.h | 10 ---------- 16 files changed, 140 deletions(-) diff --git a/include/aio.h b/include/aio.h index 453c41b7..c5198938 100644 --- a/include/aio.h +++ b/include/aio.h @@ -49,19 +49,6 @@ int aio_fsync(int, struct aiocb *); int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sigevent *__restrict); -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define aiocb64 aiocb -#define aio_read64 aio_read -#define aio_write64 aio_write -#define aio_error64 aio_error -#define aio_return64 aio_return -#define aio_cancel64 aio_cancel -#define aio_suspend64 aio_suspend -#define aio_fsync64 aio_fsync -#define lio_listio64 lio_listio -#define off64_t off_t -#endif - #if _REDIR_TIME64 __REDIR(aio_suspend, __aio_suspend_time64); #endif diff --git a/include/dirent.h b/include/dirent.h index 650ecf64..7ec7cf69 100644 --- a/include/dirent.h +++ b/include/dirent.h @@ -56,18 +56,6 @@ int getdents(int, struct dirent *, size_t); int versionsort(const struct dirent **, const struct dirent **); #endif -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define dirent64 dirent -#define readdir64 readdir -#define readdir64_r readdir_r -#define scandir64 scandir -#define alphasort64 alphasort -#define versionsort64 versionsort -#define off64_t off_t -#define ino64_t ino_t -#define getdents64 getdents -#endif - #ifdef __cplusplus } #endif diff --git a/include/fcntl.h b/include/fcntl.h index b664cdc4..3494fde4 100644 --- a/include/fcntl.h +++ b/include/fcntl.h @@ -195,20 +195,6 @@ ssize_t tee(int, int, size_t, unsigned); #define loff_t off_t #endif -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define F_GETLK64 F_GETLK -#define F_SETLK64 F_SETLK -#define F_SETLKW64 F_SETLKW -#define flock64 flock -#define open64 open -#define openat64 openat -#define creat64 creat -#define lockf64 lockf -#define posix_fadvise64 posix_fadvise -#define posix_fallocate64 posix_fallocate -#define off64_t off_t -#endif - #ifdef __cplusplus } #endif diff --git a/include/ftw.h b/include/ftw.h index b15c062a..dfb7db93 100644 --- a/include/ftw.h +++ b/include/ftw.h @@ -29,11 +29,6 @@ struct FTW { int ftw(const char *, int (*)(const char *, const struct stat *, int), int); int nftw(const char *, int (*)(const char *, const struct stat *, int, struct FTW *), int, int); -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define ftw64 ftw -#define nftw64 nftw -#endif - #ifdef __cplusplus } #endif diff --git a/include/glob.h b/include/glob.h index 4a562a20..718bef44 100644 --- a/include/glob.h +++ b/include/glob.h @@ -39,12 +39,6 @@ void globfree(glob_t *); #define GLOB_NOMATCH 3 #define GLOB_NOSYS 4 -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define glob64 glob -#define globfree64 globfree -#define glob64_t glob_t -#endif - #ifdef __cplusplus } #endif diff --git a/include/stdio.h b/include/stdio.h index d1ed01f0..67acad1e 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -205,18 +205,6 @@ typedef struct _IO_cookie_io_functions_t { FILE *fopencookie(void *, const char *, cookie_io_functions_t); #endif -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define tmpfile64 tmpfile -#define fopen64 fopen -#define freopen64 freopen -#define fseeko64 fseeko -#define ftello64 ftello -#define fgetpos64 fgetpos -#define fsetpos64 fsetpos -#define fpos64_t fpos_t -#define off64_t off_t -#endif - #ifdef __cplusplus } #endif diff --git a/include/stdlib.h b/include/stdlib.h index b507ca33..6f6b708c 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -163,15 +163,6 @@ double strtod_l(const char *__restrict, char **__restrict, struct __locale_struc long double strtold_l(const char *__restrict, char **__restrict, struct __locale_struct *); #endif -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define mkstemp64 mkstemp -#define mkostemp64 mkostemp -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define mkstemps64 mkstemps -#define mkostemps64 mkostemps -#endif -#endif - #ifdef __cplusplus } #endif diff --git a/include/sys/mman.h b/include/sys/mman.h index 80a3baae..facab648 100644 --- a/include/sys/mman.h +++ b/include/sys/mman.h @@ -141,11 +141,6 @@ int mincore (void *, size_t, unsigned char *); int shm_open (const char *, int, mode_t); int shm_unlink (const char *); -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define mmap64 mmap -#define off64_t off_t -#endif - #ifdef __cplusplus } #endif diff --git a/include/sys/resource.h b/include/sys/resource.h index 3068328d..d4c2f688 100644 --- a/include/sys/resource.h +++ b/include/sys/resource.h @@ -95,16 +95,6 @@ int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); #define RLIM_NLIMITS RLIMIT_NLIMITS -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define RLIM64_INFINITY RLIM_INFINITY -#define RLIM64_SAVED_CUR RLIM_SAVED_CUR -#define RLIM64_SAVED_MAX RLIM_SAVED_MAX -#define getrlimit64 getrlimit -#define setrlimit64 setrlimit -#define rlimit64 rlimit -#define rlim64_t rlim_t -#endif - #if _REDIR_TIME64 __REDIR(getrusage, __getrusage_time64); #endif diff --git a/include/sys/sendfile.h b/include/sys/sendfile.h index e7570d8e..7273aed1 100644 --- a/include/sys/sendfile.h +++ b/include/sys/sendfile.h @@ -10,11 +10,6 @@ extern "C" { ssize_t sendfile(int, int, off_t *, size_t); -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define sendfile64 sendfile -#define off64_t off_t -#endif - #ifdef __cplusplus } #endif diff --git a/include/sys/stat.h b/include/sys/stat.h index 10d446c4..cdd2a455 100644 --- a/include/sys/stat.h +++ b/include/sys/stat.h @@ -98,18 +98,6 @@ int lchmod(const char *, mode_t); #define S_IEXEC S_IXUSR #endif -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define stat64 stat -#define fstat64 fstat -#define lstat64 lstat -#define fstatat64 fstatat -#define blkcnt64_t blkcnt_t -#define fsblkcnt64_t fsblkcnt_t -#define fsfilcnt64_t fsfilcnt_t -#define ino64_t ino_t -#define off64_t off_t -#endif - #if _REDIR_TIME64 __REDIR(stat, __stat_time64); __REDIR(fstat, __fstat_time64); diff --git a/include/sys/statfs.h b/include/sys/statfs.h index 6f4c6230..bcdb0d17 100644 --- a/include/sys/statfs.h +++ b/include/sys/statfs.h @@ -18,13 +18,6 @@ typedef struct __fsid_t { int statfs (const char *, struct statfs *); int fstatfs (int, struct statfs *); -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define statfs64 statfs -#define fstatfs64 fstatfs -#define fsblkcnt64_t fsblkcnt_t -#define fsfilcnt64_t fsfilcnt_t -#endif - #ifdef __cplusplus } #endif diff --git a/include/sys/statvfs.h b/include/sys/statvfs.h index 793490b6..12f5f695 100644 --- a/include/sys/statvfs.h +++ b/include/sys/statvfs.h @@ -42,13 +42,6 @@ int fstatvfs (int, struct statvfs *); #define ST_NODIRATIME 2048 #define ST_RELATIME 4096 -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define statvfs64 statvfs -#define fstatvfs64 fstatvfs -#define fsblkcnt64_t fsblkcnt_t -#define fsfilcnt64_t fsfilcnt_t -#endif - #ifdef __cplusplus } #endif diff --git a/include/sys/types.h b/include/sys/types.h index 0c35541d..71a27bb3 100644 --- a/include/sys/types.h +++ b/include/sys/types.h @@ -71,14 +71,6 @@ typedef unsigned long long u_quad_t; #include #endif -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define blkcnt64_t blkcnt_t -#define fsblkcnt64_t fsblkcnt_t -#define fsfilcnt64_t fsfilcnt_t -#define ino64_t ino_t -#define off64_t off_t -#endif - #ifdef __cplusplus } #endif diff --git a/include/sys/uio.h b/include/sys/uio.h index 00f73a2f..fb228c6b 100644 --- a/include/sys/uio.h +++ b/include/sys/uio.h @@ -29,11 +29,6 @@ ssize_t writev (int, const struct iovec *, int); #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) ssize_t preadv (int, const struct iovec *, int, off_t); ssize_t pwritev (int, const struct iovec *, int, off_t); -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define preadv64 preadv -#define pwritev64 pwritev -#define off64_t off_t -#endif #endif #ifdef _GNU_SOURCE diff --git a/include/unistd.h b/include/unistd.h index 0e8149e4..20f5eb35 100644 --- a/include/unistd.h +++ b/include/unistd.h @@ -198,16 +198,6 @@ ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); pid_t gettid(void); #endif -#if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE) -#define lseek64 lseek -#define pread64 pread -#define pwrite64 pwrite -#define truncate64 truncate -#define ftruncate64 ftruncate -#define lockf64 lockf -#define off64_t off_t -#endif - #define POSIX_CLOSE_RESTART 0 #define _XOPEN_VERSION 700 -- 2.21.0 --K1n7F7fSdjvFAEnM--