All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Palethorpe <rpalethorpe@suse.de>
To: Cyril Hrubis <chrubis@suse.cz>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH] waitid10: Fix when coredumps are piped
Date: Mon, 21 Mar 2022 15:17:55 +0000	[thread overview]
Message-ID: <87ils7corb.fsf@suse.de> (raw)
In-Reply-To: <20220321133849.14924-1-chrubis@suse.cz>

Hello

Cyril Hrubis <chrubis@suse.cz> writes:

> When coredumps are piped into a stdin of a program (the core_pattern
> starts with '|') the RLIMIT_CORE limits are not enforced.
>
> This fixes the test expectation in the corner case that rlim_cur and
> rlim_max for RLIMIT_CORE are both set to 0 but the core pattern is set
> to dump core into a pipe where we previously assumed the core wouldn't
> be dumped.
>
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> ---
>  testcases/kernel/syscalls/waitid/waitid10.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/testcases/kernel/syscalls/waitid/waitid10.c b/testcases/kernel/syscalls/waitid/waitid10.c
> index 869ef18bd..e75edd07e 100644
> --- a/testcases/kernel/syscalls/waitid/waitid10.c
> +++ b/testcases/kernel/syscalls/waitid/waitid10.c
> @@ -45,14 +45,17 @@ static void run(void)
>  static void setup(void)
>  {
>  	struct rlimit rlim;
> +	char c;
>  
>  	SAFE_GETRLIMIT(RLIMIT_CORE, &rlim);
> +	SAFE_FILE_SCANF("/proc/sys/kernel/core_pattern", "%c", &c);
>  
>  	if (rlim.rlim_cur)
>  		return;
>  
>  	if (!rlim.rlim_max) {
> -		core_dumps = 0;
> +		if (c != '|')
> +			core_dumps = 0;
>  		return;
>  	}
>  
> -- 
> 2.34.1

Reviewed-by: Richard Palethorpe <rpalethorpe@suse.com>

BTW I thought that division by zero actually just resulted in zero or
INT_MAX on some platforms? (e.g. ARM)

It's undefined behaviour, so I fail to see how this test has ever worked
on some architectures. Perhaps we should dereference a null/invalid
pointer instead?


-- 
Thank you,
Richard.

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

  reply	other threads:[~2022-03-21 15:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-21 13:38 [LTP] [PATCH] waitid10: Fix when coredumps are piped Cyril Hrubis
2022-03-21 15:17 ` Richard Palethorpe [this message]
2022-03-21 15:29   ` Cyril Hrubis
2022-03-22 12:21   ` Cyril Hrubis

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=87ils7corb.fsf@suse.de \
    --to=rpalethorpe@suse.de \
    --cc=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 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.