public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/4] time: Use __nonnull to avoid null pointer
@ 2022-04-28 12:25 Xiaoming Ni
  2022-04-28 12:25 ` [PATCH 1/4] adjtimex/adjtimex64: " Xiaoming Ni
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Xiaoming Ni @ 2022-04-28 12:25 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer, adhemerval.zanella
  Cc: nixiaoming, wangle6, libc-alpha

Some external interface codes do not check whether the pointer parameter
 is null. If the parameter is null, the program crashes (BZ#27662).
Therefore, add a __nonull statement to the function declaration to avoid
 null pointers.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084

The __nonull declaration is added for the following interfaces:
	adjtimex()
	adjtimex64()
	ntp_gettime()
	ntp_gettime64()
	ntp_gettimex()
	ntp_gettimex64()
	ntp_adjtime()
	clock_settime()
	clock_settime64()
	clock_gettime()
	clock_gettime64()
	clock_adjtime()
	clock_adjtime64()

--
Xiaoming Ni (4):
  adjtimex/adjtimex64: Use __nonnull to avoid null pointer
  ntp_xxxtimex: Use __nonnull to avoid null pointer
  clock_adjtime: Use __nonnull to avoid null pointer
  clock_settime/clock_gettime: Use __nonnull to avoid null pointer

 include/time.h                              |  4 ++--
 sysdeps/unix/sysv/linux/bits/time.h         |  4 ++--
 sysdeps/unix/sysv/linux/include/sys/timex.h | 10 +++++-----
 sysdeps/unix/sysv/linux/sys/timex.h         | 16 ++++++++--------
 time/time.h                                 |  9 ++++++---
 5 files changed, 23 insertions(+), 20 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/4] adjtimex/adjtimex64: Use __nonnull to avoid null pointer
  2022-04-28 12:25 [PATCH 0/4] time: Use __nonnull to avoid null pointer Xiaoming Ni
@ 2022-04-28 12:25 ` Xiaoming Ni
  2022-05-04 10:56   ` Siddhesh Poyarekar
  2022-04-28 12:25 ` [PATCH 2/4] ntp_xxxtimex: " Xiaoming Ni
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Xiaoming Ni @ 2022-04-28 12:25 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer, adhemerval.zanella
  Cc: nixiaoming, wangle6, libc-alpha

Add __nonnull((1)) to the adjtimex()/adjtimex64() function declaration
    to avoid null pointer access.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
 sysdeps/unix/sysv/linux/include/sys/timex.h | 4 ++--
 sysdeps/unix/sysv/linux/sys/timex.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index 964a2c21f2..dd599b1c32 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -23,7 +23,7 @@
 
 # ifndef _ISOMAC
 
-extern int __adjtimex (struct timex *__ntx);
+extern int __adjtimex (struct timex *__ntx) __nonnull ((1));
 libc_hidden_proto (__adjtimex)
 
 #  include <time.h>
@@ -79,7 +79,7 @@ struct __timex64
 };
 extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
 libc_hidden_proto (__clock_adjtime64);
-extern int ___adjtimex64 (struct __timex64 *tx64);
+extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1));
 libc_hidden_proto (___adjtimex64)
 
 struct __ntptimeval64
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index 60d94814e8..430e47509d 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -55,7 +55,7 @@ struct ntptimeval
 __BEGIN_DECLS
 
 #ifndef __USE_TIME_BITS64
-extern int adjtimex (struct timex *__ntx) __THROW;
+extern int adjtimex (struct timex *__ntx) __THROW __nonnull ((1));
 extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
 
 # ifdef __REDIRECT_NTH
@@ -68,7 +68,7 @@ extern int ntp_adjtime (struct timex *__tntx) __THROW;
 #else
 # ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (adjtimex, (struct timex *__ntx),
-                           ___adjtimex64);
+                           ___adjtimex64) __nonnull ((1));
 extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
                            __ntp_gettime64);
 extern int __REDIRECT_NTH (ntp_gettimex, (struct ntptimeval *__ntv),
-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 2/4] ntp_xxxtimex: Use __nonnull to avoid null pointer
  2022-04-28 12:25 [PATCH 0/4] time: Use __nonnull to avoid null pointer Xiaoming Ni
  2022-04-28 12:25 ` [PATCH 1/4] adjtimex/adjtimex64: " Xiaoming Ni
@ 2022-04-28 12:25 ` Xiaoming Ni
  2022-05-04 10:59   ` Siddhesh Poyarekar
  2022-04-28 12:25 ` [PATCH 3/4] clock_adjtime: " Xiaoming Ni
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 18+ messages in thread
From: Xiaoming Ni @ 2022-04-28 12:25 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer, adhemerval.zanella
  Cc: nixiaoming, wangle6, libc-alpha

ntp_gettime()
ntp_gettime64()
ntp_gettimex()
ntp_gettimex64()
ntp_adjtime()
Add __nonnull((1)) to avoid null pointer access.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
 sysdeps/unix/sysv/linux/include/sys/timex.h |  4 ++--
 sysdeps/unix/sysv/linux/sys/timex.h         | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index dd599b1c32..9d0da60640 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -94,9 +94,9 @@ struct __ntptimeval64
   long int __glibc_reserved3;
   long int __glibc_reserved4;
 };
-extern int __ntp_gettime64 (struct __ntptimeval64 *ntv);
+extern int __ntp_gettime64 (struct __ntptimeval64 *ntv) __nonnull ((1));
 libc_hidden_proto (__ntp_gettime64)
-extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv);
+extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv) __nonnull ((1));
 libc_hidden_proto (__ntp_gettimex64)
 
 #  endif
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index 430e47509d..1a3d2fdb8d 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -56,25 +56,25 @@ __BEGIN_DECLS
 
 #ifndef __USE_TIME_BITS64
 extern int adjtimex (struct timex *__ntx) __THROW __nonnull ((1));
-extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
+extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW __nonnull ((1));
 
 # ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
-                           ntp_gettimex);
+                           ntp_gettimex) __nonnull ((1));
 # else
 #  define ntp_gettime ntp_gettimex
 # endif
-extern int ntp_adjtime (struct timex *__tntx) __THROW;
+extern int ntp_adjtime (struct timex *__tntx) __THROW __nonnull ((1));
 #else
 # ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (adjtimex, (struct timex *__ntx),
                            ___adjtimex64) __nonnull ((1));
 extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
-                           __ntp_gettime64);
+                           __ntp_gettime64) __nonnull ((1));
 extern int __REDIRECT_NTH (ntp_gettimex, (struct ntptimeval *__ntv),
-                           __ntp_gettimex64);
+                           __ntp_gettimex64) __nonnull ((1));
 extern int __REDIRECT_NTH (ntp_adjtime, (struct timex *__ntx),
-                           ___adjtimex64);
+                           ___adjtimex64) __nonnull ((1));
 # else
 #  define adjtimex ___adjtimex64
 #  define ntp_adjtime ___adjtimex64
-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 3/4] clock_adjtime: Use __nonnull to avoid null pointer
  2022-04-28 12:25 [PATCH 0/4] time: Use __nonnull to avoid null pointer Xiaoming Ni
  2022-04-28 12:25 ` [PATCH 1/4] adjtimex/adjtimex64: " Xiaoming Ni
  2022-04-28 12:25 ` [PATCH 2/4] ntp_xxxtimex: " Xiaoming Ni
@ 2022-04-28 12:25 ` Xiaoming Ni
  2022-05-04 11:00   ` Siddhesh Poyarekar
  2022-04-28 12:25 ` [PATCH 4/4] clock_settime/clock_gettime: " Xiaoming Ni
  2022-05-05  3:01 ` [PATCH v2 0/4] time: " Xiaoming Ni
  4 siblings, 1 reply; 18+ messages in thread
From: Xiaoming Ni @ 2022-04-28 12:25 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer, adhemerval.zanella
  Cc: nixiaoming, wangle6, libc-alpha

clock_adjtime()/clock_adjtime64()
Add __nonnull((2)) to avoid null pointer access.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
 sysdeps/unix/sysv/linux/bits/time.h         | 4 ++--
 sysdeps/unix/sysv/linux/include/sys/timex.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h
index efb4a014df..0485a1e181 100644
--- a/sysdeps/unix/sysv/linux/bits/time.h
+++ b/sysdeps/unix/sysv/linux/bits/time.h
@@ -75,13 +75,13 @@ extern long int __sysconf (int);
 __BEGIN_DECLS
 
 /* Tune a POSIX clock.  */
-extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
+extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW __nonnull((2));
 
 #ifdef __USE_TIME_BITS64
 # if defined(__REDIRECT_NTH)
 extern int __REDIRECT_NTH (clock_adjtime, (__clockid_t __clock_id,
                                            struct timex *__utx),
-                           __clock_adjtime64);
+                           __clock_adjtime64) __nonnull((2));
 # else
 # define clock_adjtime __clock_adjtime64
 # endif
diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index 9d0da60640..0c0261a06d 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -77,7 +77,7 @@ struct __timex64
   int  :32;
   int  :32;
 };
-extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
+extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64) __nonnull((2));
 libc_hidden_proto (__clock_adjtime64);
 extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1));
 libc_hidden_proto (___adjtimex64)
-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer
  2022-04-28 12:25 [PATCH 0/4] time: Use __nonnull to avoid null pointer Xiaoming Ni
                   ` (2 preceding siblings ...)
  2022-04-28 12:25 ` [PATCH 3/4] clock_adjtime: " Xiaoming Ni
@ 2022-04-28 12:25 ` Xiaoming Ni
  2022-05-04 11:02   ` Siddhesh Poyarekar
  2022-05-05  3:01 ` [PATCH v2 0/4] time: " Xiaoming Ni
  4 siblings, 1 reply; 18+ messages in thread
From: Xiaoming Ni @ 2022-04-28 12:25 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer, adhemerval.zanella
  Cc: nixiaoming, wangle6, libc-alpha

clock_settime()
clock_settime64()
clock_gettime()
clock_gettime64()
Add __nonnull((2)) to avoid null pointer access.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
 include/time.h | 4 ++--
 time/time.h    | 9 ++++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/time.h b/include/time.h
index 127347eb90..a64eff54f5 100644
--- a/include/time.h
+++ b/include/time.h
@@ -166,7 +166,7 @@ libc_hidden_proto (__timegm64)
 # define __clock_settime64 __clock_settime
 #else
 extern int __clock_settime64 (clockid_t clock_id,
-                              const struct __timespec64 *tp);
+                              const struct __timespec64 *tp) __nonnull((2));
 libc_hidden_proto (__clock_settime64)
 #endif
 
@@ -324,7 +324,7 @@ extern int __clock_nanosleep_time64 (clockid_t clock_id,
                                      int flags, const struct __timespec64 *req,
                                      struct __timespec64 *rem);
 libc_hidden_proto (__clock_nanosleep_time64)
-extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp);
+extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) __nonnull((2));
 libc_hidden_proto (__clock_gettime64)
 extern int __timespec_get64 (struct __timespec64 *ts, int base);
 libc_hidden_proto (__timespec_get64)
diff --git a/time/time.h b/time/time.h
index 847ac3f8c0..26f276f147 100644
--- a/time/time.h
+++ b/time/time.h
@@ -276,11 +276,12 @@ extern int nanosleep (const struct timespec *__requested_time,
 extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW;
 
 /* Get current value of clock CLOCK_ID and store it in TP.  */
-extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
+extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp)
+     __THROW __nonnull((2));
 
 /* Set clock CLOCK_ID to value TP.  */
 extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
-     __THROW;
+     __THROW __nonnull((2));
 # else
 #  ifdef __REDIRECT
 extern int __REDIRECT (nanosleep, (const struct timespec *__requested_time,
@@ -291,8 +292,10 @@ extern int __REDIRECT_NTH (clock_getres, (clockid_t __clock_id,
                            __clock_getres64);
 extern int __REDIRECT_NTH (clock_gettime, (clockid_t __clock_id, struct
                                            timespec *__tp), __clock_gettime64);
+                           __nonnull((2));
 extern int __REDIRECT_NTH (clock_settime, (clockid_t __clock_id, const struct
-                                           timespec *__tp), __clock_settime64);
+                                           timespec *__tp), __clock_settime64)
+                           __nonnull((2));
 #  else
 #   define nanosleep __nanosleep64
 #   define clock_getres __clock_getres64
-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/4] adjtimex/adjtimex64: Use __nonnull to avoid null pointer
  2022-04-28 12:25 ` [PATCH 1/4] adjtimex/adjtimex64: " Xiaoming Ni
@ 2022-05-04 10:56   ` Siddhesh Poyarekar
  0 siblings, 0 replies; 18+ messages in thread
From: Siddhesh Poyarekar @ 2022-05-04 10:56 UTC (permalink / raw)
  To: Xiaoming Ni, drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella
  Cc: libc-alpha, wangle6

On 28/04/2022 17:55, Xiaoming Ni via Libc-alpha wrote:
> Add __nonnull((1)) to the adjtimex()/adjtimex64() function declaration
>      to avoid null pointer access.
> 
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
> ---

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

>   sysdeps/unix/sysv/linux/include/sys/timex.h | 4 ++--
>   sysdeps/unix/sysv/linux/sys/timex.h         | 4 ++--
>   2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
> index 964a2c21f2..dd599b1c32 100644
> --- a/sysdeps/unix/sysv/linux/include/sys/timex.h
> +++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
> @@ -23,7 +23,7 @@
>   
>   # ifndef _ISOMAC
>   
> -extern int __adjtimex (struct timex *__ntx);
> +extern int __adjtimex (struct timex *__ntx) __nonnull ((1));
>   libc_hidden_proto (__adjtimex)
>   
>   #  include <time.h>
> @@ -79,7 +79,7 @@ struct __timex64
>   };
>   extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
>   libc_hidden_proto (__clock_adjtime64);
> -extern int ___adjtimex64 (struct __timex64 *tx64);
> +extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1));
>   libc_hidden_proto (___adjtimex64)
>   
>   struct __ntptimeval64
> diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
> index 60d94814e8..430e47509d 100644
> --- a/sysdeps/unix/sysv/linux/sys/timex.h
> +++ b/sysdeps/unix/sysv/linux/sys/timex.h
> @@ -55,7 +55,7 @@ struct ntptimeval
>   __BEGIN_DECLS
>   
>   #ifndef __USE_TIME_BITS64
> -extern int adjtimex (struct timex *__ntx) __THROW;
> +extern int adjtimex (struct timex *__ntx) __THROW __nonnull ((1));
>   extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
>   
>   # ifdef __REDIRECT_NTH
> @@ -68,7 +68,7 @@ extern int ntp_adjtime (struct timex *__tntx) __THROW;
>   #else
>   # ifdef __REDIRECT_NTH
>   extern int __REDIRECT_NTH (adjtimex, (struct timex *__ntx),
> -                           ___adjtimex64);
> +                           ___adjtimex64) __nonnull ((1));
>   extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
>                              __ntp_gettime64);
>   extern int __REDIRECT_NTH (ntp_gettimex, (struct ntptimeval *__ntv),


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/4] ntp_xxxtimex: Use __nonnull to avoid null pointer
  2022-04-28 12:25 ` [PATCH 2/4] ntp_xxxtimex: " Xiaoming Ni
@ 2022-05-04 10:59   ` Siddhesh Poyarekar
  0 siblings, 0 replies; 18+ messages in thread
From: Siddhesh Poyarekar @ 2022-05-04 10:59 UTC (permalink / raw)
  To: Xiaoming Ni, drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella
  Cc: libc-alpha, wangle6

On 28/04/2022 17:55, Xiaoming Ni via Libc-alpha wrote:
> ntp_gettime()
> ntp_gettime64()
> ntp_gettimex()
> ntp_gettimex64()
> ntp_adjtime()
> Add __nonnull((1)) to avoid null pointer access.
> 
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
> ---

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

>   sysdeps/unix/sysv/linux/include/sys/timex.h |  4 ++--
>   sysdeps/unix/sysv/linux/sys/timex.h         | 12 ++++++------
>   2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
> index dd599b1c32..9d0da60640 100644
> --- a/sysdeps/unix/sysv/linux/include/sys/timex.h
> +++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
> @@ -94,9 +94,9 @@ struct __ntptimeval64
>     long int __glibc_reserved3;
>     long int __glibc_reserved4;
>   };
> -extern int __ntp_gettime64 (struct __ntptimeval64 *ntv);
> +extern int __ntp_gettime64 (struct __ntptimeval64 *ntv) __nonnull ((1));
>   libc_hidden_proto (__ntp_gettime64)
> -extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv);
> +extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv) __nonnull ((1));
>   libc_hidden_proto (__ntp_gettimex64)
>   
>   #  endif
> diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
> index 430e47509d..1a3d2fdb8d 100644
> --- a/sysdeps/unix/sysv/linux/sys/timex.h
> +++ b/sysdeps/unix/sysv/linux/sys/timex.h
> @@ -56,25 +56,25 @@ __BEGIN_DECLS
>   
>   #ifndef __USE_TIME_BITS64
>   extern int adjtimex (struct timex *__ntx) __THROW __nonnull ((1));
> -extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
> +extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW __nonnull ((1));
>   
>   # ifdef __REDIRECT_NTH
>   extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
> -                           ntp_gettimex);
> +                           ntp_gettimex) __nonnull ((1));
>   # else
>   #  define ntp_gettime ntp_gettimex
>   # endif
> -extern int ntp_adjtime (struct timex *__tntx) __THROW;
> +extern int ntp_adjtime (struct timex *__tntx) __THROW __nonnull ((1));
>   #else
>   # ifdef __REDIRECT_NTH
>   extern int __REDIRECT_NTH (adjtimex, (struct timex *__ntx),
>                              ___adjtimex64) __nonnull ((1));
>   extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
> -                           __ntp_gettime64);
> +                           __ntp_gettime64) __nonnull ((1));
>   extern int __REDIRECT_NTH (ntp_gettimex, (struct ntptimeval *__ntv),
> -                           __ntp_gettimex64);
> +                           __ntp_gettimex64) __nonnull ((1));
>   extern int __REDIRECT_NTH (ntp_adjtime, (struct timex *__ntx),
> -                           ___adjtimex64);
> +                           ___adjtimex64) __nonnull ((1));
>   # else
>   #  define adjtimex ___adjtimex64
>   #  define ntp_adjtime ___adjtimex64


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 3/4] clock_adjtime: Use __nonnull to avoid null pointer
  2022-04-28 12:25 ` [PATCH 3/4] clock_adjtime: " Xiaoming Ni
@ 2022-05-04 11:00   ` Siddhesh Poyarekar
  0 siblings, 0 replies; 18+ messages in thread
From: Siddhesh Poyarekar @ 2022-05-04 11:00 UTC (permalink / raw)
  To: Xiaoming Ni, drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella
  Cc: libc-alpha, wangle6

On 28/04/2022 17:55, Xiaoming Ni via Libc-alpha wrote:
> clock_adjtime()/clock_adjtime64()
> Add __nonnull((2)) to avoid null pointer access.
> 
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
> ---

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>


>   sysdeps/unix/sysv/linux/bits/time.h         | 4 ++--
>   sysdeps/unix/sysv/linux/include/sys/timex.h | 2 +-
>   2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h
> index efb4a014df..0485a1e181 100644
> --- a/sysdeps/unix/sysv/linux/bits/time.h
> +++ b/sysdeps/unix/sysv/linux/bits/time.h
> @@ -75,13 +75,13 @@ extern long int __sysconf (int);
>   __BEGIN_DECLS
>   
>   /* Tune a POSIX clock.  */
> -extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
> +extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW __nonnull((2));
>   
>   #ifdef __USE_TIME_BITS64
>   # if defined(__REDIRECT_NTH)
>   extern int __REDIRECT_NTH (clock_adjtime, (__clockid_t __clock_id,
>                                              struct timex *__utx),
> -                           __clock_adjtime64);
> +                           __clock_adjtime64) __nonnull((2));
>   # else
>   # define clock_adjtime __clock_adjtime64
>   # endif
> diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
> index 9d0da60640..0c0261a06d 100644
> --- a/sysdeps/unix/sysv/linux/include/sys/timex.h
> +++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
> @@ -77,7 +77,7 @@ struct __timex64
>     int  :32;
>     int  :32;
>   };
> -extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
> +extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64) __nonnull((2));
>   libc_hidden_proto (__clock_adjtime64);
>   extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1));
>   libc_hidden_proto (___adjtimex64)


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer
  2022-04-28 12:25 ` [PATCH 4/4] clock_settime/clock_gettime: " Xiaoming Ni
@ 2022-05-04 11:02   ` Siddhesh Poyarekar
  2022-05-05  1:39     ` Xiaoming Ni
  0 siblings, 1 reply; 18+ messages in thread
From: Siddhesh Poyarekar @ 2022-05-04 11:02 UTC (permalink / raw)
  To: Xiaoming Ni, drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella
  Cc: libc-alpha, wangle6

On 28/04/2022 17:55, Xiaoming Ni via Libc-alpha wrote:
> clock_settime()
> clock_settime64()
> clock_gettime()
> clock_gettime64()
> Add __nonnull((2)) to avoid null pointer access.
> 
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
> ---
>   include/time.h | 4 ++--
>   time/time.h    | 9 ++++++---
>   2 files changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/include/time.h b/include/time.h
> index 127347eb90..a64eff54f5 100644
> --- a/include/time.h
> +++ b/include/time.h
> @@ -166,7 +166,7 @@ libc_hidden_proto (__timegm64)
>   # define __clock_settime64 __clock_settime
>   #else
>   extern int __clock_settime64 (clockid_t clock_id,
> -                              const struct __timespec64 *tp);
> +                              const struct __timespec64 *tp) __nonnull((2));
>   libc_hidden_proto (__clock_settime64)
>   #endif
>   
> @@ -324,7 +324,7 @@ extern int __clock_nanosleep_time64 (clockid_t clock_id,
>                                        int flags, const struct __timespec64 *req,
>                                        struct __timespec64 *rem);
>   libc_hidden_proto (__clock_nanosleep_time64)
> -extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp);
> +extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) __nonnull((2));
>   libc_hidden_proto (__clock_gettime64)
>   extern int __timespec_get64 (struct __timespec64 *ts, int base);
>   libc_hidden_proto (__timespec_get64)
> diff --git a/time/time.h b/time/time.h
> index 847ac3f8c0..26f276f147 100644
> --- a/time/time.h
> +++ b/time/time.h
> @@ -276,11 +276,12 @@ extern int nanosleep (const struct timespec *__requested_time,
>   extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW;
>   
>   /* Get current value of clock CLOCK_ID and store it in TP.  */
> -extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
> +extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp)
> +     __THROW __nonnull((2));
>   
>   /* Set clock CLOCK_ID to value TP.  */
>   extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
> -     __THROW;
> +     __THROW __nonnull((2));
>   # else
>   #  ifdef __REDIRECT
>   extern int __REDIRECT (nanosleep, (const struct timespec *__requested_time,
> @@ -291,8 +292,10 @@ extern int __REDIRECT_NTH (clock_getres, (clockid_t __clock_id,
>                              __clock_getres64);
>   extern int __REDIRECT_NTH (clock_gettime, (clockid_t __clock_id, struct
>                                              timespec *__tp), __clock_gettime64);

The semicolon at the end needs to go away.  This was also caught by 
patchwork trybot:

https://patchwork.sourceware.org/project/glibc/patch/20220428122529.108208-5-nixiaoming@huawei.com/
https://www.delorie.com/trybots/32bit/8846/make.tail.txt

> +                           __nonnull((2));
>   extern int __REDIRECT_NTH (clock_settime, (clockid_t __clock_id, const struct
> -                                           timespec *__tp), __clock_settime64);
> +                                           timespec *__tp), __clock_settime64)
> +                           __nonnull((2));
>   #  else
>   #   define nanosleep __nanosleep64
>   #   define clock_getres __clock_getres64


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer
  2022-05-04 11:02   ` Siddhesh Poyarekar
@ 2022-05-05  1:39     ` Xiaoming Ni
  0 siblings, 0 replies; 18+ messages in thread
From: Xiaoming Ni @ 2022-05-05  1:39 UTC (permalink / raw)
  To: Siddhesh Poyarekar, drepper, lukma, adrian.ratiu, schwab,
	fweimer, adhemerval.zanella
  Cc: libc-alpha, wangle6

On 2022/5/4 19:02, Siddhesh Poyarekar wrote:
> On 28/04/2022 17:55, Xiaoming Ni via Libc-alpha wrote:
>> clock_settime()
>> clock_settime64()
>> clock_gettime()
>> clock_gettime64()
>> Add __nonnull((2)) to avoid null pointer access.
>>
>> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
>> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
>> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
>> ---
>>   include/time.h | 4 ++--
>>   time/time.h    | 9 ++++++---
>>   2 files changed, 8 insertions(+), 5 deletions(-)
>>
>> diff --git a/include/time.h b/include/time.h
>> index 127347eb90..a64eff54f5 100644
>> --- a/include/time.h
>> +++ b/include/time.h
>> @@ -166,7 +166,7 @@ libc_hidden_proto (__timegm64)
>>   # define __clock_settime64 __clock_settime
>>   #else
>>   extern int __clock_settime64 (clockid_t clock_id,
>> -                              const struct __timespec64 *tp);
>> +                              const struct __timespec64 *tp) 
>> __nonnull((2));
>>   libc_hidden_proto (__clock_settime64)
>>   #endif
>> @@ -324,7 +324,7 @@ extern int __clock_nanosleep_time64 (clockid_t 
>> clock_id,
>>                                        int flags, const struct 
>> __timespec64 *req,
>>                                        struct __timespec64 *rem);
>>   libc_hidden_proto (__clock_nanosleep_time64)
>> -extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 
>> *tp);
>> +extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 
>> *tp) __nonnull((2));
>>   libc_hidden_proto (__clock_gettime64)
>>   extern int __timespec_get64 (struct __timespec64 *ts, int base);
>>   libc_hidden_proto (__timespec_get64)
>> diff --git a/time/time.h b/time/time.h
>> index 847ac3f8c0..26f276f147 100644
>> --- a/time/time.h
>> +++ b/time/time.h
>> @@ -276,11 +276,12 @@ extern int nanosleep (const struct timespec 
>> *__requested_time,
>>   extern int clock_getres (clockid_t __clock_id, struct timespec 
>> *__res) __THROW;
>>   /* Get current value of clock CLOCK_ID and store it in TP.  */
>> -extern int clock_gettime (clockid_t __clock_id, struct timespec 
>> *__tp) __THROW;
>> +extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp)
>> +     __THROW __nonnull((2));
>>   /* Set clock CLOCK_ID to value TP.  */
>>   extern int clock_settime (clockid_t __clock_id, const struct 
>> timespec *__tp)
>> -     __THROW;
>> +     __THROW __nonnull((2));
>>   # else
>>   #  ifdef __REDIRECT
>>   extern int __REDIRECT (nanosleep, (const struct timespec 
>> *__requested_time,
>> @@ -291,8 +292,10 @@ extern int __REDIRECT_NTH (clock_getres, 
>> (clockid_t __clock_id,
>>                              __clock_getres64);
>>   extern int __REDIRECT_NTH (clock_gettime, (clockid_t __clock_id, struct
>>                                              timespec *__tp), 
>> __clock_gettime64);
> 
> The semicolon at the end needs to go away.  This was also caught by 
> patchwork trybot:
> 
> https://patchwork.sourceware.org/project/glibc/patch/20220428122529.108208-5-nixiaoming@huawei.com/ 
> 
> https://www.delorie.com/trybots/32bit/8846/make.tail.txt
>
Thanks, I'll fix it later on v2.


>> +                           __nonnull((2));
>>   extern int __REDIRECT_NTH (clock_settime, (clockid_t __clock_id, 
>> const struct
>> -                                           timespec *__tp), 
>> __clock_settime64);
>> +                                           timespec *__tp), 
>> __clock_settime64)
>> +                           __nonnull((2));
>>   #  else
>>   #   define nanosleep __nanosleep64
>>   #   define clock_getres __clock_getres64
> 
> .


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 0/4] time: Use __nonnull to avoid null pointer
  2022-04-28 12:25 [PATCH 0/4] time: Use __nonnull to avoid null pointer Xiaoming Ni
                   ` (3 preceding siblings ...)
  2022-04-28 12:25 ` [PATCH 4/4] clock_settime/clock_gettime: " Xiaoming Ni
@ 2022-05-05  3:01 ` Xiaoming Ni
  2022-05-05  3:01   ` [PATCH v2 1/4] adjtimex/adjtimex64: " Xiaoming Ni
                     ` (3 more replies)
  4 siblings, 4 replies; 18+ messages in thread
From: Xiaoming Ni @ 2022-05-05  3:01 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella, siddhesh
  Cc: nixiaoming, wangle6, libc-alpha

Some external interface codes do not check whether the pointer parameter
 is null. If the parameter is null, the program crashes (BZ#27662).
Therefore, add a __nonull statement to the function declaration to avoid
 null pointers.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084

The __nonull declaration is added for the following interfaces:
	adjtimex()
	adjtimex64()
	ntp_gettime()
	ntp_gettime64()
	ntp_gettimex()
	ntp_gettimex64()
	ntp_adjtime()
	clock_settime()
	clock_settime64()
	clock_gettime()
	clock_gettime64()
	clock_adjtime()
	clock_adjtime64()
--
v2:
  fix the compilation error caused by missing semicolons.
  Thanks Siddhesh Poyarekar for the review.
v1: https://public-inbox.org/libc-alpha/20220428122529.108208-1-nixiaoming@huawei.com/

--

Xiaoming Ni (4):
  adjtimex/adjtimex64: Use __nonnull to avoid null pointer
  ntp_xxxtimex: Use __nonnull to avoid null pointer
  clock_adjtime: Use __nonnull to avoid null pointer
  clock_settime/clock_gettime: Use __nonnull to avoid null pointer

 include/time.h                              |  4 ++--
 sysdeps/unix/sysv/linux/bits/time.h         |  4 ++--
 sysdeps/unix/sysv/linux/include/sys/timex.h | 10 +++++-----
 sysdeps/unix/sysv/linux/sys/timex.h         | 16 ++++++++--------
 time/time.h                                 | 11 +++++++----
 5 files changed, 24 insertions(+), 21 deletions(-)

-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 1/4] adjtimex/adjtimex64: Use __nonnull to avoid null pointer
  2022-05-05  3:01 ` [PATCH v2 0/4] time: " Xiaoming Ni
@ 2022-05-05  3:01   ` Xiaoming Ni
  2022-05-05  3:01   ` [PATCH v2 2/4] ntp_xxxtimex: " Xiaoming Ni
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 18+ messages in thread
From: Xiaoming Ni @ 2022-05-05  3:01 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella, siddhesh
  Cc: nixiaoming, wangle6, libc-alpha

Add __nonnull((1)) to the adjtimex()/adjtimex64() function declaration
    to avoid null pointer access.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
---
 sysdeps/unix/sysv/linux/include/sys/timex.h | 4 ++--
 sysdeps/unix/sysv/linux/sys/timex.h         | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index 964a2c21f2..dd599b1c32 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -23,7 +23,7 @@
 
 # ifndef _ISOMAC
 
-extern int __adjtimex (struct timex *__ntx);
+extern int __adjtimex (struct timex *__ntx) __nonnull ((1));
 libc_hidden_proto (__adjtimex)
 
 #  include <time.h>
@@ -79,7 +79,7 @@ struct __timex64
 };
 extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
 libc_hidden_proto (__clock_adjtime64);
-extern int ___adjtimex64 (struct __timex64 *tx64);
+extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1));
 libc_hidden_proto (___adjtimex64)
 
 struct __ntptimeval64
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index 60d94814e8..430e47509d 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -55,7 +55,7 @@ struct ntptimeval
 __BEGIN_DECLS
 
 #ifndef __USE_TIME_BITS64
-extern int adjtimex (struct timex *__ntx) __THROW;
+extern int adjtimex (struct timex *__ntx) __THROW __nonnull ((1));
 extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
 
 # ifdef __REDIRECT_NTH
@@ -68,7 +68,7 @@ extern int ntp_adjtime (struct timex *__tntx) __THROW;
 #else
 # ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (adjtimex, (struct timex *__ntx),
-                           ___adjtimex64);
+                           ___adjtimex64) __nonnull ((1));
 extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
                            __ntp_gettime64);
 extern int __REDIRECT_NTH (ntp_gettimex, (struct ntptimeval *__ntv),
-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 2/4] ntp_xxxtimex: Use __nonnull to avoid null pointer
  2022-05-05  3:01 ` [PATCH v2 0/4] time: " Xiaoming Ni
  2022-05-05  3:01   ` [PATCH v2 1/4] adjtimex/adjtimex64: " Xiaoming Ni
@ 2022-05-05  3:01   ` Xiaoming Ni
  2022-05-05  3:01   ` [PATCH v2 3/4] clock_adjtime: " Xiaoming Ni
  2022-05-05  3:01   ` [PATCH v2 4/4] clock_settime/clock_gettime: " Xiaoming Ni
  3 siblings, 0 replies; 18+ messages in thread
From: Xiaoming Ni @ 2022-05-05  3:01 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella, siddhesh
  Cc: nixiaoming, wangle6, libc-alpha

ntp_gettime()
ntp_gettime64()
ntp_gettimex()
ntp_gettimex64()
ntp_adjtime()
Add __nonnull((1)) to avoid null pointer access.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
---
 sysdeps/unix/sysv/linux/include/sys/timex.h |  4 ++--
 sysdeps/unix/sysv/linux/sys/timex.h         | 12 ++++++------
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index dd599b1c32..9d0da60640 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -94,9 +94,9 @@ struct __ntptimeval64
   long int __glibc_reserved3;
   long int __glibc_reserved4;
 };
-extern int __ntp_gettime64 (struct __ntptimeval64 *ntv);
+extern int __ntp_gettime64 (struct __ntptimeval64 *ntv) __nonnull ((1));
 libc_hidden_proto (__ntp_gettime64)
-extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv);
+extern int __ntp_gettimex64 (struct __ntptimeval64 *ntv) __nonnull ((1));
 libc_hidden_proto (__ntp_gettimex64)
 
 #  endif
diff --git a/sysdeps/unix/sysv/linux/sys/timex.h b/sysdeps/unix/sysv/linux/sys/timex.h
index 430e47509d..1a3d2fdb8d 100644
--- a/sysdeps/unix/sysv/linux/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/sys/timex.h
@@ -56,25 +56,25 @@ __BEGIN_DECLS
 
 #ifndef __USE_TIME_BITS64
 extern int adjtimex (struct timex *__ntx) __THROW __nonnull ((1));
-extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW;
+extern int ntp_gettimex (struct ntptimeval *__ntv) __THROW __nonnull ((1));
 
 # ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
-                           ntp_gettimex);
+                           ntp_gettimex) __nonnull ((1));
 # else
 #  define ntp_gettime ntp_gettimex
 # endif
-extern int ntp_adjtime (struct timex *__tntx) __THROW;
+extern int ntp_adjtime (struct timex *__tntx) __THROW __nonnull ((1));
 #else
 # ifdef __REDIRECT_NTH
 extern int __REDIRECT_NTH (adjtimex, (struct timex *__ntx),
                            ___adjtimex64) __nonnull ((1));
 extern int __REDIRECT_NTH (ntp_gettime, (struct ntptimeval *__ntv),
-                           __ntp_gettime64);
+                           __ntp_gettime64) __nonnull ((1));
 extern int __REDIRECT_NTH (ntp_gettimex, (struct ntptimeval *__ntv),
-                           __ntp_gettimex64);
+                           __ntp_gettimex64) __nonnull ((1));
 extern int __REDIRECT_NTH (ntp_adjtime, (struct timex *__ntx),
-                           ___adjtimex64);
+                           ___adjtimex64) __nonnull ((1));
 # else
 #  define adjtimex ___adjtimex64
 #  define ntp_adjtime ___adjtimex64
-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 3/4] clock_adjtime: Use __nonnull to avoid null pointer
  2022-05-05  3:01 ` [PATCH v2 0/4] time: " Xiaoming Ni
  2022-05-05  3:01   ` [PATCH v2 1/4] adjtimex/adjtimex64: " Xiaoming Ni
  2022-05-05  3:01   ` [PATCH v2 2/4] ntp_xxxtimex: " Xiaoming Ni
@ 2022-05-05  3:01   ` Xiaoming Ni
  2022-05-05  3:01   ` [PATCH v2 4/4] clock_settime/clock_gettime: " Xiaoming Ni
  3 siblings, 0 replies; 18+ messages in thread
From: Xiaoming Ni @ 2022-05-05  3:01 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella, siddhesh
  Cc: nixiaoming, wangle6, libc-alpha

clock_adjtime()/clock_adjtime64()
Add __nonnull((2)) to avoid null pointer access.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
---
 sysdeps/unix/sysv/linux/bits/time.h         | 4 ++--
 sysdeps/unix/sysv/linux/include/sys/timex.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/sysdeps/unix/sysv/linux/bits/time.h b/sysdeps/unix/sysv/linux/bits/time.h
index efb4a014df..0485a1e181 100644
--- a/sysdeps/unix/sysv/linux/bits/time.h
+++ b/sysdeps/unix/sysv/linux/bits/time.h
@@ -75,13 +75,13 @@ extern long int __sysconf (int);
 __BEGIN_DECLS
 
 /* Tune a POSIX clock.  */
-extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW;
+extern int clock_adjtime (__clockid_t __clock_id, struct timex *__utx) __THROW __nonnull((2));
 
 #ifdef __USE_TIME_BITS64
 # if defined(__REDIRECT_NTH)
 extern int __REDIRECT_NTH (clock_adjtime, (__clockid_t __clock_id,
                                            struct timex *__utx),
-                           __clock_adjtime64);
+                           __clock_adjtime64) __nonnull((2));
 # else
 # define clock_adjtime __clock_adjtime64
 # endif
diff --git a/sysdeps/unix/sysv/linux/include/sys/timex.h b/sysdeps/unix/sysv/linux/include/sys/timex.h
index 9d0da60640..0c0261a06d 100644
--- a/sysdeps/unix/sysv/linux/include/sys/timex.h
+++ b/sysdeps/unix/sysv/linux/include/sys/timex.h
@@ -77,7 +77,7 @@ struct __timex64
   int  :32;
   int  :32;
 };
-extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64);
+extern int __clock_adjtime64 (const clockid_t clock_id, struct __timex64 *tx64) __nonnull((2));
 libc_hidden_proto (__clock_adjtime64);
 extern int ___adjtimex64 (struct __timex64 *tx64) __nonnull ((1));
 libc_hidden_proto (___adjtimex64)
-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2 4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer
  2022-05-05  3:01 ` [PATCH v2 0/4] time: " Xiaoming Ni
                     ` (2 preceding siblings ...)
  2022-05-05  3:01   ` [PATCH v2 3/4] clock_adjtime: " Xiaoming Ni
@ 2022-05-05  3:01   ` Xiaoming Ni
  2022-05-05  4:26     ` Siddhesh Poyarekar
  3 siblings, 1 reply; 18+ messages in thread
From: Xiaoming Ni @ 2022-05-05  3:01 UTC (permalink / raw)
  To: drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella, siddhesh
  Cc: nixiaoming, wangle6, libc-alpha

clock_settime()
clock_settime64()
clock_gettime()
clock_gettime64()
Add __nonnull((2)) to avoid null pointer access.

Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
 include/time.h |  4 ++--
 time/time.h    | 11 +++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/include/time.h b/include/time.h
index 127347eb90..a64eff54f5 100644
--- a/include/time.h
+++ b/include/time.h
@@ -166,7 +166,7 @@ libc_hidden_proto (__timegm64)
 # define __clock_settime64 __clock_settime
 #else
 extern int __clock_settime64 (clockid_t clock_id,
-                              const struct __timespec64 *tp);
+                              const struct __timespec64 *tp) __nonnull((2));
 libc_hidden_proto (__clock_settime64)
 #endif
 
@@ -324,7 +324,7 @@ extern int __clock_nanosleep_time64 (clockid_t clock_id,
                                      int flags, const struct __timespec64 *req,
                                      struct __timespec64 *rem);
 libc_hidden_proto (__clock_nanosleep_time64)
-extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp);
+extern int __clock_gettime64 (clockid_t clock_id, struct __timespec64 *tp) __nonnull((2));
 libc_hidden_proto (__clock_gettime64)
 extern int __timespec_get64 (struct __timespec64 *ts, int base);
 libc_hidden_proto (__timespec_get64)
diff --git a/time/time.h b/time/time.h
index 847ac3f8c0..2cf89e6222 100644
--- a/time/time.h
+++ b/time/time.h
@@ -276,11 +276,12 @@ extern int nanosleep (const struct timespec *__requested_time,
 extern int clock_getres (clockid_t __clock_id, struct timespec *__res) __THROW;
 
 /* Get current value of clock CLOCK_ID and store it in TP.  */
-extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp) __THROW;
+extern int clock_gettime (clockid_t __clock_id, struct timespec *__tp)
+     __THROW __nonnull((2));
 
 /* Set clock CLOCK_ID to value TP.  */
 extern int clock_settime (clockid_t __clock_id, const struct timespec *__tp)
-     __THROW;
+     __THROW __nonnull((2));
 # else
 #  ifdef __REDIRECT
 extern int __REDIRECT (nanosleep, (const struct timespec *__requested_time,
@@ -290,9 +291,11 @@ extern int __REDIRECT_NTH (clock_getres, (clockid_t __clock_id,
                                           struct timespec *__res),
                            __clock_getres64);
 extern int __REDIRECT_NTH (clock_gettime, (clockid_t __clock_id, struct
-                                           timespec *__tp), __clock_gettime64);
+                                           timespec *__tp), __clock_gettime64)
+                           __nonnull((2));
 extern int __REDIRECT_NTH (clock_settime, (clockid_t __clock_id, const struct
-                                           timespec *__tp), __clock_settime64);
+                                           timespec *__tp), __clock_settime64)
+                           __nonnull((2));
 #  else
 #   define nanosleep __nanosleep64
 #   define clock_getres __clock_getres64
-- 
2.27.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer
  2022-05-05  3:01   ` [PATCH v2 4/4] clock_settime/clock_gettime: " Xiaoming Ni
@ 2022-05-05  4:26     ` Siddhesh Poyarekar
  2022-05-05  8:23       ` Xiaoming Ni
  0 siblings, 1 reply; 18+ messages in thread
From: Siddhesh Poyarekar @ 2022-05-05  4:26 UTC (permalink / raw)
  To: Xiaoming Ni, drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella
  Cc: libc-alpha, wangle6

On 05/05/2022 08:31, Xiaoming Ni via Libc-alpha wrote:
> clock_settime()
> clock_settime64()
> clock_gettime()
> clock_gettime64()
> Add __nonnull((2)) to avoid null pointer access.
> 
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
> ---

LGTM.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

Do you have commit access or do you need someone to push this for you?

Thanks,
Siddhesh

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer
  2022-05-05  4:26     ` Siddhesh Poyarekar
@ 2022-05-05  8:23       ` Xiaoming Ni
  2022-05-05 12:26         ` Siddhesh Poyarekar
  0 siblings, 1 reply; 18+ messages in thread
From: Xiaoming Ni @ 2022-05-05  8:23 UTC (permalink / raw)
  To: Siddhesh Poyarekar, drepper, lukma, adrian.ratiu, schwab,
	fweimer, adhemerval.zanella
  Cc: libc-alpha, wangle6

On 2022/5/5 12:26, Siddhesh Poyarekar wrote:
> On 05/05/2022 08:31, Xiaoming Ni via Libc-alpha wrote:
>> clock_settime()
>> clock_settime64()
>> clock_gettime()
>> clock_gettime64()
>> Add __nonnull((2)) to avoid null pointer access.
>>
>> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
>> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
>> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
>> ---
> 
> LGTM.
> 
> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
> 
> Do you have commit access or do you need someone to push this for you?
> 
> Thanks,
> Siddhesh
> 
> .
I don't have the permission to push directly.
Can you help push this patch set?

Thanks
Xiaoming Ni
.



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2 4/4] clock_settime/clock_gettime: Use __nonnull to avoid null pointer
  2022-05-05  8:23       ` Xiaoming Ni
@ 2022-05-05 12:26         ` Siddhesh Poyarekar
  0 siblings, 0 replies; 18+ messages in thread
From: Siddhesh Poyarekar @ 2022-05-05 12:26 UTC (permalink / raw)
  To: Xiaoming Ni, drepper, lukma, adrian.ratiu, schwab, fweimer,
	adhemerval.zanella
  Cc: wangle6, libc-alpha

On 05/05/2022 13:53, Xiaoming Ni via Libc-alpha wrote:
> On 2022/5/5 12:26, Siddhesh Poyarekar wrote:
>> On 05/05/2022 08:31, Xiaoming Ni via Libc-alpha wrote:
>>> clock_settime()
>>> clock_settime64()
>>> clock_gettime()
>>> clock_gettime64()
>>> Add __nonnull((2)) to avoid null pointer access.
>>>
>>> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=27662
>>> Link: https://sourceware.org/bugzilla/show_bug.cgi?id=29084
>>> Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
>>> ---
>>
>> LGTM.
>>
>> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
>>
>> Do you have commit access or do you need someone to push this for you?
>>
>> Thanks,
>> Siddhesh
>>
>> .
> I don't have the permission to push directly.
> Can you help push this patch set?

Done, thanks.

Siddhesh

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2022-05-05 12:26 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-28 12:25 [PATCH 0/4] time: Use __nonnull to avoid null pointer Xiaoming Ni
2022-04-28 12:25 ` [PATCH 1/4] adjtimex/adjtimex64: " Xiaoming Ni
2022-05-04 10:56   ` Siddhesh Poyarekar
2022-04-28 12:25 ` [PATCH 2/4] ntp_xxxtimex: " Xiaoming Ni
2022-05-04 10:59   ` Siddhesh Poyarekar
2022-04-28 12:25 ` [PATCH 3/4] clock_adjtime: " Xiaoming Ni
2022-05-04 11:00   ` Siddhesh Poyarekar
2022-04-28 12:25 ` [PATCH 4/4] clock_settime/clock_gettime: " Xiaoming Ni
2022-05-04 11:02   ` Siddhesh Poyarekar
2022-05-05  1:39     ` Xiaoming Ni
2022-05-05  3:01 ` [PATCH v2 0/4] time: " Xiaoming Ni
2022-05-05  3:01   ` [PATCH v2 1/4] adjtimex/adjtimex64: " Xiaoming Ni
2022-05-05  3:01   ` [PATCH v2 2/4] ntp_xxxtimex: " Xiaoming Ni
2022-05-05  3:01   ` [PATCH v2 3/4] clock_adjtime: " Xiaoming Ni
2022-05-05  3:01   ` [PATCH v2 4/4] clock_settime/clock_gettime: " Xiaoming Ni
2022-05-05  4:26     ` Siddhesh Poyarekar
2022-05-05  8:23       ` Xiaoming Ni
2022-05-05 12:26         ` Siddhesh Poyarekar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).