public inbox for ltp@lists.linux.it
 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] getcwd01: Only check buffer NULL on glibc
Date: Thu, 28 Sep 2023 08:06:09 +0100	[thread overview]
Message-ID: <87lecqeolk.fsf@suse.de> (raw)
In-Reply-To: <20230928010808.15862-1-wegao@suse.com>

Hello,

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

> Signed-off-by: Wei Gao <wegao@suse.com>
> ---

Need to mention the github issue in the commit
https://github.com/linux-test-project/ltp/issues/1084

>  testcases/kernel/syscalls/getcwd/getcwd01.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/getcwd/getcwd01.c b/testcases/kernel/syscalls/getcwd/getcwd01.c
> index 65d827873..6769eb6f4 100644
> --- a/testcases/kernel/syscalls/getcwd/getcwd01.c
> +++ b/testcases/kernel/syscalls/getcwd/getcwd01.c
> @@ -34,10 +34,13 @@ static struct t_case {
>  	int exp_err;
>  } tcases[] = {
>  	{(void *)-1, PATH_MAX, EFAULT},
> -	{NULL, (size_t)-1, ENOMEM},
>  	{buffer, 0, EINVAL},
>  	{buffer, 1, ERANGE},
> +/* musl and uclibc-ng will allocate memory before syscall if buf == NULL */
> +#ifdef __GLIBC__
> +	{NULL, (size_t)-1, ENOMEM},

I'd prefer a more general solution. There are a lot of failures like
this. I've seen a lot in the past in glibc where it changed its
behaviour.

Most of these failures follow the same pattern:
pass an invalid argument -> expect a particular kernel error code.

Two things go wrong:
1. libc does something with the invalid value
   a. performs some extended behaviour (like above)
   b. segfaults
2. kernel returns an unexpected error code because the value or context
   are invalid in multiple ways.

For 1. we can usually call the system call directly. This solution has
       been used before. It works for most syscalls except ones like clone.

For 2. Beyond reporting these errors I'm just going to ignore tests like this.

>  	{NULL, 1, ERANGE}
> +#endif
>  };
>  
>  static void verify_getcwd(unsigned int n)
> -- 
> 2.35.3


-- 
Thank you,
Richard.

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

  reply	other threads:[~2023-09-28  7:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-28  1:08 [LTP] [PATCH v1] getcwd01: Only check buffer NULL on glibc Wei Gao via ltp
2023-09-28  7:06 ` Richard Palethorpe [this message]
2023-09-28  8:44 ` [LTP] [PATCH v2] getcwd01: Use syscall directly check invalid argument Wei Gao via ltp
2023-09-28 17:55   ` Petr Vorel
2023-09-29  0:49     ` Wei Gao via ltp
2023-09-29  0:45   ` [LTP] [PATCH v3] " Wei Gao via ltp
2023-11-28 10:52     ` Petr Vorel
2023-12-01  3:52       ` Wei Gao via ltp
2023-11-28 10:53     ` Petr Vorel
2023-12-01  3:15     ` [LTP] [PATCH v4] " Wei Gao via ltp
2023-12-01 10:14       ` Petr Vorel
2023-12-04  0:06         ` 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=87lecqeolk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox