public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: Andrea Cervesato <andrea.cervesato@suse.de>
Cc: Linux Test Project <ltp@lists.linux.it>
Subject: Re: [LTP] [PATCH v2 4/5] syscalls: add listns01 test for EFAULT on invalid address
Date: Fri, 20 Mar 2026 11:39:47 +0100	[thread overview]
Message-ID: <ab0j8yh0a8IlT5Oc@yuki.lan> (raw)
In-Reply-To: <20260313-listns-v2-4-38384fae9b1f@suse.com>

Hi!
> +++ b/testcases/kernel/syscalls/listns/listns01.c
> @@ -0,0 +1,56 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2026 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
> + */
> +
> +/*\
> + * Test listns() EFAULT error handling with invalid buffer pointers.
> + *
> + * Verify that listns() returns EFAULT when given a completely invalid
> + * address or a NULL pointer as the output buffer.
> + */
> +
> +#define _GNU_SOURCE
> +
> +#include "tst_test.h"
> +#include "lapi/syscalls.h"
> +#include "lapi/listns.h"
> +
> +static struct tcase {
> +	const char *desc;
> +	uintptr_t bad_ptr_val;
> +	size_t nr_ids;
> +} tcases[] = {
> +	{
> +		.desc = "completely invalid pointer",
                            ^
			    Just "invalid pointer"

Keep messages short and to the point.

> +		.bad_ptr_val = 0xdeadbeef,

We do have a tst_get_bad_addr() function to generate an address that is
100% sure to be invalid on any platform.

> +		.nr_ids = 10,

This is the same for bot cases, no need to put it into the struct.

> +	},
> +	{
> +		.desc = "NULL buffer",
> +		.bad_ptr_val = 0,
> +		.nr_ids = 10,
> +	},
> +};
> +
> +static void verify_listns(unsigned int n)
> +{
> +	struct tcase *tc = &tcases[n];
> +	struct listns_req req = { .size = NS_ID_REQ_SIZE_VER0 };
> +
> +	TST_EXP_FAIL2(listns(&req, (uint64_t *)tc->bad_ptr_val, tc->nr_ids, 0),
> +		      EFAULT, "listns() %s", tc->desc);
> +}
> +
> +static void setup(void)
> +{
> +	struct listns_req req = { .size = NS_ID_REQ_SIZE_VER0 };
> +
> +	tst_syscall(__NR_listns, &req, NULL, 0, 0);
> +}
> +
> +static struct tst_test test = {
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.test = verify_listns,
> +	.setup = setup,
> +};
> 
> -- 
> 2.51.0
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

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

  reply	other threads:[~2026-03-20 10:40 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-13 11:48 [LTP] [PATCH v2 0/5] listns() testing suite Andrea Cervesato
2026-03-13 11:48 ` [LTP] [PATCH v2 1/5] Update architectures syscalls identifiers Andrea Cervesato
2026-03-20 10:28   ` Cyril Hrubis
2026-03-20 13:21     ` Andrea Cervesato via ltp
2026-03-13 11:48 ` [LTP] [PATCH v2 2/5] Add listns fallback header Andrea Cervesato
2026-03-20 10:35   ` Cyril Hrubis
2026-03-20 13:34     ` Andrea Cervesato via ltp
2026-03-23 10:16       ` Cyril Hrubis
2026-03-24 14:49         ` Andrea Cervesato via ltp
2026-03-13 11:48 ` [LTP] [PATCH v2 3/5] Add NS_GET_ID fallback Andrea Cervesato
2026-03-20 10:36   ` Cyril Hrubis
2026-03-13 11:48 ` [LTP] [PATCH v2 4/5] syscalls: add listns01 test for EFAULT on invalid address Andrea Cervesato
2026-03-20 10:39   ` Cyril Hrubis [this message]
2026-03-13 11:48 ` [LTP] [PATCH v2 5/5] syscalls: add listns02 functionality test Andrea Cervesato
2026-03-20 11:19   ` 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=ab0j8yh0a8IlT5Oc@yuki.lan \
    --to=chrubis@suse.cz \
    --cc=andrea.cervesato@suse.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox