All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.com>
Cc: ltp@lists.linux.it
Subject: Re: [LTP] [PATCH v1] mseal02: Handle multiple errnos for 32-bit compat mode
Date: Thu, 19 Feb 2026 12:37:46 +0100	[thread overview]
Message-ID: <aZb2CpwcJnK1LBrM@yuki.lan> (raw)
In-Reply-To: <DGI4KQCXESV5.5PGMWF4DXPA3@suse.com>

Hi!
> > In 32-bit compat mode, the overflow_size (calculated using a 32-bit ULONG_MAX)
> > does not cause a 64-bit integer wrap-around when added to the start address.
> > Consequently, the kernel see valid range that points to unmapped space, returning
> > ENOMEM instead of the expected EINVAL.
> >
> > Signed-off-by: Wei Gao <wegao@suse.com>
> > ---
> >  testcases/kernel/syscalls/mseal/mseal02.c | 20 +++++++++++---------
> >  1 file changed, 11 insertions(+), 9 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/mseal/mseal02.c b/testcases/kernel/syscalls/mseal/mseal02.c
> > index e11d7dbf4..d941f6c40 100644
> > --- a/testcases/kernel/syscalls/mseal/mseal02.c
> > +++ b/testcases/kernel/syscalls/mseal/mseal02.c
> > @@ -21,6 +21,8 @@
> >  #include "tst_test.h"
> >  #include "lapi/syscalls.h"
> >  
> > +#define MAX_ERRNOS 5
> > +
> >  static void *start_addr, *unaligned_start_addr, *unallocated_start_addr, *unallocated_end_addr;
> >  static size_t page_size, twopages_size, fourpages_size, overflow_size;
> >  
> > @@ -28,22 +30,22 @@ static struct tcase {
> >  	void **addr;
> >  	size_t *len;
> >  	unsigned long flags;
> > -	int exp_err;
> > +	int exp_errs[MAX_ERRNOS];
> >  } tcases[] = {
> > -	{&start_addr, &page_size, ULONG_MAX, EINVAL},
> > -	{&unaligned_start_addr, &page_size, 0, EINVAL},
> > -	{&start_addr, &overflow_size, 0, EINVAL},
> > -	{&unallocated_start_addr, &twopages_size, 0, ENOMEM},
> > -	{&unallocated_end_addr, &twopages_size, 0, ENOMEM},
> > -	{&start_addr, &fourpages_size, 0, ENOMEM},
> > +	{&start_addr, &page_size, ULONG_MAX, {EINVAL}},
> > +	{&unaligned_start_addr, &page_size, 0, {EINVAL}},
> > +	{&start_addr, &overflow_size, 0, {EINVAL, ENOMEM}},
> > +	{&unallocated_start_addr, &twopages_size, 0, {ENOMEM}},
> > +	{&unallocated_end_addr, &twopages_size, 0, {ENOMEM}},
> > +	{&start_addr, &fourpages_size, 0, {ENOMEM}},
> >  };
> >  
> >  static void run(unsigned int n)
> >  {
> >  	struct tcase *tc = &tcases[n];
> >  
> > -	TST_EXP_FAIL(tst_syscall(__NR_mseal, *tc->addr, *tc->len, tc->flags), tc->exp_err,
> > -		"mseal(%p, %lu, %lu)", *tc->addr, *tc->len, tc->flags);
> > +	TST_EXP_FAIL2_ARR(tst_syscall(__NR_mseal, *tc->addr, *tc->len, tc->flags),
> > +		tc->exp_errs, MAX_ERRNOS, "mseal(%p, %lu, %lu)", *tc->addr, *tc->len, tc->flags);
> >  }
> >  
> >  static void setup(void)
> 
> Instead of checking multiple errno, you should pass the right type
> according to the architecture.

That would be slightly more complex here since the problem happens only
in compat mode, which can be only detected at runtime with
tst_is_compat_mode(). We would have to call that in the test setup and
adjust expectations accordinlgy.

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2026-02-19 11:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-28  0:28 [LTP] [PATCH v1] mseal02: Handle multiple errnos for 32-bit compat mode Wei Gao via ltp
2026-02-18 13:34 ` Andrea Cervesato via ltp
2026-02-19 11:37   ` Cyril Hrubis [this message]
2026-02-26  2:25 ` [LTP] [PATCH v2] " Wei Gao via ltp
2026-03-20 14:35   ` Andrea Cervesato via ltp
2026-03-20 15:09   ` Petr Vorel
2026-03-20 17:27     ` Petr Vorel
2026-03-23  6:08   ` [LTP] [PATCH v3] " Wei Gao via ltp
2026-03-23 13:14     ` Cyril Hrubis
2026-03-26 10:07     ` Andrea Cervesato via ltp
2026-03-26 10:08     ` Andrea Cervesato via ltp
2026-03-26 10:43     ` Petr Vorel

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=aZb2CpwcJnK1LBrM@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=andrea.cervesato@suse.com \
    --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.