[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202406101209.1B76564DC@keescook>
Date: Mon, 10 Jun 2024 12:11:11 -0700
From: Kees Cook <kees@...nel.org>
To: Ivan Orlov <ivan.orlov0322@...il.com>
Cc: Mark Rutland <mark.rutland@....com>,
Vitor Massaru Iha <vitor@...saru.org>,
Brendan Higgins <brendan.higgins@...ux.dev>,
David Gow <davidgow@...gle.com>, Rae Moar <rmoar@...gle.com>,
"Gustavo A. R. Silva" <gustavoars@...nel.org>,
linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
kunit-dev@...glegroups.com, linux-hardening@...r.kernel.org
Subject: Re: [PATCH 2/2] usercopy: Convert test_user_copy to KUnit test
On Wed, May 29, 2024 at 01:17:35PM +0100, Ivan Orlov wrote:
> On 5/19/24 20:12, Kees Cook wrote:
> > #define test(condition, msg, ...) \
> > ({ \
> > int cond = (condition); \
> > if (cond) \
> > - pr_warn("[%d] " msg "\n", __LINE__, ##__VA_ARGS__); \
> > + KUNIT_EXPECT_FALSE_MSG(test, cond, msg, ##__VA_ARGS__); \
> > cond; \
> > })
> It looks like the 'test' macro is not used anymore, so probably it should be
> removed.
Oops, yes. Thanks!
> > +static int usercopy_test_init(struct kunit *test)
> > +{
> > + struct usercopy_test_priv *priv;
> > + unsigned long user_addr;
> > - if (ret == 0) {
> > - pr_info("tests passed.\n");
> > - return 0;
> > - }
> > + priv = kunit_kzalloc(test, sizeof(*priv), GFP_KERNEL);
> > + if (!priv)
> > + return -ENOMEM;
>
> Should the check be done with KUNIT_ASSERT_NOT_ERR_OR_NULL here as well, as
> it is done with priv->kmem?
Yes, that's much more idiomatic. I'll adjust this too.
> Other than that,
>
> Tested-by: Ivan Orlov <ivan.orlov0322@...il.com>
Thanks!
--
Kees Cook
Powered by blists - more mailing lists