From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 31 Jan 2025 11:15:49 +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 1tdo3w-006hsA-0l for lore@lore.pengutronix.de; Fri, 31 Jan 2025 11:15:49 +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 1tdo3w-0004ZH-My; Fri, 31 Jan 2025 11:15:48 +0100 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1tdo3m-0004Z8-DT for ptxdist@pengutronix.de; Fri, 31 Jan 2025 11:15:39 +0100 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-38633b5dbcfso1784905f8f.2 for ; Fri, 31 Jan 2025 02:15:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20230601; t=1738318537; x=1738923337; darn=pengutronix.de; h=mime-version:message-id:subject:to:date:from:from:to:cc:subject :date:message-id:reply-to; bh=UP5NjCDnoCMlAhlzwGjuUmrNVs1m2u9hgtjvC8Eq0r0=; b=ET2HPL246KB48DM3sUKDzaYJKrR4adD+y1oOrF0EtSAr86zjnXuMNJbiquWCq7NyYn 1D2H6FpRQFndL+uLQa+rcOoH2JAHEmeTxSK0y293EqxJ48cgjWln5zXTWX3sqKSezA6y G2R+HkVywgTJY02teKIFZFP8I5Bx+gYD0nheAB8jKMWaMnuD7hTwvKp2J68AcR5wSxIk mVaKzweKb1uHwl87pM+fStt2dXeDgg+8Nwi5TjXloKWk5ay9DlSZlHq4g4IXzJ0nqjfd yfr1y30vyrzUvJp7B7w6bp/6fLl/MlfCOv+AVhv8RggdirrCllWZKBlWonD3MUufbWLZ Py3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738318537; x=1738923337; h=mime-version:message-id:subject:to:date:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=UP5NjCDnoCMlAhlzwGjuUmrNVs1m2u9hgtjvC8Eq0r0=; b=eJ3p+vrzpsnE6CAiPlFwEd1dKvI+A1feF+IxwKc8dyPPx/Q7YWcXHwjWfitXt9m1ap 148UMBX7XQ+lbI6BlasP2fDiCK7Or1WQIpRh+HccIb6zfRBtE7S0LXE0mYctNo4Tm7rS W+o8UkGk5NwbEScIzcqYeSwd4MEd8MMcu4yyJGTq4bLfON5EOt0mHk9MXVBWCaEszwSL QlwV7dsWgpDKfivaqs3Cbt8cntWifUD8v6Gvt6K77FeCZH2xn5VZl9B/pLgZNg5QZ3rx HKMlmT1DsFCOMkaNEC8MRdzB2cfNVNJAQxmlrtpuJBj+BtIzYsdNZicF+vpK+P0jBmYX GXNg== X-Gm-Message-State: AOJu0Yz2alZyFs0DoyDcPRXdugWf43TaLJ03IgOPh9QXH/NMhXqcNFCI Q+/tzQD+GR9FwNaeFI6RELIKNUHyluM+JLWnCl62FuJFL/Ms0raAEPIqmg== X-Gm-Gg: ASbGncv9YUYDKHBkh7eTNpL439qbjq0YoYu58/36feTeDQYcqA3IPMbr1Isp7NFL+pN CagN4aM5T0utv1EEmQxvbjijiRV1PTZkKWGGTYrUp5Y31ChfcTUoUpwkl2nH/AXVqT5kJQ0Oe7U omkPWUdgxz+qyyUavHbFOL0exWjC1O8tWfFfrPNDbBHVU7pWBjI0HSLWRzjIKz9gYEm2kNIFMWa OkHZbH7LeEFimGGrfgldnrievNuQQE3BHwApLqryWDlh1mdHGbo9DNXjDp1vz/1RvGbRHXVzlGj DM2qdE4Jxw0evln6EHBYgVnU9LYjIIdXGE7sRxZuPQ7dVyfyKl0KeOkFfqZPwNlTr1XrvQO2 X-Google-Smtp-Source: AGHT+IGMBA81byGmsaTvEokZdfU0iSMt1nbNM40Naaxhiy9MmpZUPxpw8ZE6QEh4zXqqzh/G8gDCVQ== X-Received: by 2002:adf:f40a:0:b0:38a:1ba4:d066 with SMTP id ffacd0b85a97d-38c5196a2admr8755531f8f.27.1738318536723; Fri, 31 Jan 2025 02:15:36 -0800 (PST) Received: from RR-Laptop (p200300c00f116c0003b3e0170b947910.dip0.t-ipconnect.de. [2003:c0:f11:6c00:3b3:e017:b94:7910]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-38c5c1cfa2fsm4326391f8f.91.2025.01.31.02.15.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 02:15:36 -0800 (PST) From: ruggero X-Google-Original-From: ruggero Date: Fri, 31 Jan 2025 11:15:35 +0100 To: ptxdist@pengutronix.de Message-ID: <20250131111535.07f27b37@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_/B8=ZY_iFs/6_+6eB8MAqhkF" 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_/B8=ZY_iFs/6_+6eB8MAqhkF 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_/B8=ZY_iFs/6_+6eB8MAqhkF 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_/B8=ZY_iFs/6_+6eB8MAqhkF 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_/B8=ZY_iFs/6_+6eB8MAqhkF 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_/B8=ZY_iFs/6_+6eB8MAqhkF 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_/B8=ZY_iFs/6_+6eB8MAqhkF 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_/B8=ZY_iFs/6_+6eB8MAqhkF 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_/B8=ZY_iFs/6_+6eB8MAqhkF--