From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 31 Jan 2025 13:06:27 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tdpn0-006jjh-1N for lore@lore.pengutronix.de; Fri, 31 Jan 2025 13:06:27 +0100 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1tdpn0-0007ad-NR; Fri, 31 Jan 2025 13:06:26 +0100 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1tdpmj-0007aU-Bm for ptxdist@pengutronix.de; Fri, 31 Jan 2025 13:06:10 +0100 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-436345cc17bso14399985e9.0 for ; Fri, 31 Jan 2025 04:06:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1738325168; x=1738929968; darn=pengutronix.de; h=mime-version:message-id:subject:to:date:from:from:to:cc:subject :date:message-id:reply-to; bh=/GQ0tpTsJbHmIB2Q+PLyVbvT0zYP66DRi9Equgmv3kw=; b=VZBLqTQRmrHMkEMhL8Zul1kqvxz6qO+lAUQ9xrnFsJKITR98sqjKOXUxhbsHLJgeCM /54bC91+Ort/pqY1SJpBxV3BwN2Sb2SA4JRz4VN6oa2U4JwnzzfyqXPViNNCyBjoAJov D2okmOK7XZU5mRf7pK6fJ7yqSdf8zmgrvuBna5VZgnOIpBVC1nQjKjbSzt9s0GG/G+It rOSvcB7EnvP8V5wDVcPSMUrKntswQPF4Y9wFMdWyh/jnSReSQDGTOvSzGZMvW0fYW1Oq rcYFZbaNNmf1p+7xbKZI0bzSp4wIX/RmAl/YL3XMsAGcsPlb2q6jNZ1cVcuhzcuctNHx 4hTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738325168; x=1738929968; h=mime-version:message-id:subject:to:date:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=/GQ0tpTsJbHmIB2Q+PLyVbvT0zYP66DRi9Equgmv3kw=; b=UWIWIs7BYgJ+i75uKq1KEseYMgVLnQ517CCvpHwhQ2hAwUdDbcXgL/0lpOKN7vsBVY /x9HStS4Tg0hMkVnYGK8da3K73J73a2iSfEiEOviOVReLtvOfhCHDCFNi1TX7OQ3N0oo b1JrwnCJ87qSRzFzlwHlnn9WGGTVnmnRiSzMy4lgKnu2FRC7Cu1KEAopj+ixLKr2r4gP 3Aj9IjFM8hf+3NDQoAon+dXaV/BPZQd1iCXoNOXn1R1wlA2q0mgZ6ASXn/atqelnQaL+ y6BYMJZHMJDXSyEuzQMEfRpbTKPmXHKYzHx6lodHvfPCs8PdOD/sX0/9SNBPnQarJNFB X6Bw== X-Gm-Message-State: AOJu0YwDzgFYjoTn3DT/YZM2rOzjMj+gettdyuuab9rG8Jxw2z2blvES C7Q5Qlt8bFYEVWRwJG9FhUGI0z6OIDNmaDRU7EiLv7IrhwqHfpoVOkZ+zA== X-Gm-Gg: ASbGncvip2gUmVaI46bjVleh9Mj9DQxp3Z/73/Dm/NbRvVLu+pGac6b2dvGDfrgqJW/ rQ+FUKBL6/ZAjoLKED5wn932sZUKkl0tQJoguI+6a+kZhBBkk4Hxw54PHhqzMi7bcsF3ZuiP4HM aEYTNXjPHeQRtB5Z+4L7MxvmUPMrAh4iUlHUgTH2xfVcXnzP3wsFwqJUufq38XOogzFMT77Pbbe z/Pf/Nc4GvrYEEQ5IM+qBKlP/v0T8hvKJ1NAEuv07dXH/NpYX4F/9wUmtPF7lEVY0ovkT/a1/s3 MdoFu7Y8PAotZI7lSy4qJdtRUxzbIPRGmmR+L4k80ffl0m6C2olQfrGuIGJByUIKUt3297cq X-Google-Smtp-Source: AGHT+IF6OU/DZvH0rE9EpYC0wYim0Dmw9mInCe7w0dTSE5LD8hlBonydnQX1jxEmMcdllen8XHn5Dw== X-Received: by 2002:a05:600c:8712:b0:434:a1e7:27b0 with SMTP id 5b1f17b1804b1-438dc3c29f2mr128232975e9.11.1738325168028; Fri, 31 Jan 2025 04:06:08 -0800 (PST) Received: from RR-Laptop (p200300c00f116c0079d9805e1f57c226.dip0.t-ipconnect.de. [2003:c0:f11:6c00:79d9:805e:1f57:c226]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438dcc263f0sm88325265e9.9.2025.01.31.04.06.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 04:06:07 -0800 (PST) From: ruggero rossi X-Google-Original-From: ruggero rossi Date: Fri, 31 Jan 2025 13:06:05 +0100 To: ptxdist@pengutronix.de Message-ID: <20250131130605.05ea0372@RR-Laptop> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MP_/DborRppnHnaTz+XW2D0owPP" X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=4.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Subject: [ptxdist] Bug in BusyBox 1.37.0 - NTPD Module X-BeenThere: ptxdist@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: PTXdist Development Mailing List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: ptxdist@pengutronix.de Sender: "ptxdist" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: ptxdist-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false --MP_/DborRppnHnaTz+XW2D0owPP Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Content-Disposition: inline HHello everyone, My BSP still uses an older version of Linux and libc with a 32-bit time_t. While migrating to ptxdist-2025.01.0, I encountered an unexpected crash in the ntpd service. Specifically, when the BSP acts as an ntpd server, the crash occurs on the client side. After investigating the issue, I believe I have identified a bug. On my system, time_t is effectively an int32_t. In the function that converts a double to the NTP time format, I found the following code: double d; uint32_t intl; intl = (uint32_t)(time_t)d; Here, the integer part of d represents the number of seconds since 1900-01-01T00:00:00.0, which exceeds 31 bits. Casting d to time_t in the server truncates the value to 0x7fffffff, leading to a crash in the client. The solution is to avoid the cast to time_t when sizeof(time_t) == 4. I have attached a proposed patch for this issue. If someone with more authority in the project could report this upstream, that would be appreciated. Best regards, Ruggero --MP_/DborRppnHnaTz+XW2D0owPP Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0002-meson-dont-build-blkzone-if-blkzoned.h-is-not-available.patch Some versions of Linux don't provide linux/blkzoned.h. In this case, attempting to build blkzone produces an error. Suppress building of blkzone. Index: util-linux-2.39.2/meson.build =================================================================== --- util-linux-2.39.2.orig/meson.build +++ util-linux-2.39.2/meson.build @@ -1477,16 +1477,19 @@ exes += exe manadocs += ['sys-utils/blkdiscard.8.adoc'] bashcompletions += ['blkdiscard'] -exe = executable( - 'blkzone', - blkzone_sources, - include_directories : includes, - link_with : [lib_common], - install_dir : sbindir, - install : true) -exes += exe -manadocs += ['sys-utils/blkzone.8.adoc'] -bashcompletions += ['blkzone'] +have = cc.has_header('linux/blkzoned.h') +if have + exe = executable( + 'blkzone', + blkzone_sources, + include_directories : includes, + link_with : [lib_common], + install_dir : sbindir, + install : true) + exes += exe + manadocs += ['sys-utils/blkzone.8.adoc'] + bashcompletions += ['blkzone'] +endif exe = executable( 'blkpr', --MP_/DborRppnHnaTz+XW2D0owPP Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0003-meson-dont-build-blkpr-if-pr.h-is-not-available.patch Some versions of Linux don't provide linux/pr.h. In this case, attempting to build blkpr produces an error. Suppress building of blkpr. Index: util-linux-2.39.2/meson.build =================================================================== --- util-linux-2.39.2.orig/meson.build +++ util-linux-2.39.2/meson.build @@ -1491,15 +1491,18 @@ if have bashcompletions += ['blkzone'] endif -exe = executable( - 'blkpr', - blkpr_sources, - include_directories : includes, - link_with : [lib_common], - install_dir : sbindir, - install : true) -exes += exe -manadocs += ['sys-utils/blkpr.8.adoc'] +have = cc.has_header('linux/pr.h') +if have + exe = executable( + 'blkpr', + blkpr_sources, + include_directories : includes, + link_with : [lib_common], + install_dir : sbindir, + install : true) + exes += exe + manadocs += ['sys-utils/blkpr.8.adoc'] +endif exe = executable( 'ldattach', --MP_/DborRppnHnaTz+XW2D0owPP Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0004-meson-dont-build-lsfd-if-kcmp.h-is-not-available.patch Some versions of Linux don't provide linux/kcmp.h. In this case, attempting to build lsfd produces an error. Suppress building of lsfd. Index: util-linux-2.39.2/meson.build =================================================================== --- util-linux-2.39.2.orig/meson.build +++ util-linux-2.39.2/meson.build @@ -2595,17 +2595,20 @@ if not is_disabler(exe) bashcompletions += ['lsblk'] endif -exe = executable( - 'lsfd', - lsfd_sources, - include_directories : includes, - link_with : [lib_common, - lib_smartcols], - install_dir : usrbin_exec_dir, - install : true) -if not is_disabler(exe) - exes += exe - manadocs += ['misc-utils/lsfd.1.adoc'] +have = cc.has_header('linux/kcmp.h') +if have + exe = executable( + 'lsfd', + lsfd_sources, + include_directories : includes, + link_with : [lib_common, + lib_smartcols], + install_dir : usrbin_exec_dir, + install : true) + if not is_disabler(exe) + exes += exe + manadocs += ['misc-utils/lsfd.1.adoc'] + endif endif exe = executable( --MP_/DborRppnHnaTz+XW2D0owPP Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0005-meson-dont-build-mkfds-if-SIOCGSKNS-is-not-available.patch Some old version of Linux don't provide the SIOCGSKNS ioctl in linux/sockios.h. In this case, attempting to build test_mkfds produces an error. Suppress building of test_mkfds. Index: util-linux-2.39.2/meson.build =================================================================== --- util-linux-2.39.2.orig/meson.build +++ util-linux-2.39.2/meson.build @@ -3288,11 +3288,14 @@ exe = executable( exes += exe if LINUX - exe = executable( - 'test_mkfds', - 'tests/helpers/test_mkfds.c', - include_directories : includes) - exes += exe + have = cc.has_header_symbol('linux/sockios.h', 'SIOCGSKNS') + if have + exe = executable( + 'test_mkfds', + 'tests/helpers/test_mkfds.c', + include_directories : includes) + exes += exe + endif endif exe = executable( --MP_/DborRppnHnaTz+XW2D0owPP Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=util-linux.make.patch --- /usr/local/lib/ptxdist-2023.11.0/rules/util-linux.make 2023-10-30 11:15:25.000000000 +0100 +++ util-linux.make 2024-01-07 18:24:56.336248170 +0100 @@ -127,7 +127,7 @@ -Dlibpcre2-posix=disabled \ -Dlibuser=disabled \ -Dlibutempter=disabled \ - -Dlibutil=disabled \ + -Dlibutil=enabled \ -Dmagic=disabled \ -Dncurses=$(call ptx/endis, UTIL_LINUX_USES_NCURSES)d \ -Dncursesw=$(call ptx/endis, PTXCONF_UTIL_LINUX_USES_NCURSESW)d \ --MP_/DborRppnHnaTz+XW2D0owPP Content-Type: text/x-patch Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=0300-fix-ntpd-for-32-bit-time_t.patch Index: busybox-1.37.0/networking/ntpd.c =================================================================== --- busybox-1.37.0.orig/networking/ntpd.c +++ busybox-1.37.0/networking/ntpd.c @@ -583,8 +583,13 @@ d_to_lfp(l_fixedpt_t *lfp, double d) { uint32_t intl; uint32_t frac; - intl = (uint32_t)(time_t)d; - frac = (uint32_t)((d - (time_t)d) * 0xffffffff); + if(sizeof(time_t) == 4){ + intl = (uint32_t)d; + frac = (uint32_t)((d - intl) * 0xffffffff); + }else{ + intl = (uint32_t)(time_t)d; + frac = (uint32_t)((d - (time_t)d) * 0xffffffff); + } lfp->int_partl = htonl(intl); lfp->fractionl = htonl(frac); } --MP_/DborRppnHnaTz+XW2D0owPP--