Gentoo Archives: gentoo-portage-dev

From: Mike Frysinger <vapier@g.o>
To: gentoo-portage-dev@l.g.o
Subject: [gentoo-portage-dev] [PATCH] install-qa-check.d: issue warnings for 32bit ELFs not using LFS
Date: Tue, 26 May 2015 07:45:00
Message-Id: 1432626293-22692-1-git-send-email-vapier@gentoo.org
1 From: Mike Frysinger <vapier@××××××××.org>
2
3 Start issuing QA warnings when ELFs are installed using the old 32bit
4 file interface. This programs can fail when working with large files
5 (like ones more than 4GiB), but even just trying to stat a file that
6 happens to have a 64bit inode. It also can lead to silent corruption
7 when one library/app is using 64bit structures and tries to work with
8 another one that uses 32bit (or vice versa). This is because the API
9 might utilize off_t's, the library was compiled with off_t==off64_t,
10 and the app was compiled with off_t==off32_t.
11
12 X-Gentoo-Bug: 471102
13 X-Gentoo-Bug-url: https://bugs.gentoo.org/471102
14 ---
15 bin/install-qa-check.d/10large-file-support | 158 ++++++++++++++++++++++++++++
16 1 file changed, 158 insertions(+)
17 create mode 100644 bin/install-qa-check.d/10large-file-support
18
19 diff --git a/bin/install-qa-check.d/10large-file-support b/bin/install-qa-check.d/10large-file-support
20 new file mode 100644
21 index 0000000..34726d7
22 --- /dev/null
23 +++ b/bin/install-qa-check.d/10large-file-support
24 @@ -0,0 +1,158 @@
25 +# Detect 32-bit builds that are using legacy 32-bit file interfaces.
26 +# https://en.wikipedia.org/wiki/Large_file_support
27 +#
28 +# We want to make sure everyone is using the 64-bit interfaces.
29 +# https://bugs.gentoo.org/471102
30 +
31 +# Lists gleaned from headers and this doc:
32 +# http://people.redhat.com/berrange/notes/largefile.html
33 +# http://opengroup.org/platform/lfs.html
34 +SYMBOLS=(
35 + # aio.h
36 + aio_cancel
37 + aio_error
38 + aio_fsync
39 + aio_read
40 + aio_return
41 + aio_suspend
42 + aio_write
43 + lio_listio
44 +
45 + # dirent.h
46 + alphasort
47 + getdirentries
48 + readdir
49 + readdir_r
50 + scandir
51 + scandirat
52 + versionsort
53 +
54 + # fcntl.h
55 + creat
56 + fallocate
57 + fopen
58 + fopenat
59 + freopen
60 + open
61 + openat
62 + posix_fadvise
63 + posix_fallocate
64 + __open
65 + __open_2
66 + __openat_2
67 +
68 + # ftw.h
69 + ftw
70 + nftw
71 +
72 + # glob.h
73 + glob
74 + globfree
75 +
76 + # stdio.h
77 + fgetpos
78 + fopen
79 + freopen
80 + fseeko
81 + fsetpos
82 + ftello
83 + tmpfile
84 +
85 + # stdlib.h
86 + mkostemp
87 + mkostemps
88 + mkstemp
89 + mkstemps
90 +
91 + # sys/mman.h
92 + mmap
93 +
94 + # sys/resource.h
95 + getrlimit
96 + prlimit
97 + setrlimit
98 +
99 + # sys/sendfile.h
100 + sendfile
101 +
102 + # sys/stat.h
103 + fstat
104 + fstatat
105 + lstat
106 + stat
107 + __fxstat
108 + __fxstatat
109 + __lxstat
110 + __xstat
111 +
112 + # sys/statfs.h
113 + fstatfs
114 +
115 + # sys/statvfs.h
116 + statvfs
117 + fstatvfs
118 +
119 + # unistd.h
120 + lockf
121 + lseek
122 + ftruncate
123 + pread
124 + preadv
125 + pwrite
126 + pwritev
127 + truncate
128 + __pread_chk
129 +)
130 +SYMBOLS_REGEX=$(printf '%s|' "${SYMBOLS[@]}")
131 +# The @@ part is to workaround a limitation in pax-utils w/versioned symbols.
132 +SYMBOLS_REGEX="^(${SYMBOLS_REGEX%|})(@@.*)?$"
133 +
134 +check_lfs() {
135 + local files=$(scanelf -F '%s %p' -qyRgs "-${SYMBOLS_REGEX}" "$@")
136 +
137 + if [[ -n ${files} ]]; then
138 + echo
139 + eqawarn "QA Notice: The following files were not built with LFS support:"
140 + eqawarn " Please see https://bugs.gentoo.org/471102 for details."
141 + eqawarn "${files}"
142 + echo
143 + fi
144 +}
145 +
146 +filtered_check_lfs() {
147 + if ! type -P scanelf >/dev/null || has binchecks ${RESTRICT}; then
148 + return
149 + fi
150 +
151 + # Only check glibc & uClibc libraries. Others are presumed to use LFS by
152 + # default (e.g. musl), or it's not relevant (e.g. newlib).
153 + case ${CHOST} in
154 + *-gnu*|*-uclibc*) ;;
155 + *) return ;;
156 + esac
157 +
158 + # Only check on 32-bit systems. Filtering by $ARCH here isn't perfect, but
159 + # it should be good enough for our needs.
160 + case ${ARCH} in
161 + arm|mips|ppc|sh|x86) ;;
162 + *) return ;;
163 + esac
164 +
165 + # Obviously filter out C libraries themselves :).
166 + # The sandbox has to capture all symbols by design.
167 + case ${CATEGORY}/${PN} in
168 + */glibc|\
169 + */uclibc|\
170 + */gcc|\
171 + sys-apps/sandbox) ;;
172 + *) check_lfs "${ED}" ;;
173 + esac
174 +}
175 +
176 +# Allow for people to run manually for testing/debugging.
177 +if [[ $# -ne 0 ]]; then
178 + eqawarn() { echo " * $*"; }
179 + check_lfs "$@"
180 +else
181 + filtered_check_lfs
182 +fi
183 --
184 2.4.1

Replies