From patchwork Wed Sep 25 00:31:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 34650 Received: (qmail 118988 invoked by alias); 25 Sep 2019 00:35:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 118970 invoked by uid 89); 25 Sep 2019 00:35:33 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy=4010, HContent-Transfer-Encoding:8bit X-HELO: esa2.hgst.iphmx.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1569371749; x=1600907749; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=X8U+KzLsaYNs2Fape8ayrygCKD+yKgHG9CjJCjmm+gQ=; b=Gld8O8/uijH1bjduqaDlZZ/kLWJF6o4VJ2yyL/yRquJkabnENokcpHQG JV4SdkI9e1fFTfradO4xX5K5sughVoUOA9HE8DUShBtCWMJVh3M+LlXxv 17CLB7Fp9MJRiLz8D05L4ZKSZU1FGUPu77C8fCNcUtSdrby+KQQUElxSS AOl4bzHIuheocNc45G3ty25ScOXj50JEBquk9sTw0s7+k9JjUNAbPN/FJ Kt13OznyVKJREIPdxLHAQNToWOlNIMbk72akeCqu1kpIwePl5iS05tCDN vglmd72XiXc1mDGTw1dYl5wg0BXNmXBOBXASNc54NVq5C0xXj2rSFaE1/ g==; IronPort-SDR: 5fm65oOHK3UXr1QfRQ4czSZyJMd7j4Butl6oygjSRVNO1hyM76uhLjZEDnDUIBkQ11ccU/SXAE i4geajWOZPKnNjEs6mP0MNYd0wnP0/rmsoar1PJmeRdmlNCUdP7YbDqExIUJlHo2OEiGfQL05X NuWIUXjhgd84GqdxSHOLSrR8zkXKwFxnK2ZDXv2JEYNHCs65jNb/LO96vkalhaACFGQhFa3E4n COZf2MRQ9SKZd/hQlYFoQzsBXO8+f+tsrbphSnGN4f8vwsmUS+kOfojMeLM1hiNpNIiVg6le97 Dt4= IronPort-SDR: QrL4/VfM+cdt2iMXNxwWuv1t3ZWVpxVJ3K3zD7SKLhv+ROFBXW1P8kxdfjpN6pcs/SeHfghiK+ f1YXq7ZhZzTm6k0PiwHznj4cUn4pA1t9p9U+fu4Jqu8yMz+XoFpuJ+KQz1cp3Y06upkhJnZsIS LoXkQMEBJHF09G4paVG31r6jtWqjZj+WNpxnz3MJj0mk7nuwss5mVdRrhbVdsSwLp7v33CLto1 poyeS9e/Kee9SCRVsT8EKgkKxb2X1rgu3R1/+LnJiARGSjrUyVAZP0QTCvUBL6mFZvG2QA4qid vpJWgEcFFplYguxAKlTSSWJo IronPort-SDR: 3MZV3hqslYmK7/XKXAzUY1CKZ02Bpz5a+QXH9FclMZJwjpofYFeJCE0EkiPHHQTC7xxw1f+bri ih3uv23MV3Te7KuMfGhle5+fC9PKoBjrhQx1ZA7mkbQJHpIWYF6id4J+ZD+91Wv4xuxIgZHEWj 4tyQ9ENQDzusufaW4zGpDRasKF1Xkw/2FWWZo53gf44+FauwOD4tpIQmzZ+4Uh3mmkgmpl1jGr kL955nLlKJuRM+1DdDUD080ACJUqdVfts84fVgdlQGsM82ujHoYkuwPrmaxY3FdD1aqbYrpHoe W6k= WDCIronportException: Internal From: Alistair Francis To: libc-alpha@sourceware.org Cc: alistair23@gmail.com, Alistair Francis Subject: [PATCH v2 1/2] sysdeps/stat: Handle 64-bit ino_t types on 32-bit hosts Date: Tue, 24 Sep 2019 17:31:13 -0700 Message-Id: <20190925003114.21546-1-alistair.francis@wdc.com> MIME-Version: 1.0 On a 32-bit platform with a 64-bit ino_t type (__INO_T_MATCHES_INO64_T defined) we want to update the stat struct to remove the padding as it isn't required. As we don't have the padding we also need to update the overflow checker to not access the undefined members. 2019-09-16 Alistair Francis * sysdeps/unix/sysv/linux/generic/bits/stat.h: Handle 64-bit ino_t types on 32-bit hosts. * sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h: Likewise. --- This change was tested by running user space tests for RV32 and RV64. v2: - Change to if defined instead of if == 1 sysdeps/unix/sysv/linux/generic/bits/stat.h | 5 ++++- sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/generic/bits/stat.h b/sysdeps/unix/sysv/linux/generic/bits/stat.h index 1565f3f8248..e580071d26c 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/stat.h +++ b/sysdeps/unix/sysv/linux/generic/bits/stat.h @@ -40,7 +40,10 @@ /* Versions of the `xmknod' interface. */ #define _MKNOD_VER_LINUX 0 -#if defined __USE_FILE_OFFSET64 +#if defined (__USE_FILE_OFFSET64) || defined (__INO_T_MATCHES_INO64_T) +# if defined (__INO_T_MATCHES_INO64_T) && !defined (__OFF_T_MATCHES_OFF64_T) +# error "ino_t and off_t must both be the same type" +# endif # define __field64(type, type64, name) type64 name #elif __WORDSIZE == 64 # define __field64(type, type64, name) type name diff --git a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h index 45efcd8fd34..3c21da501b2 100644 --- a/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h +++ b/sysdeps/unix/sysv/linux/generic/wordsize-32/overflow.h @@ -36,12 +36,16 @@ static inline off_t lseek_overflow (loff_t res) static inline int stat_overflow (struct stat *buf) { +#if defined (__INO_T_MATCHES_INO64_T) + return 0; +#else if (buf->__st_ino_pad == 0 && buf->__st_size_pad == 0 && buf->__st_blocks_pad == 0) return 0; __set_errno (EOVERFLOW); return -1; +#endif } /* Note that f_files and f_ffree may validly be a sign-extended -1. */