From: Kees Cook <kees@kernel.org>
To: Bill Wendling <morbo@google.com>
Cc: codemender-patching+linux@google.com,
Alexander Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH 2/2] vfs: Add KUnit tests for fdtable
Date: Mon, 10 Aug 2026 17:16:26 -0700 [thread overview]
Message-ID: <202608101713.34DEA00E9D@keescook> (raw)
In-Reply-To: <20260810204118.1981755-3-morbo@google.com>
On Mon, Aug 10, 2026 at 08:41:13PM +0000, Bill Wendling wrote:
> +static void fdtable_test_alloc(struct kunit *test)
> +{
> + struct fdtable *fdt;
> + unsigned int slots = 64;
> +
> + fdt = alloc_fdtable(slots);
> + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, fdt);
> +
> + /* Check that max_fds is set correctly and is >= slots */
> + KUNIT_EXPECT_GE(test, fdt->max_fds, slots);
> +
> + /* Check that fd is allocated */
> + KUNIT_EXPECT_NOT_ERR_OR_NULL(test, fdt->fd);
Nice to add these tests! Can you add one for each of the conditionals
in alloc_fdtable (e.g. ENOMEM, EMFILE, and the power-of-two rounding-up
logic, etc)?
-Kees
--
Kees Cook
prev parent reply other threads:[~2026-08-11 0:16 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260810204118.1981755-1-morbo@google.com>
2026-08-10 20:41 ` [PATCH 1/2] vfs: Annotate struct fdtable's fd field with __counted_by_ptr Bill Wendling
2026-08-11 0:18 ` Kees Cook
2026-08-10 20:41 ` [PATCH 2/2] vfs: Add KUnit tests for fdtable Bill Wendling
2026-08-11 0:16 ` Kees Cook [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=202608101713.34DEA00E9D@keescook \
--to=kees@kernel.org \
--cc=brauner@kernel.org \
--cc=codemender-patching+linux@google.com \
--cc=gustavoars@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=morbo@google.com \
--cc=viro@zeniv.linux.org.uk \
/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