public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Xi Ruoyao <xry111@xry111.site>, lixing <lixing@loongson.cn>,
	Carlos O'Donell <carlos@redhat.com>,
	Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	Peng Fan <fanpeng@loongson.cn>
Cc: "libc-alpha@sourceware.org" <libc-alpha@sourceware.org>,
	ltp@lists.linux.it
Subject: Re: [PATCH] Increase judgment on buf.
Date: Sun, 21 May 2023 01:19:28 -0700	[thread overview]
Message-ID: <1c688849-f992-029e-30e8-8990c311c8a3@cs.ucla.edu> (raw)
In-Reply-To: <0cb83efa85ae32d956f81e6b9d4966c38fd54bcb.camel@xry111.site>

[-- Attachment #1: Type: text/plain, Size: 513 bytes --]

On 2023-05-20 03:19, Xi Ruoyao via Libc-alpha wrote:
> If a LTP test relies on a EFAULT here, then LTP has a bug.  You should
> tell LTP to fix it then.

LTP fstat03 allows either EFAULT or SIGSEGV, but no other behavior, when 
'stat' is passed a null pointer.

Therefore that test is too strict for POSIX, as the POSIX behavior is 
undefined.

It's also too strict for GNU/Linux, because it insists on SIGSEGV 
whereas any terminating signal will do (e.g., SIGABRT).

Proposed LTP patch attached.

[-- Attachment #2: 0001-fstat03-wrongly-required-SIGSEGV.patch --]
[-- Type: text/x-patch, Size: 1490 bytes --]

From 8a2b3f75d2b61e5e4ec0a2c93f3db62584daf1cd Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Sun, 21 May 2023 01:15:40 -0700
Subject: [PATCH] fstat03 wrongly required SIGSEGV

Change fstat03 to allow the syscall to signal SIGABRT (or any other
signal) instead of SIGSEGV when a null pointer is passed, as POSIX
says behavior is undefined and the glibc behavior (which is a bit
better defined) could be any signal, not necessarily SIGSEGV.

Signed-off-by: Paul Eggert <eggert@cs.ucla.edu>
---
 testcases/kernel/syscalls/fstat/fstat03.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/fstat/fstat03.c b/testcases/kernel/syscalls/fstat/fstat03.c
index 4ff37e882..a400692e9 100644
--- a/testcases/kernel/syscalls/fstat/fstat03.c
+++ b/testcases/kernel/syscalls/fstat/fstat03.c
@@ -10,7 +10,7 @@
  * 1) Calls fstat() with closed file descriptor
  *    -> EBADF
  * 2) Calls fstat() with an invalid address for stat structure
- *    -> EFAULT (or receive signal SIGSEGV)
+ *    -> EFAULT (or receive signal)
  */
 
 #include <errno.h>
@@ -70,8 +70,8 @@ static void run(unsigned int tc_num)
 	}
 	SAFE_WAITPID(pid, &status, 0);
 
-	if (tcases[tc_num].exp_err == EFAULT && WTERMSIG(status) == SIGSEGV) {
-		tst_res(TPASS, "fstat() failed as expected with SIGSEGV");
+	if (tcases[tc_num].exp_err == EFAULT && WIFSIGNALED(status)) {
+		tst_res(TPASS, "fstat() failed as expected with a signal");
 		return;
 	}
 
-- 
2.39.2


  reply	other threads:[~2023-05-21  8:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <lxnjka-9sevacf455zj-1fthj246gvr4-712jsi8w59t4969pqyxmxkaq-l3n4z6dp0ybpuvpiuudtnfot-dl7onwkii2tq8gtprte6cu4fgip6f-ikuh33-a5p9ixcl44cx2h7mimcgl3xt-13bjom.1684553069255@email.android.com>
2023-05-20 10:19 ` Xi Ruoyao
2023-05-21  8:19   ` Paul Eggert [this message]
2023-05-21  8:27     ` Andreas Schwab
2023-05-21  8:44       ` Paul Eggert
2023-05-21  9:05         ` Andreas Schwab
2023-05-19  3:57 Peng Fan
2023-05-19 11:48 ` Adhemerval Zanella Netto
2023-05-19 11:55   ` Carlos O'Donell
2023-05-20  0:29     ` lixing

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=1c688849-f992-029e-30e8-8990c311c8a3@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=adhemerval.zanella@linaro.org \
    --cc=carlos@redhat.com \
    --cc=fanpeng@loongson.cn \
    --cc=libc-alpha@sourceware.org \
    --cc=lixing@loongson.cn \
    --cc=ltp@lists.linux.it \
    --cc=xry111@xry111.site \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).