public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 4/5] syscalls: Don't pass struct timespec to tst_syscall()
Date: Tue, 19 May 2020 14:21:55 +0200	[thread overview]
Message-ID: <20200519122155.GB16008@yuki.lan> (raw)
In-Reply-To: <a6c2c59a9cffb86d751b911384a560803e723623.1589877853.git.viresh.kumar@linaro.org>

Hi!
> There are compatibility issues here as we are calling the direct
> syscalls with the "struct timespec" (which is a libc definition). We
> must use struct __kernel_old_timespec instead.
> 
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
>  include/tst_clocks.h          |  8 +++++---
>  lib/tst_clocks.c              |  6 +++---
>  lib/tst_test.c                | 16 ++++++++--------
>  lib/tst_timer.c               | 23 +++++++++++++++--------
>  lib/tst_timer_test.c          |  2 +-
>  lib/tst_wallclock.c           | 17 +++++++++--------
>  testcases/cve/cve-2016-7117.c |  2 +-
>  7 files changed, 42 insertions(+), 32 deletions(-)
> 
> diff --git a/include/tst_clocks.h b/include/tst_clocks.h
> index 80030c6b0c68..bb149acd2f83 100644
> --- a/include/tst_clocks.h
> +++ b/include/tst_clocks.h
> @@ -9,11 +9,13 @@
>  #ifndef TST_CLOCKS__
>  #define TST_CLOCKS__
>  
> -int tst_clock_getres(clockid_t clk_id, struct timespec *res);
> +struct __kernel_old_timespec;
>  
> -int tst_clock_gettime(clockid_t clk_id, struct timespec *ts);
> +int tst_clock_getres(clockid_t clk_id, struct __kernel_old_timespec *res);
>  
> -int tst_clock_settime(clockid_t clk_id, struct timespec *ts);
> +int tst_clock_gettime(clockid_t clk_id, struct __kernel_old_timespec *ts);
> +
> +int tst_clock_settime(clockid_t clk_id, struct __kernel_old_timespec *ts);
>  
>  /*
>   * Converts clock id to a readable name.
> diff --git a/lib/tst_clocks.c b/lib/tst_clocks.c
> index 2eaa73b11abe..8d8c2f7666fa 100644
> --- a/lib/tst_clocks.c
> +++ b/lib/tst_clocks.c
> @@ -11,17 +11,17 @@
>  #include "lapi/syscalls.h"
>  #include "lapi/posix_clocks.h"
>  
> -int tst_clock_getres(clockid_t clk_id, struct timespec *res)
> +int tst_clock_getres(clockid_t clk_id, struct __kernel_old_timespec *res)
>  {
>  	return tst_syscall(__NR_clock_getres, clk_id, res);
>  }
>  
> -int tst_clock_gettime(clockid_t clk_id, struct timespec *ts)
> +int tst_clock_gettime(clockid_t clk_id, struct __kernel_old_timespec *ts)
>  {
>  	return tst_syscall(__NR_clock_gettime, clk_id, ts);
>  }
>  
> -int tst_clock_settime(clockid_t clk_id, struct timespec *ts)
> +int tst_clock_settime(clockid_t clk_id, struct __kernel_old_timespec *ts)
>  {
>  	return tst_syscall(__NR_clock_settime, clk_id, ts);
>  }

These functions are supposed to be library-internal and were added so
that we do not have to link everything in LTP with -lrt, which is needed
for the clock_gettime() functions on older glibc.

So we can as well so that they take the tst_ts structure, then we are
also free to change the way the timestamp is acquired without the need
to change all the callers.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2020-05-19 12:21 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-19  8:51 [LTP] [PATCH 0/5] syscalls: Remove incorrect usage of libc structures Viresh Kumar
2020-05-19  8:51 ` [LTP] [PATCH 1/5] tst_safe_clocks: Remove safe_clock_adjtime() Viresh Kumar
2020-05-19  8:51 ` [LTP] [PATCH 2/5] syscalls: settimeofday: Use gettimeofday() Viresh Kumar
2020-05-19  9:20   ` Arnd Bergmann
2020-05-19  9:25     ` Viresh Kumar
2020-05-19 10:24       ` Arnd Bergmann
2020-05-19 12:16   ` Cyril Hrubis
2020-05-19 12:47     ` Arnd Bergmann
2020-05-20  7:16     ` Viresh Kumar
2020-05-21 13:16       ` Cyril Hrubis
2020-05-19  8:51 ` [LTP] [PATCH 3/5] syscalls: Don't use tst_syscall() unnecessarily Viresh Kumar
2020-05-19  9:22   ` Arnd Bergmann
2020-05-19  9:28     ` Viresh Kumar
2020-05-19 12:23   ` Cyril Hrubis
2020-05-19 12:41     ` Arnd Bergmann
2020-05-19 12:56       ` Petr Vorel
2020-05-19 13:45       ` Cyril Hrubis
2020-05-20  7:19         ` Viresh Kumar
2020-05-21 14:20           ` Cyril Hrubis
2020-05-21 15:10             ` Arnd Bergmann
2020-05-19  8:51 ` [LTP] [PATCH 4/5] syscalls: Don't pass struct timespec to tst_syscall() Viresh Kumar
2020-05-19 12:21   ` Cyril Hrubis [this message]
2020-05-20  7:31     ` Viresh Kumar
2020-05-20  8:47       ` Arnd Bergmann
2020-05-20  9:05         ` Viresh Kumar
2020-05-20  9:35           ` Arnd Bergmann
2020-05-20  9:39             ` Viresh Kumar
2020-05-20  9:52               ` Arnd Bergmann
2020-05-19  8:51 ` [LTP] [PATCH 5/5] syscalls: Don't pass struct timeval " Viresh Kumar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200519122155.GB16008@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox