All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Wei Gao <wegao@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1 2/2] ptrace06: Refactor the test using new LTP API
Date: Tue, 28 Nov 2023 09:31:02 +0000	[thread overview]
Message-ID: <87v89m6vq6.fsf@suse.de> (raw)
In-Reply-To: <20230925112245.30701-3-wegao@suse.com>

Hello,

Wei Gao via ltp <ltp@lists.linux.it> writes:

> Signed-off-by: Wei Gao <wegao@suse.com>
> ---
>  testcases/kernel/syscalls/ptrace/ptrace06.c | 306 +++++++++++---------
>  1 file changed, 175 insertions(+), 131 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/ptrace/ptrace06.c b/testcases/kernel/syscalls/ptrace/ptrace06.c
> index c0cb3b9bd..5829faea4 100644
> --- a/testcases/kernel/syscalls/ptrace/ptrace06.c
> +++ b/testcases/kernel/syscalls/ptrace/ptrace06.c
> @@ -1,32 +1,31 @@
> +// SPDX-License-Identifier: GPL-2.0-only
>  /*
> + * Copyright (c) 2008 Analog Devices Inc.
> + * Copyright (c) 2023 Wei Gao <wegao@suse.com>
> + */
> +
> +/*\
> + * [Description]
> + *
>   * check out-of-bound/unaligned addresses given to
>   *  - {PEEK,POKE}{DATA,TEXT,USER}
>   *  - {GET,SET}{,FG}REGS
>   *  - {GET,SET}SIGINFO
>   *
> - * Copyright (c) 2008 Analog Devices Inc.
> - *
> - * Licensed under the GPL-2 or later
>   */
>  
>  #define _GNU_SOURCE
>  
> -#include <errno.h>
> -#include <stdbool.h>
> -#include <stdio.h>
>  #include <stdlib.h>
> -#include <unistd.h>
> -
>  #include <config.h>
> -#include "ptrace.h"
>  
> -#include "test.h"
> -#include "spawn_ptrace_child.h"
> -#include "config.h"
> +#include "ptrace.h"
> +#include "tst_test.h"
>  
>  /* this should be sizeof(struct user), but that info is only found
>   * in the kernel asm/user.h which is not exported to userspace.
>   */
> +
>  #if defined(__i386__)
>  #define SIZEOF_USER 284
>  #elif defined(__x86_64__)
> @@ -35,168 +34,213 @@
>  #define SIZEOF_USER 0x1000	/* just pick a big number */
>  #endif
>  
> -char *TCID = "ptrace06";
> -
>  struct test_case_t {
>  	int request;
>  	long addr;
>  	long data;
>  } test_cases[] = {
>  	{
> -	PTRACE_PEEKDATA,.addr = 0}, {
> -	PTRACE_PEEKDATA,.addr = 1}, {
> -	PTRACE_PEEKDATA,.addr = 2}, {
> -	PTRACE_PEEKDATA,.addr = 3}, {
> -	PTRACE_PEEKDATA,.addr = -1}, {
> -	PTRACE_PEEKDATA,.addr = -2}, {
> -	PTRACE_PEEKDATA,.addr = -3}, {
> -	PTRACE_PEEKDATA,.addr = -4}, {
> -	PTRACE_PEEKTEXT,.addr = 0}, {
> -	PTRACE_PEEKTEXT,.addr = 1}, {
> -	PTRACE_PEEKTEXT,.addr = 2}, {
> -	PTRACE_PEEKTEXT,.addr = 3}, {
> -	PTRACE_PEEKTEXT,.addr = -1}, {
> -	PTRACE_PEEKTEXT,.addr = -2}, {
> -	PTRACE_PEEKTEXT,.addr = -3}, {
> -	PTRACE_PEEKTEXT,.addr = -4}, {
> -	PTRACE_PEEKUSER,.addr = SIZEOF_USER + 1}, {
> -	PTRACE_PEEKUSER,.addr = SIZEOF_USER + 2}, {
> -	PTRACE_PEEKUSER,.addr = SIZEOF_USER + 3}, {
> -	PTRACE_PEEKUSER,.addr = SIZEOF_USER + 4}, {
> -	PTRACE_PEEKUSER,.addr = -1}, {
> -	PTRACE_PEEKUSER,.addr = -2}, {
> -	PTRACE_PEEKUSER,.addr = -3}, {
> -	PTRACE_PEEKUSER,.addr = -4}, {
> -	PTRACE_POKEDATA,.addr = 0}, {
> -	PTRACE_POKEDATA,.addr = 1}, {
> -	PTRACE_POKEDATA,.addr = 2}, {
> -	PTRACE_POKEDATA,.addr = 3}, {
> -	PTRACE_POKEDATA,.addr = -1}, {
> -	PTRACE_POKEDATA,.addr = -2}, {
> -	PTRACE_POKEDATA,.addr = -3}, {
> -	PTRACE_POKEDATA,.addr = -4}, {
> -	PTRACE_POKETEXT,.addr = 0}, {
> -	PTRACE_POKETEXT,.addr = 1}, {
> -	PTRACE_POKETEXT,.addr = 2}, {
> -	PTRACE_POKETEXT,.addr = 3}, {
> -	PTRACE_POKETEXT,.addr = -1}, {
> -	PTRACE_POKETEXT,.addr = -2}, {
> -	PTRACE_POKETEXT,.addr = -3}, {
> -	PTRACE_POKETEXT,.addr = -4}, {
> -	PTRACE_POKEUSER,.addr = SIZEOF_USER + 1}, {
> -	PTRACE_POKEUSER,.addr = SIZEOF_USER + 2}, {
> -	PTRACE_POKEUSER,.addr = SIZEOF_USER + 3}, {
> -	PTRACE_POKEUSER,.addr = SIZEOF_USER + 4}, {
> -	PTRACE_POKEUSER,.addr = -1}, {
> -	PTRACE_POKEUSER,.addr = -2}, {
> -	PTRACE_POKEUSER,.addr = -3}, {
> -	PTRACE_POKEUSER,.addr = -4},
> +	PTRACE_PEEKDATA, .addr = 0}, {
> +	PTRACE_PEEKDATA, .addr = 1}, {
> +	PTRACE_PEEKDATA, .addr = 2}, {
> +	PTRACE_PEEKDATA, .addr = 3}, {
> +	PTRACE_PEEKDATA, .addr = -1}, {
> +	PTRACE_PEEKDATA, .addr = -2}, {
> +	PTRACE_PEEKDATA, .addr = -3}, {
> +	PTRACE_PEEKDATA, .addr = -4}, {
> +	PTRACE_PEEKTEXT, .addr = 0}, {
> +	PTRACE_PEEKTEXT, .addr = 1}, {
> +	PTRACE_PEEKTEXT, .addr = 2}, {
> +	PTRACE_PEEKTEXT, .addr = 3}, {
> +	PTRACE_PEEKTEXT, .addr = -1}, {
> +	PTRACE_PEEKTEXT, .addr = -2}, {
> +	PTRACE_PEEKTEXT, .addr = -3}, {
> +	PTRACE_PEEKTEXT, .addr = -4}, {
> +	PTRACE_PEEKUSER, .addr = SIZEOF_USER + 1}, {
> +	PTRACE_PEEKUSER, .addr = SIZEOF_USER + 2}, {
> +	PTRACE_PEEKUSER, .addr = SIZEOF_USER + 3}, {
> +	PTRACE_PEEKUSER, .addr = SIZEOF_USER + 4}, {
> +	PTRACE_PEEKUSER, .addr = -1}, {
> +	PTRACE_PEEKUSER, .addr = -2}, {
> +	PTRACE_PEEKUSER, .addr = -3}, {
> +	PTRACE_PEEKUSER, .addr = -4}, {
> +	PTRACE_POKEDATA, .addr = 0}, {
> +	PTRACE_POKEDATA, .addr = 1}, {
> +	PTRACE_POKEDATA, .addr = 2}, {
> +	PTRACE_POKEDATA, .addr = 3}, {
> +	PTRACE_POKEDATA, .addr = -1}, {
> +	PTRACE_POKEDATA, .addr = -2}, {
> +	PTRACE_POKEDATA, .addr = -3}, {
> +	PTRACE_POKEDATA, .addr = -4}, {
> +	PTRACE_POKETEXT, .addr = 0}, {
> +	PTRACE_POKETEXT, .addr = 1}, {
> +	PTRACE_POKETEXT, .addr = 2}, {
> +	PTRACE_POKETEXT, .addr = 3}, {
> +	PTRACE_POKETEXT, .addr = -1}, {
> +	PTRACE_POKETEXT, .addr = -2}, {
> +	PTRACE_POKETEXT, .addr = -3}, {
> +	PTRACE_POKETEXT, .addr = -4}, {
> +	PTRACE_POKEUSER, .addr = SIZEOF_USER + 1}, {
> +	PTRACE_POKEUSER, .addr = SIZEOF_USER + 2}, {
> +	PTRACE_POKEUSER, .addr = SIZEOF_USER + 3}, {
> +	PTRACE_POKEUSER, .addr = SIZEOF_USER + 4}, {
> +	PTRACE_POKEUSER, .addr = -1}, {
> +	PTRACE_POKEUSER, .addr = -2}, {
> +	PTRACE_POKEUSER, .addr = -3}, {
> +	PTRACE_POKEUSER, .addr = -4},
>  #ifdef PTRACE_GETREGS
>  	{
> -	PTRACE_GETREGS,.data = 0}, {
> -	PTRACE_GETREGS,.data = 1}, {
> -	PTRACE_GETREGS,.data = 2}, {
> -	PTRACE_GETREGS,.data = 3}, {
> -	PTRACE_GETREGS,.data = -1}, {
> -	PTRACE_GETREGS,.data = -2}, {
> -	PTRACE_GETREGS,.data = -3}, {
> -	PTRACE_GETREGS,.data = -4},
> +	PTRACE_GETREGS, .data = 0}, {
> +	PTRACE_GETREGS, .data = 1}, {
> +	PTRACE_GETREGS, .data = 2}, {
> +	PTRACE_GETREGS, .data = 3}, {
> +	PTRACE_GETREGS, .data = -1}, {
> +	PTRACE_GETREGS, .data = -2}, {
> +	PTRACE_GETREGS, .data = -3}, {
> +	PTRACE_GETREGS, .data = -4},
>  #endif
>  #ifdef PTRACE_GETFGREGS
>  	{
> -	PTRACE_GETFGREGS,.data = 0}, {
> -	PTRACE_GETFGREGS,.data = 1}, {
> -	PTRACE_GETFGREGS,.data = 2}, {
> -	PTRACE_GETFGREGS,.data = 3}, {
> -	PTRACE_GETFGREGS,.data = -1}, {
> -	PTRACE_GETFGREGS,.data = -2}, {
> -	PTRACE_GETFGREGS,.data = -3}, {
> -	PTRACE_GETFGREGS,.data = -4},
> +	PTRACE_GETFGREGS, .data = 0}, {
> +	PTRACE_GETFGREGS, .data = 1}, {
> +	PTRACE_GETFGREGS, .data = 2}, {
> +	PTRACE_GETFGREGS, .data = 3}, {
> +	PTRACE_GETFGREGS, .data = -1}, {
> +	PTRACE_GETFGREGS, .data = -2}, {
> +	PTRACE_GETFGREGS, .data = -3}, {
> +	PTRACE_GETFGREGS, .data = -4},
>  #endif
>  #ifdef PTRACE_SETREGS
>  	{
> -	PTRACE_SETREGS,.data = 0}, {
> -	PTRACE_SETREGS,.data = 1}, {
> -	PTRACE_SETREGS,.data = 2}, {
> -	PTRACE_SETREGS,.data = 3}, {
> -	PTRACE_SETREGS,.data = -1}, {
> -	PTRACE_SETREGS,.data = -2}, {
> -	PTRACE_SETREGS,.data = -3}, {
> -	PTRACE_SETREGS,.data = -4},
> +	PTRACE_SETREGS, .data = 0}, {
> +	PTRACE_SETREGS, .data = 1}, {
> +	PTRACE_SETREGS, .data = 2}, {
> +	PTRACE_SETREGS, .data = 3}, {
> +	PTRACE_SETREGS, .data = -1}, {
> +	PTRACE_SETREGS, .data = -2}, {
> +	PTRACE_SETREGS, .data = -3}, {
> +	PTRACE_SETREGS, .data = -4},
>  #endif
>  #ifdef PTRACE_SETFGREGS
>  	{
> -	PTRACE_SETFGREGS,.data = 0}, {
> -	PTRACE_SETFGREGS,.data = 1}, {
> -	PTRACE_SETFGREGS,.data = 2}, {
> -	PTRACE_SETFGREGS,.data = 3}, {
> -	PTRACE_SETFGREGS,.data = -1}, {
> -	PTRACE_SETFGREGS,.data = -2}, {
> -	PTRACE_SETFGREGS,.data = -3}, {
> -	PTRACE_SETFGREGS,.data = -4},
> +	PTRACE_SETFGREGS, .data = 0}, {
> +	PTRACE_SETFGREGS, .data = 1}, {
> +	PTRACE_SETFGREGS, .data = 2}, {
> +	PTRACE_SETFGREGS, .data = 3}, {
> +	PTRACE_SETFGREGS, .data = -1}, {
> +	PTRACE_SETFGREGS, .data = -2}, {
> +	PTRACE_SETFGREGS, .data = -3}, {
> +	PTRACE_SETFGREGS, .data = -4},
>  #endif
>  #if HAVE_DECL_PTRACE_GETSIGINFO
>  	{
> -	PTRACE_GETSIGINFO,.data = 0}, {
> -	PTRACE_GETSIGINFO,.data = 1}, {
> -	PTRACE_GETSIGINFO,.data = 2}, {
> -	PTRACE_GETSIGINFO,.data = 3}, {
> -	PTRACE_GETSIGINFO,.data = -1}, {
> -	PTRACE_GETSIGINFO,.data = -2}, {
> -	PTRACE_GETSIGINFO,.data = -3}, {
> -	PTRACE_GETSIGINFO,.data = -4},
> +	PTRACE_GETSIGINFO, .data = 0}, {
> +	PTRACE_GETSIGINFO, .data = 1}, {
> +	PTRACE_GETSIGINFO, .data = 2}, {
> +	PTRACE_GETSIGINFO, .data = 3}, {
> +	PTRACE_GETSIGINFO, .data = -1}, {
> +	PTRACE_GETSIGINFO, .data = -2}, {
> +	PTRACE_GETSIGINFO, .data = -3}, {
> +	PTRACE_GETSIGINFO, .data = -4},
>  #endif
>  #if HAVE_DECL_PTRACE_SETSIGINFO
>  	{
> -	PTRACE_SETSIGINFO,.data = 0}, {
> -	PTRACE_SETSIGINFO,.data = 1}, {
> -	PTRACE_SETSIGINFO,.data = 2}, {
> -	PTRACE_SETSIGINFO,.data = 3}, {
> -	PTRACE_SETSIGINFO,.data = -1}, {
> -	PTRACE_SETSIGINFO,.data = -2}, {
> -	PTRACE_SETSIGINFO,.data = -3}, {
> -	PTRACE_SETSIGINFO,.data = -4},
> +	PTRACE_SETSIGINFO, .data = 0}, {
> +	PTRACE_SETSIGINFO, .data = 1}, {
> +	PTRACE_SETSIGINFO, .data = 2}, {
> +	PTRACE_SETSIGINFO, .data = 3}, {
> +	PTRACE_SETSIGINFO, .data = -1}, {
> +	PTRACE_SETSIGINFO, .data = -2}, {
> +	PTRACE_SETSIGINFO, .data = -3}, {
> +	PTRACE_SETSIGINFO, .data = -4},
> +#endif
> +};
> +
> +#define SPT(x) [PTRACE_##x] = #x,
> +static char *strings[] = {
> +	SPT(TRACEME)
> +	SPT(PEEKTEXT)
> +	SPT(PEEKDATA)
> +	SPT(PEEKUSER)
> +	SPT(POKETEXT)
> +	SPT(POKEDATA)
> +	SPT(POKEUSER)
> +#ifdef PTRACE_GETREGS
> +	SPT(GETREGS)
> +#endif
> +#ifdef PTRACE_SETREGS
> +	SPT(SETREGS)
> +#endif
> +#ifdef PTRACE_GETSIGINFO
> +	SPT(GETSIGINFO)
> +#endif
> +#ifdef PTRACE_SETSIGINFO
> +	SPT(SETSIGINFO)
> +#endif
> +#ifdef PTRACE_GETFGREGS
> +	SPT(GETFGREGS)
> +#endif
> +#ifdef PTRACE_SETFGREGS
> +	SPT(SETFGREGS)
>  #endif
> +	SPT(KILL)
> +	SPT(SINGLESTEP)
>  };
>  
> -int TST_TOTAL = ARRAY_SIZE(test_cases);
> +static inline char *strptrace(int request)
> +{
> +	return strings[request];
> +}
> +
> +static void child(void)
> +{
> +	SAFE_PTRACE(PTRACE_TRACEME, 0, NULL, NULL);
> +	execl("/bin/echo", "/bin/echo", NULL);

This isn't guaranteed to exist.

-- 
Thank you,
Richard.

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

  reply	other threads:[~2023-11-28 10:03 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-25 11:22 [LTP] [PATCH v1 0/2] ptrace: Refactor Wei Gao via ltp
2023-09-25 11:22 ` [LTP] [PATCH v1 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2023-11-28  8:57   ` Richard Palethorpe
2023-11-28  9:24   ` Petr Vorel
2023-09-25 11:22 ` [LTP] [PATCH v1 2/2] ptrace06: " Wei Gao via ltp
2023-11-28  9:31   ` Richard Palethorpe [this message]
2023-11-28  9:51   ` Petr Vorel
2023-12-01  1:06     ` Wei Gao via ltp
2023-12-01  0:59 ` [LTP] [PATCH v2 0/2] ptrace: Refactor Wei Gao via ltp
2023-12-01  0:59   ` [LTP] [PATCH v2 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2024-02-08 16:15     ` Andrea Cervesato via ltp
2023-12-01  0:59   ` [LTP] [PATCH v2 2/2] ptrace06: " Wei Gao via ltp
2024-02-08 16:25     ` Andrea Cervesato via ltp
2024-06-03 10:35   ` [LTP] [PATCH v3 0/2] ptrace: Refactor Wei Gao via ltp
2024-06-03 10:35     ` [LTP] [PATCH v3 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2024-06-28 15:35       ` Cyril Hrubis
2024-06-03 10:35     ` [LTP] [PATCH v3 2/2] ptrace06: " Wei Gao via ltp
2024-06-28 16:15       ` Cyril Hrubis
2024-12-17  6:16     ` [LTP] [PATCH v4 0/2] ptrace: Refactor Wei Gao via ltp
2024-12-17  6:16       ` [LTP] [PATCH v4 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2025-01-08 13:39         ` Petr Vorel
2024-12-17  6:16       ` [LTP] [PATCH v4 2/2] ptrace06: " Wei Gao via ltp
2025-01-09  8:55         ` Petr Vorel
2025-01-13  8:16       ` [LTP] [PATCH v5 0/2] ptrace: Refactor Wei Gao via ltp
2025-01-13  8:16         ` [LTP] [PATCH v5 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2025-01-13 16:02           ` Cyril Hrubis
2025-01-13 21:40             ` Petr Vorel
2025-01-14  9:25               ` Cyril Hrubis
2025-01-13  8:16         ` [LTP] [PATCH v5 2/2] ptrace06: " Wei Gao via ltp
2025-01-14 12:40         ` [LTP] [PATCH v6 0/2] ptrace: Refactor Wei Gao via ltp
2025-01-14 12:40           ` [LTP] [PATCH v6 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2025-01-14 13:05             ` Cyril Hrubis
2025-01-14 12:40           ` [LTP] [PATCH v6 2/2] ptrace06: " Wei Gao via ltp
2025-01-14 14:32           ` [LTP] [PATCH v7 0/2] ptrace: Refactor Wei Gao via ltp
2025-01-14 14:32             ` [LTP] [PATCH v7 1/2] ptrace05: Refactor the test using new LTP API Wei Gao via ltp
2025-01-16 16:44               ` Cyril Hrubis
2025-01-14 14:32             ` [LTP] [PATCH v7 2/2] ptrace06: " Wei Gao via ltp
2025-01-16 16:50               ` Cyril Hrubis
2025-01-17 10:40               ` Petr Vorel
2025-01-17 10:42                 ` Cyril Hrubis
2025-01-17 11:12                   ` Petr Vorel
2025-01-20  4:14             ` [LTP] [PATCH v8 0/2] ptrace: Refactor Wei Gao via ltp
2025-01-20  4:14               ` [LTP] [PATCH v8 1/2] ptrace06: Refactor the test using new LTP API Wei Gao via ltp
2025-01-20 13:35                 ` Petr Vorel
2025-01-20  4:14               ` [LTP] [PATCH v8 2/2] ptrace06_child.c: Remove unused ptrace06_child.c Wei Gao via ltp

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=87v89m6vq6.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=ltp@lists.linux.it \
    --cc=wegao@suse.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.