mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pratyush Yadav <pratyush@kernel.org>
To: Chris Down <chris@chrisdown.name>
Cc: Pasha Tatashin <pasha.tatashin@soleen.com>,
	 Mike Rapoport <rppt@kernel.org>,
	 Pratyush Yadav <pratyush@kernel.org>,
	 Shuah Khan <shuah@kernel.org>,
	 Shuah Khan <skhan@linuxfoundation.org>,
	linux-kselftest@vger.kernel.org,  kexec@lists.infradead.org,
	linux-kernel@vger.kernel.org,  linux-api@vger.kernel.org
Subject: Re: [PATCH 2/2] selftests/liveupdate: Test ENOTTY for unknown ioctl numbers
Date: Wed, 02 Dec 2026 10:45:38 +0000	[thread overview]
Message-ID: <2vxzqzg0ufjh.fsf@kernel.org> (raw)
In-Reply-To: <77e3a5054b47829fd1ad103cef19fb57d93fd570.1796194107.git.chris@chrisdown.name> (Chris Down's message of "Tue, 01 Dec 2026 22:53:46 -0800")

On Tue, Dec 01 2026, Chris Down wrote:

> Check that command numbers outside the ioctl tables of /dev/liveupdate
> and of a session fd fail with ENOTTY, not EINVAL.
>
> Signed-off-by: Chris Down <chris@chrisdown.name>
> ---
>  .../testing/selftests/liveupdate/liveupdate.c | 35 +++++++++++++++++++
>  1 file changed, 35 insertions(+)
>
> diff --git a/tools/testing/selftests/liveupdate/liveupdate.c b/tools/testing/selftests/liveupdate/liveupdate.c
> index 2dedd5fc2534..8df62fda4710 100644
> --- a/tools/testing/selftests/liveupdate/liveupdate.c
> +++ b/tools/testing/selftests/liveupdate/liveupdate.c
> @@ -530,4 +530,39 @@ TEST_F(liveupdate_device, preserve_many_files)
>  	ASSERT_EQ(close(session_fd), 0);
>  }
>  
> +/*
> + * Test Case: Unknown IOCTL Numbers
> + *
> + * Verifies that command numbers outside the ioctl tables of /dev/liveupdate
> + * and of a session fd fail with ENOTTY, not EINVAL, which is reserved for a
> + * known command with a bad argument.
> + */
> +TEST_F(liveupdate_device, unknown_ioctl_number)
> +{
> +	char buf[64] = {};
> +	int session_fd;
> +
> +	self->fd1 = open(LIVEUPDATE_DEV, O_RDWR);
> +	if (self->fd1 < 0 && errno == ENOENT)
> +		SKIP(return, "%s does not exist", LIVEUPDATE_DEV);
> +	ASSERT_GE(self->fd1, 0);
> +
> +	session_fd = luo_create_session(self->fd1, "unknown-ioctl-test");
> +	ASSERT_GE(session_fd, 0);
> +
> +	EXPECT_LT(ioctl(self->fd1, _IO(LIVEUPDATE_IOCTL_TYPE, 0x3f), buf), 0);
> +	EXPECT_EQ(errno, ENOTTY);
> +	EXPECT_LT(ioctl(self->fd1, _IO(LIVEUPDATE_IOCTL_TYPE, 0xff), buf), 0);
> +	EXPECT_EQ(errno, ENOTTY);

Why 0x3f and 0xff? I assume you use this because
LIVEUPDATE_CMD_SESSION_BASE is 0x40, so you want to test for a command
before and after the base. This makes sense for a session FD, but for
/dev/liveupdate, LIVEUPDATE_CMD_BASE is 0x00, so both 0x3f and 0xff
would test for the same condition, right?

Also, please give these numbers a name. Otherwise we will forget why
these were used in the first place.

> +
> +	EXPECT_LT(ioctl(session_fd, TCGETS, buf), 0);
> +	EXPECT_EQ(errno, ENOTTY);
> +	EXPECT_LT(ioctl(session_fd, _IO(LIVEUPDATE_IOCTL_TYPE, 0x3f), buf), 0);
> +	EXPECT_EQ(errno, ENOTTY);
> +	EXPECT_LT(ioctl(session_fd, _IO(LIVEUPDATE_IOCTL_TYPE, 0xff), buf), 0);
> +	EXPECT_EQ(errno, ENOTTY);
> +
> +	ASSERT_EQ(close(session_fd), 0);
> +}
> +
>  TEST_HARNESS_MAIN

-- 
Regards,
Pratyush Yadav

      reply	other threads:[~2026-12-02 10:45 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  6:53 [PATCH 0/2] liveupdate: Return -ENOTTY " Chris Down
2026-12-02  6:53 ` [PATCH 1/2] " Chris Down
2026-12-02 10:16   ` Pratyush Yadav
2026-12-02  6:53 ` [PATCH 2/2] selftests/liveupdate: Test ENOTTY " Chris Down
2026-12-02 10:45   ` Pratyush Yadav [this message]

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=2vxzqzg0ufjh.fsf@kernel.org \
    --to=pratyush@kernel.org \
    --cc=chris@chrisdown.name \
    --cc=kexec@lists.infradead.org \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=pasha.tatashin@soleen.com \
    --cc=rppt@kernel.org \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    /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

all inboxes | Powered by JetHome®