Compare commits

...

10 Commits

Author SHA1 Message Date
openeuler-ci-bot
98a08ae8b0
!84 ntpd abort if fail to drop root
From: @chengyechun 
Reviewed-by: @robertxw 
Signed-off-by: @robertxw
2024-01-23 09:36:47 +00:00
chengyechun
9b7f1fb05e ntpd abort if fail to drop root 2024-01-23 01:11:00 +00:00
openeuler-ci-bot
cc98bbb71d
!79 update ntpd.service
From: @chengyechun 
Reviewed-by: @robertxw 
Signed-off-by: @robertxw
2023-12-14 02:11:32 +00:00
chengyechun
5e989dc92c add restart in ntpd.service 2023-12-11 19:16:45 +08:00
openeuler-ci-bot
b8f396ef22
!72 update to ntp-4.2.8p17
From: @chengyechun 
Reviewed-by: @kircher 
Signed-off-by: @kircher
2023-07-24 11:40:28 +00:00
chengyechun
941f64deec update to 4.2.8p17 2023-07-21 16:30:06 +08:00
openeuler-ci-bot
f6d32aeb3f
!62 backport some patches from upstream
From: @chengyechun 
Reviewed-by: @kircher 
Signed-off-by: @kircher
2023-06-21 08:47:27 +00:00
chengyechun
fb160829f1 sync patch from upstream 2023-06-21 14:52:46 +08:00
openeuler-ci-bot
de6163b984
!54 fix CVE-2023-26551,CVE-2023-26552,CVE-2023-26553,CVE-2023-26554,CVE-2023-26555
From: @chengyechun 
Reviewed-by: @kircher 
Signed-off-by: @kircher
2023-05-24 06:52:42 +00:00
chengyechun
0c1d93ac25 fix CVE-2023-26555 2023-05-24 10:07:09 +08:00
11 changed files with 237 additions and 267 deletions

View File

@ -1,31 +0,0 @@
From 082a504cfcc046c3d8adaae1164268bc94e5108a Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 31 Jul 2021 10:51:41 -0700
Subject: [PATCH] libntp: Do not use PTHREAD_STACK_MIN on glibc
In glibc 2.34+ PTHREAD_STACK_MIN is not a compile-time constant which
could mean different stack sizes at runtime on different architectures
and it also causes compile failure. Default glibc thread stack size
or 64Kb set by ntp should be good in glibc these days.
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
libntp/work_thread.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libntp/work_thread.c b/libntp/work_thread.c
index 03a5647..3ddd751 100644
--- a/libntp/work_thread.c
+++ b/libntp/work_thread.c
@@ -41,7 +41,7 @@
#ifndef THREAD_MINSTACKSIZE
# define THREAD_MINSTACKSIZE (64U * 1024)
#endif
-#ifndef __sun
+#if !defined(__sun) && !defined(__GLIBC__)
#if defined(PTHREAD_STACK_MIN) && THREAD_MINSTACKSIZE < PTHREAD_STACK_MIN
# undef THREAD_MINSTACKSIZE
# define THREAD_MINSTACKSIZE PTHREAD_STACK_MIN
--
2.32.0

View File

@ -1,47 +0,0 @@
From 562c0cc96b42afce4eeef8da8ac315f03e2e99df Mon Sep 17 00:00:00 2001
From: Miroslva Lichvar <mlichvar@redhat.com>
Date: Thu, 20 Apr 2023 08:27:41 PM GMT+0800
Subject: [PATCH] mstolfp:make sure the buffer has enough room for the input extra characters
Reference:https://build.opensuse.org/package/view_file/openSUSE:Factory/ntp/ntp-CVE-2023-26551.patch?expand=1
Conflict:NA
CVE-2023-26552, CVE-2023-26553 and CVE-2023-26554 are marked identical to CVE-2023-26551
https://github.com/spwpun/ntp-4.2.8p15-cves/issues/1#issuecomment-1507034339
---
libntp/mstolfp.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libntp/mstolfp.c b/libntp/mstolfp.c
index 3dfc4ef..a8defa2 100644
--- a/libntp/mstolfp.c
+++ b/libntp/mstolfp.c
@@ -14,7 +14,7 @@ mstolfp(
l_fp *lfp
)
{
- register const char *cp;
+ register const char *cp, *end;
register char *bp;
register const char *cpdec;
char buf[100];
@@ -42,6 +42,15 @@ mstolfp(
if (*cp != '.' && !isdigit((unsigned char)*cp))
return 0;
+ /*
+ * Make sure the buffer has enough room for the input string and the
+ * extra characters, in the worst case replacing "." with "0.000"
+ */
+ end = cp;
+ while (isdigit((unsigned char)*end) || *end == '.')
+ end++;
+ if (end - cp + 4 >= sizeof (buf) - (bp - buf))
+ return 0;
/*
* Search forward for the decimal point or the end of the string.
--
2.27.0

View File

@ -0,0 +1,37 @@
From 6f92672308e9ff2ff72f1d929b6887ab24787e42 Mon Sep 17 00:00:00 2001
From: Harlen Stenn <stenn@ntp.org>
Date: Tue, 20 Jun 2023 18:41:55 +0000
Subject: [PATCH] add NULL pointer check when ntpd deletes the last interface
Conflict:NA
Reference:https://bugs.ntp.org/attachment.cgi?id=1854&action=diff
---
include/ntp_lists.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/include/ntp_lists.h b/include/ntp_lists.h
index d741974..37befc0 100644
--- a/include/ntp_lists.h
+++ b/include/ntp_lists.h
@@ -181,7 +181,7 @@ do { \
#define UNLINK_EXPR_SLIST(punlinked, listhead, expr, nextlink, \
entrytype) \
-do { \
+if (NULL != (listhead)) { \
entrytype **ppentry; \
\
ppentry = &(listhead); \
@@ -202,6 +202,8 @@ do { \
} else { \
(punlinked) = NULL; \
} \
+} else do { \
+ (punlinked) = NULL; \
} while (FALSE)
#define UNLINK_SLIST(punlinked, listhead, ptounlink, nextlink, \
--
2.27.0

View File

@ -0,0 +1,162 @@
Conflict:NA
Reference:https://bugs.ntp.org/attachment.cgi?id=1880
diff -Nru a/ntpd/ntpd.c b/ntpd/ntpd.c
--- a/ntpd/ntpd.c 2024-01-22 05:23:37 +0000
+++ b/ntpd/ntpd.c 2024-01-22 05:23:37 +0000
@@ -204,10 +204,6 @@
int mdnstries = 5;
#endif /* HAVE_DNSREGISTRATION */
-#ifdef HAVE_LINUX_CAPABILITIES
-int have_caps; /* runtime check whether capabilities work */
-#endif /* HAVE_LINUX_CAPABILITIES */
-
#ifdef HAVE_DROPROOT
int droproot;
int root_dropped;
@@ -813,8 +809,8 @@
#ifndef SIM
int
ntpdmain(
- int argc,
- char *argv[]
+ int argc,
+ char * argv[]
)
{
l_fp now;
@@ -837,7 +833,7 @@
# ifdef NEED_PTHREAD_WARMUP
my_pthread_warmup();
# endif
-
+
# ifdef HAVE_UMASK
uv = umask(0);
if (uv)
@@ -861,9 +857,9 @@
# ifdef DEBUG
|| debug
# endif
- || HAVE_OPT(SAVECONFIGQUIT))
+ || HAVE_OPT(SAVECONFIGQUIT)) {
nofork = TRUE;
-
+ }
init_logging(progname, NLOG_SYNCMASK, TRUE);
/* honor -l/--logfile option to log to a file */
if (HAVE_OPT(LOGFILE)) {
@@ -931,32 +927,33 @@
}
# endif
-/*
- * Enable the Multi-Media Timer for Windows?
- */
+ /*
+ * Enable the Multi-Media Timer for Windows?
+ */
# ifdef SYS_WINNT
- if (HAVE_OPT( MODIFYMMTIMER ))
+ if (HAVE_OPT(MODIFYMMTIMER)) {
set_mm_timer(MM_TIMER_HIRES);
+ }
# endif
#ifdef HAVE_DNSREGISTRATION
-/*
- * Enable mDNS registrations?
- */
+ /*
+ * Enable mDNS registrations?
+ */
if (HAVE_OPT( MDNS )) {
mdnsreg = TRUE;
}
#endif /* HAVE_DNSREGISTRATION */
- if (HAVE_OPT( NOVIRTUALIPS ))
+ if (HAVE_OPT(NOVIRTUALIPS)) {
listen_to_virtual_ips = 0;
-
+ }
/*
* --interface, listen on specified interfaces
*/
if (HAVE_OPT( INTERFACE )) {
int ifacect = STACKCT_OPT( INTERFACE );
- const char** ifaces = STACKLST_OPT( INTERFACE );
+ const char ** ifaces = STACKLST_OPT( INTERFACE );
sockaddr_u addr;
while (ifacect-- > 0) {
@@ -969,9 +966,9 @@
}
}
- if (HAVE_OPT( NICE ))
+ if (HAVE_OPT(NICE)) {
priority_done = 0;
-
+ }
# ifdef HAVE_SCHED_SETSCHEDULER
if (HAVE_OPT( PRIORITY )) {
config_priority = OPT_VALUE_PRIORITY;
@@ -1036,7 +1033,7 @@
* on the base CPU than the other CPUs (for multiprocessor systems),
* so we must lock to the base CPU.
*/
- fd = open("/dev/at1", O_RDONLY);
+ fd = open("/dev/at1", O_RDONLY);
if (fd >= 0) {
zero = 0;
if (ioctl(fd, ACPU_LOCK, &zero) < 0)
@@ -1144,7 +1141,7 @@
# ifdef RLIMIT_MEMLOCK
&& -1 != DFLT_RLIMIT_MEMLOCK
# endif
- && 0 != mlockall(MCL_CURRENT|MCL_FUTURE))
+ && 0 != mlockall(MCL_CURRENT | MCL_FUTURE))
msyslog(LOG_ERR, "mlockall(): %m");
# else /* !HAVE_MLOCKALL follows */
# ifdef HAVE_PLOCK
@@ -1174,28 +1171,30 @@
initializing = FALSE;
# ifdef HAVE_LINUX_CAPABILITIES
- {
+ if (droproot) {
+ int have_caps;
+ cap_t caps;
+
/* Check that setting capabilities actually works; we might be
* run on a kernel with disabled capabilities. We must not
* drop privileges in this case.
*/
- cap_t caps;
caps = cap_from_text("cap_sys_time,cap_setuid,cap_setgid,cap_sys_chroot,cap_net_bind_service=pe");
- if ( ! caps) {
- msyslog( LOG_ERR, "cap_from_text() failed: %m" );
+ if (!caps) {
+ msyslog(LOG_ERR, "cap_from_text() failed: %m");
exit(-1);
}
have_caps = (cap_set_proc(caps) == 0);
cap_free(caps); /* caps not NULL here! */
+ if (!have_caps) {
+ msyslog(LOG_ERR, ("Fatal: unable to drop root privs: %m"));
+ exit(-1);
+ }
}
# endif /* HAVE_LINUX_CAPABILITIES */
# ifdef HAVE_DROPROOT
-# ifdef HAVE_LINUX_CAPABILITIES
- if (droproot && have_caps) {
-# else
if (droproot) {
-# endif /*HAVE_LINUX_CAPABILITIES*/
# ifdef NEED_EARLY_FORK
fork_nonchroot_worker();

View File

@ -1,5 +1,5 @@
--- ntp-4.2.6p5/lib/isc/unix/interfaceiter.c.orig 2018-10-15 15:16:00.414796346 +0800
+++ ntp-4.2.6p5/lib/isc/unix/interfaceiter.c 2018-10-15 15:16:26.605794341 +0800
--- a/libntp/lib/isc/unix/interfaceiter.c 2018-10-15 15:16:00.414796346 +0800
+++ a/libntp/lib/isc/unix/interfaceiter.c 2018-10-15 15:16:26.605794341 +0800
@@ -151,7 +151,7 @@ get_addr(unsigned int family, isc_netadd
#ifdef __linux

View File

@ -1,155 +0,0 @@
From bac29f25f063d3a2a87f2b824179df6fbd54334f Mon Sep 17 00:00:00 2001
From: renmingshuai <renmingshuai@huawei.com>
Date: Fri, 30 Jul 2021 22:26:26 +0800
Subject: [PATCH] Fix multiple defination with gcc 10
---
sntp/tests/run-crypto.c | 2 +-
sntp/tests/run-keyFile.c | 2 +-
sntp/tests/run-kodDatabase.c | 2 +-
sntp/tests/run-kodFile.c | 2 +-
sntp/tests/run-networking.c | 2 +-
sntp/tests/run-packetHandling.c | 2 +-
sntp/tests/run-packetProcessing.c | 2 +-
sntp/tests/run-t-log.c | 2 +-
sntp/tests/run-utilities.c | 2 +-
tests/libntp/test-libntp.h | 5 ++++-
10 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/sntp/tests/run-crypto.c b/sntp/tests/run-crypto.c
index a486f86..5d7d02e 100644
--- a/sntp/tests/run-crypto.c
+++ b/sntp/tests/run-crypto.c
@@ -57,7 +57,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/sntp/tests/run-keyFile.c b/sntp/tests/run-keyFile.c
index 5b25519..4321002 100644
--- a/sntp/tests/run-keyFile.c
+++ b/sntp/tests/run-keyFile.c
@@ -55,7 +55,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/sntp/tests/run-kodDatabase.c b/sntp/tests/run-kodDatabase.c
index 67b7fc2..b591a0b 100644
--- a/sntp/tests/run-kodDatabase.c
+++ b/sntp/tests/run-kodDatabase.c
@@ -58,7 +58,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/sntp/tests/run-kodFile.c b/sntp/tests/run-kodFile.c
index a3af218..96d0075 100644
--- a/sntp/tests/run-kodFile.c
+++ b/sntp/tests/run-kodFile.c
@@ -56,7 +56,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/sntp/tests/run-networking.c b/sntp/tests/run-networking.c
index 1c1364f..3e1b4cd 100644
--- a/sntp/tests/run-networking.c
+++ b/sntp/tests/run-networking.c
@@ -48,7 +48,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/sntp/tests/run-packetHandling.c b/sntp/tests/run-packetHandling.c
index 7790b20..c58380c 100644
--- a/sntp/tests/run-packetHandling.c
+++ b/sntp/tests/run-packetHandling.c
@@ -64,7 +64,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/sntp/tests/run-packetProcessing.c b/sntp/tests/run-packetProcessing.c
index c91a6d3..221c88c 100644
--- a/sntp/tests/run-packetProcessing.c
+++ b/sntp/tests/run-packetProcessing.c
@@ -68,7 +68,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/sntp/tests/run-t-log.c b/sntp/tests/run-t-log.c
index 268bf41..cd835bc 100644
--- a/sntp/tests/run-t-log.c
+++ b/sntp/tests/run-t-log.c
@@ -50,7 +50,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/sntp/tests/run-utilities.c b/sntp/tests/run-utilities.c
index f717882..98d9bf1 100644
--- a/sntp/tests/run-utilities.c
+++ b/sntp/tests/run-utilities.c
@@ -58,7 +58,7 @@ void resetTest(void)
setUp();
}
-char const *progname;
+extern char const *progname;
//=======MAIN=====
diff --git a/tests/libntp/test-libntp.h b/tests/libntp/test-libntp.h
index 93050b3..2f386f6 100644
--- a/tests/libntp/test-libntp.h
+++ b/tests/libntp/test-libntp.h
@@ -1,3 +1,5 @@
+#ifndef TEST_LIBNTP_H
+#define TEST_LIBNTP_H
#include "config.h"
#include "ntp_stdlib.h"
@@ -5,4 +7,5 @@
time_t timefunc(time_t *ptr);
void settime(int y, int m, int d, int H, int M, int S);
-time_t nowtime;
+extern time_t nowtime;
+#endif
--
1.8.3.1

View File

@ -1,25 +0,0 @@
From 0494312d943d70f45e45e8e41f659318e88c8e52 Mon Sep 17 00:00:00 2001
From: chengyechun <chengyechun1@huawei.com>
Date: Tue, 14 Mar 2023 15:16:47 +0800
Subject: [PATCH] modify DSA key generation parameters base on openssl3
---
util/ntp-keygen.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/util/ntp-keygen.c b/util/ntp-keygen.c
index eb2cb34..732c073 100644
--- a/util/ntp-keygen.c
+++ b/util/ntp-keygen.c
@@ -121,7 +121,7 @@
#define MD5SIZE 20 /* maximum key size */
#ifdef AUTOKEY
#define PLEN 512 /* default prime modulus size (bits) */
-#define ILEN 256 /* default identity modulus size (bits) */
+#define ILEN 512 /* default identity modulus size (bits) */
#define MVMAX 100 /* max MV parameters */
/*
--
2.27.0

Binary file not shown.

BIN
ntp-4.2.8p17.tar.gz Normal file

Binary file not shown.

View File

@ -1,8 +1,8 @@
%global _hardened_build 1
Name: ntp
Version: 4.2.8p15
Release: 9
Version: 4.2.8p17
Release: 3
Summary: A protocol designed to synchronize the clocks of computers over a network
License: MIT and BSD and BSD with advertising
URL: https://www.ntp.org/
@ -23,11 +23,9 @@ Source16: sntp.sysconfig
Patch1: ntp-ssl-libs.patch
Patch2: bugfix-fix-bind-port-in-debug-mode.patch
Patch3: bugfix-fix-ifindex-length.patch
Patch4: fix-multiple-defination-with-gcc-10.patch
Patch5: Do-not-use-PTHREAD_STACK_MIN-on-glibc.patch
Patch6: fix-MD5-manpage.patch
Patch7: modify-DSA-key-generation-parameters-base-on-openssl3.patch
Patch8: backport-CVE-2023-26551-CVE-2023-26552-CVE-2023-26553-CVE-2023-26554.patch
Patch4: fix-MD5-manpage.patch
Patch5: backport-add-NULL-pointer-check-when-ntpd-deletes-the-last-interface.patch
Patch6: backport-ntpd-abort-if-fail-to-drop-root.patch
BuildRequires: libcap-devel openssl-devel libedit-devel libevent-devel pps-tools-devel
BuildRequires: autogen autogen-libopts-devel systemd gcc perl-generators perl-HTML-Parser
@ -210,6 +208,36 @@ make check
%{_mandir}/man8/*.8*
%changelog
* Tue Jan 23 2024 chengyechun <chengyehcun1@huawei.com> - 4.2.8p17-3
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:linux-only change to abort if ntpd can not drop root
* Mon Dec 11 2023 chengyechun <chengyechun1@huawei.com> - 4.2.8p17-2
- Type:bugfix
- ID:NA
- SUG:NA
- DESC:add Restart in ntpd.service
* Fri Jul 21 2023 chengyechun <chengyechun1@huawei.com> - 4.2.8p17-1
- Type:enhancement
- ID:
- SUG:NA
- DESC:update to 4.2.8p17
* Wed Jun 21 2023 chengyechun <chengyechun1@huawei.com> - 4.2.8p15-11
- Type:bugfix
- ID:
- SUG:NA
- DESC:add NULL pointer check when ntpd deletes the last interface
* Wed May 24 2023 chengyechun <chengyechun1@huawei.com> - 4.2.8p15-10
- Type:CVE
- ID:CVE-2023-26551,CVE-2023-26552,CVE-2023-26553,CVE-2023-26554,CVE-2023-26555
- SUG:NA
- DESC:change the patch of CVE-2023-26551 and fix CVE-2023-26555
* Fri May 12 2023 chengyechun <chengyechun1@huawei.com> - 4.2.8p15-9
- Type:bugfix
- ID:NA

View File

@ -8,6 +8,7 @@ Type=forking
EnvironmentFile=-/etc/sysconfig/ntpd
ExecStart=/usr/sbin/ntpd -u ntp:ntp $OPTIONS
PrivateTmp=true
Restart=on-failure
[Install]
WantedBy=multi-user.target