From: Chris Down <chris@chrisdown.name>
To: Pasha Tatashin <pasha.tatashin@soleen.com>,
Mike Rapoport <rppt@kernel.org>,
Pratyush Yadav <pratyush@kernel.org>
Cc: 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: [PATCH 2/2] selftests/liveupdate: Test ENOTTY for unknown ioctl numbers
Date: Tue, 01 Dec 2026 22:53:46 -0800 [thread overview]
Message-ID: <77e3a5054b47829fd1ad103cef19fb57d93fd570.1796194107.git.chris@chrisdown.name> (raw)
In-Reply-To: <cover.1796194107.git.chris@chrisdown.name>
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);
+
+ 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
--
2.56.1
prev parent reply other threads:[~2026-12-02 6:53 UTC|newest]
Thread overview: 3+ 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 6:53 ` Chris Down [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=77e3a5054b47829fd1ad103cef19fb57d93fd570.1796194107.git.chris@chrisdown.name \
--to=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=pratyush@kernel.org \
--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®