From patchwork Tue Sep 15 12:45:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yann Sionneau X-Patchwork-Id: 1364323 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=uclibc-ng.org (client-ip=89.238.66.15; helo=helium.openadk.org; envelope-from=devel-bounces@uclibc-ng.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=quarantine dis=none) header.from=kalray.eu Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=kalray.eu header.i=@kalray.eu header.a=rsa-sha256 header.s=32AE1B44-9502-11E5-BA35-3734643DEF29 header.b=ZP6NbTp7; dkim-atps=neutral Received: from helium.openadk.org (helium.openadk.org [89.238.66.15]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BrNK34wTFz9sTH for ; Tue, 15 Sep 2020 22:46:47 +1000 (AEST) Received: from helium.openadk.org (localhost [IPv6:::1]) by helium.openadk.org (Postfix) with ESMTP id C5B0E102A4; Tue, 15 Sep 2020 14:46:42 +0200 (CEST) X-Original-To: devel@uclibc-ng.org Delivered-To: devel@helium.openadk.org Received: from mib.mailinblack.com (mib.mailinblack.com [185.7.73.95]) by helium.openadk.org (Postfix) with ESMTPS id 74B4A10141 for ; Tue, 15 Sep 2020 14:46:39 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mib.mailinblack.com (Postfix) with ESMTP id DB1DC333022 for ; Tue, 15 Sep 2020 12:46:38 +0000 (UTC) Received: from mib.mailinblack.com (localhost [127.0.0.1]) by mib.mailinblack.com with SMTP (Mib Daemon ) id KF3YA7I1 for devel@uclibc-ng.org; Tue, 15 Sep 2020 12:46:38 +0000 (UTC) Received: from zimbra2.kalray.eu (zimbra2.kalray.eu [92.103.151.219]) by mib.mailinblack.com (Postfix) with ESMTPS id 97396333014 for ; Tue, 15 Sep 2020 12:46:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id 5E88B27E0C50 for ; Tue, 15 Sep 2020 14:46:38 +0200 (CEST) Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id TC2EBoaqURBO; Tue, 15 Sep 2020 14:46:38 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by zimbra2.kalray.eu (Postfix) with ESMTP id E005927E0C4F; Tue, 15 Sep 2020 14:46:37 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.10.3 zimbra2.kalray.eu E005927E0C4F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kalray.eu; s=32AE1B44-9502-11E5-BA35-3734643DEF29; t=1600173997; bh=T1Khm1LRobYkt17rtCMt7nDD5PZ12Dn5M08uOJSLRAU=; h=From:To:Date:Message-Id; b=ZP6NbTp7vIOBknOkCPnkE4el+qZbzuHVdFedrrYkx8owr3VywGgiUCxjlkEPrgJJ9 K1SDPlt3IA1Xjal0IyzaKCRO91BvViD71lB/MrrKL7eAex6hyLYgMIJQt1Q5IdrPiP e5G7SiO7OsxQHHpdwbUKdHf9NBOKjVVFzt+GClWQ= X-Virus-Scanned: amavisd-new at zimbra2.kalray.eu Received: from zimbra2.kalray.eu ([127.0.0.1]) by localhost (zimbra2.kalray.eu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 0mS0CAv7AJ7t; Tue, 15 Sep 2020 14:46:37 +0200 (CEST) Received: from junon.lin.mbt.kalray.eu (unknown [192.168.37.161]) by zimbra2.kalray.eu (Postfix) with ESMTPSA id CED8327E0C42; Tue, 15 Sep 2020 14:46:37 +0200 (CEST) From: Yann Sionneau To: devel@uclibc-ng.org Date: Tue, 15 Sep 2020 14:45:24 +0200 Message-Id: <20200915124524.5346-2-ysionneau@kalray.eu> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200915124524.5346-1-ysionneau@kalray.eu> References: <20200915124524.5346-1-ysionneau@kalray.eu> Subject: [uclibc-ng-devel] [PATCH 1/1] Fix memory corruption due to struct stat field X-BeenThere: devel@uclibc-ng.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: uClibc-ng Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: devel-bounces@uclibc-ng.org Sender: "devel" Kernel stat/stat64 structure and uClibc-ng ones were not in sync regarding the timespec fields. Kernel had them but uClibc did not expose it in some cases. Man page says that stat struct should have timespec fields if: * _POSIX_C_SOURCE is defined to 200809L or greater or * _XOPEN_SOURCE is defined to 700 or greater or * _BSD_SOURCE is defined or * _SVID_SOURCE is defined In the case of buildroot vim build, neither _BSD_SOURCE nor _SVID_SOURCE were defined. Only _POSIX_C_SOURCE and _XOPEN_SOURCE were defined. uClibc-ng header only checked for _BSD_SOURCE and _SVID_SOURCE via __USE_MISC. This patch adds a check to __USE_XOPEN2K8 which is defined if _POSIX_C_SOURCE >= 200809L or _XOPEN_SOURCE >= 700 This for instance fixes a crash at startup of vim (not the busybox one) on aarch64 and all other arch where in kernel STAT_HAVE_NSEC is set and where stat.h in uClibc-ng comes from libc/sysdeps/linux/common-generic/bits Signed-off-by: Yann Sionneau --- libc/sysdeps/linux/common-generic/bits/stat.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/sysdeps/linux/common-generic/bits/stat.h b/libc/sysdeps/linux/common-generic/bits/stat.h index 2f72d357a..045c0f486 100644 --- a/libc/sysdeps/linux/common-generic/bits/stat.h +++ b/libc/sysdeps/linux/common-generic/bits/stat.h @@ -47,7 +47,7 @@ struct stat int st_blksize; /* Optimal block size for I/O. */ int __pad2; long long st_blocks; /* Number 512-byte blocks allocated */ -#ifdef __USE_MISC +#if defined(__USE_MISC) || defined(__USE_XOPEN2K8) /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the @@ -88,7 +88,7 @@ struct stat64 int st_blksize; /* Optimal block size for I/O. */ int __pad4; long long st_blocks; /* Number 512-byte blocks allocated */ -# ifdef __USE_MISC +# if defined(__USE_MISC) || defined(__USE_XOPEN2K8) /* Nanosecond resolution timestamps are stored in a format equivalent to 'struct timespec'. This is the type used whenever possible but the Unix namespace rules do not allow the