From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id CEC15138CD1 for ; Tue, 26 May 2015 07:45:00 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D6FA1E08A4; Tue, 26 May 2015 07:44:58 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 5C811E08A4 for ; Tue, 26 May 2015 07:44:58 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 3314F3408BD for ; Tue, 26 May 2015 07:44:57 +0000 (UTC) From: Mike Frysinger To: gentoo-portage-dev@lists.gentoo.org Subject: [gentoo-portage-dev] [PATCH] install-qa-check.d: issue warnings for 32bit ELFs not using LFS Date: Tue, 26 May 2015 03:44:53 -0400 Message-Id: <1432626293-22692-1-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.4.1 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 136712db-9b85-4375-bd52-b81185f040fd X-Archives-Hash: c181b26a107a502be25e862795c3b13b From: Mike Frysinger Start issuing QA warnings when ELFs are installed using the old 32bit file interface. This programs can fail when working with large files (like ones more than 4GiB), but even just trying to stat a file that happens to have a 64bit inode. It also can lead to silent corruption when one library/app is using 64bit structures and tries to work with another one that uses 32bit (or vice versa). This is because the API might utilize off_t's, the library was compiled with off_t==off64_t, and the app was compiled with off_t==off32_t. X-Gentoo-Bug: 471102 X-Gentoo-Bug-url: https://bugs.gentoo.org/471102 --- bin/install-qa-check.d/10large-file-support | 158 ++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 bin/install-qa-check.d/10large-file-support diff --git a/bin/install-qa-check.d/10large-file-support b/bin/install-qa-check.d/10large-file-support new file mode 100644 index 0000000..34726d7 --- /dev/null +++ b/bin/install-qa-check.d/10large-file-support @@ -0,0 +1,158 @@ +# Detect 32-bit builds that are using legacy 32-bit file interfaces. +# https://en.wikipedia.org/wiki/Large_file_support +# +# We want to make sure everyone is using the 64-bit interfaces. +# https://bugs.gentoo.org/471102 + +# Lists gleaned from headers and this doc: +# http://people.redhat.com/berrange/notes/largefile.html +# http://opengroup.org/platform/lfs.html +SYMBOLS=( + # aio.h + aio_cancel + aio_error + aio_fsync + aio_read + aio_return + aio_suspend + aio_write + lio_listio + + # dirent.h + alphasort + getdirentries + readdir + readdir_r + scandir + scandirat + versionsort + + # fcntl.h + creat + fallocate + fopen + fopenat + freopen + open + openat + posix_fadvise + posix_fallocate + __open + __open_2 + __openat_2 + + # ftw.h + ftw + nftw + + # glob.h + glob + globfree + + # stdio.h + fgetpos + fopen + freopen + fseeko + fsetpos + ftello + tmpfile + + # stdlib.h + mkostemp + mkostemps + mkstemp + mkstemps + + # sys/mman.h + mmap + + # sys/resource.h + getrlimit + prlimit + setrlimit + + # sys/sendfile.h + sendfile + + # sys/stat.h + fstat + fstatat + lstat + stat + __fxstat + __fxstatat + __lxstat + __xstat + + # sys/statfs.h + fstatfs + + # sys/statvfs.h + statvfs + fstatvfs + + # unistd.h + lockf + lseek + ftruncate + pread + preadv + pwrite + pwritev + truncate + __pread_chk +) +SYMBOLS_REGEX=$(printf '%s|' "${SYMBOLS[@]}") +# The @@ part is to workaround a limitation in pax-utils w/versioned symbols. +SYMBOLS_REGEX="^(${SYMBOLS_REGEX%|})(@@.*)?$" + +check_lfs() { + local files=$(scanelf -F '%s %p' -qyRgs "-${SYMBOLS_REGEX}" "$@") + + if [[ -n ${files} ]]; then + echo + eqawarn "QA Notice: The following files were not built with LFS support:" + eqawarn " Please see https://bugs.gentoo.org/471102 for details." + eqawarn "${files}" + echo + fi +} + +filtered_check_lfs() { + if ! type -P scanelf >/dev/null || has binchecks ${RESTRICT}; then + return + fi + + # Only check glibc & uClibc libraries. Others are presumed to use LFS by + # default (e.g. musl), or it's not relevant (e.g. newlib). + case ${CHOST} in + *-gnu*|*-uclibc*) ;; + *) return ;; + esac + + # Only check on 32-bit systems. Filtering by $ARCH here isn't perfect, but + # it should be good enough for our needs. + case ${ARCH} in + arm|mips|ppc|sh|x86) ;; + *) return ;; + esac + + # Obviously filter out C libraries themselves :). + # The sandbox has to capture all symbols by design. + case ${CATEGORY}/${PN} in + */glibc|\ + */uclibc|\ + */gcc|\ + sys-apps/sandbox) ;; + *) check_lfs "${ED}" ;; + esac +} + +# Allow for people to run manually for testing/debugging. +if [[ $# -ne 0 ]]; then + eqawarn() { echo " * $*"; } + check_lfs "$@" +else + filtered_check_lfs +fi -- 2.4.1