From patchwork Thu Jan 14 08:13:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stafford Horne X-Patchwork-Id: 41717 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 54E9E3857C48; Thu, 14 Jan 2021 08:14:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 54E9E3857C48 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1610612040; bh=m18M0b+1sS8mXGwmLqzrFN+bNxNgnpdPfWcy481hook=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=lpOmPmipahysbgLxShQK+2inKI3dDYHu69EiGoA9b/R9YRLljG858BQCnLLxJlE0q iNXDJ53SgtVWphz4Q8LWkCKEFP49XyEg0lyCdjQNVn8WXaFXYYYS+vqfOcGYyOag16 U6ugHenwp4ajAN/O4XlD7eZjpmwoYOafJw+2+JQ4= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-pl1-x633.google.com (mail-pl1-x633.google.com [IPv6:2607:f8b0:4864:20::633]) by sourceware.org (Postfix) with ESMTPS id DADF7385800E for ; Thu, 14 Jan 2021 08:13:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org DADF7385800E Received: by mail-pl1-x633.google.com with SMTP id g3so2536499plp.2 for ; Thu, 14 Jan 2021 00:13:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=m18M0b+1sS8mXGwmLqzrFN+bNxNgnpdPfWcy481hook=; b=cLaml7InTaGWBs9YARfWvJx+ptEKOkhTK4Ta1LPWOfYnOOQ6uLF0ZrjNtrAV7DByyd 5sAyfT6iN/F/BxTSH7Aq0MQRMzvGXk6cHBkYhZIasRnriK+xHR6yh1UOA66jWP2IffRd YGPO76cHiqy2oLzVlZrwb/qeeINSuyj2Ot0ZnIQ+DKt6yrgpgczO3qrpUhta8jlkBG1R ZW7RsT5A8iHVsFnLmqqboY03eTi7Ia4fGlkEA50D+6hOi0wT1VvWBZ0uZ1rtFpvJTAwQ 2FwvP2svYTFOlQrNNX8rzPupeyTVzhro/rX5nlrWC3kirBbiEjohDMQ82Yb/R19Chgt1 4kmA== X-Gm-Message-State: AOAM530FD6zo9ENukrCb3oncwOLSkep+jrnCU7dmUdPIM+adkmKHVvK5 K+NmY1r8uaPkTpT5pBtBs7ARWKBo070= X-Google-Smtp-Source: ABdhPJxgFszvnTnmbNySY5kFTy3652CS2pRMYYiUuNGPGZBQZM0kcTlUgQ2t4s/vYGIW05TyKjIjkA== X-Received: by 2002:a17:90a:8508:: with SMTP id l8mr3652536pjn.131.1610612035602; Thu, 14 Jan 2021 00:13:55 -0800 (PST) Received: from localhost (g238.115-65-210.ppp.wakwak.ne.jp. [115.65.210.238]) by smtp.gmail.com with ESMTPSA id h11sm4526553pjg.46.2021.01.14.00.13.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jan 2021 00:13:54 -0800 (PST) To: GLIBC patches Subject: [PATCH] linux: Use stat_overflow to check overflow in fstatat Date: Thu, 14 Jan 2021 17:13:49 +0900 Message-Id: <20210114081349.3179376-1-shorne@gmail.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Stafford Horne via Libc-alpha From: Stafford Horne Reply-To: Stafford Horne Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" After a recent rebase of the OpenRISC port I am working on the build started to fail with: ../sysdeps/unix/sysv/linux/fstatat.c: In function '__fstatat': ../sysdeps/unix/sysv/linux/fstatat.c:35:21: error: 'struct stat' has no member named '__st_ino_pad' 35 | if (r == 0 && (buf->__st_ino_pad != 0 | ^~ ../sysdeps/unix/sysv/linux/fstatat.c:36:24: error: 'struct stat' has no member named '__st_size_pad' 36 | || buf->__st_size_pad != 0 | ^~ ../sysdeps/unix/sysv/linux/fstatat.c:37:24: error: 'struct stat' has no member named '__st_blocks_pad' 37 | || buf->__st_blocks_pad != 0)) | ^~ This seems to be caused by 6073bae64c ("linux: Disentangle fstatat from fxstatat"). Which introduced the checks for overflow using the stat->__st_*_pad fields. These do not exist on all architectures, I cannot even find any that do exist by grepping code. The fix is to use the stat_overflow function which only runs the overflow checks if the pad fields are available. Note, This is not xstat but I use the xstatover.h header. I hope that is not an issue. Cc: Adhemerval Zanella --- sysdeps/unix/sysv/linux/fstatat.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sysdeps/unix/sysv/linux/fstatat.c b/sysdeps/unix/sysv/linux/fstatat.c index 59efff615f..5bff931183 100644 --- a/sysdeps/unix/sysv/linux/fstatat.c +++ b/sysdeps/unix/sysv/linux/fstatat.c @@ -22,6 +22,7 @@ #if !XSTAT_IS_XSTAT64 # include +# include int __fstatat (int fd, const char *file, struct stat *buf, int flag) @@ -32,10 +33,7 @@ __fstatat (int fd, const char *file, struct stat *buf, int flag) /* New kABIs which uses generic pre 64-bit time Linux ABI, e.g. csky, nios2 */ r = INTERNAL_SYSCALL_CALL (fstatat64, fd, file, buf, flag); - if (r == 0 && (buf->__st_ino_pad != 0 - || buf->__st_size_pad != 0 - || buf->__st_blocks_pad != 0)) - return INLINE_SYSCALL_ERROR_RETURN_VALUE (EOVERFLOW); + return r ?: stat_overflow (buf); # else # ifdef __NR_fstatat64 /* Old KABIs with old non-LFS support, e.g. arm, i386, hppa, m68k, mips32,