From: Brendan Higgins <brendanhiggins@google.com>
To: Kees Cook <keescook@chromium.org>
Cc: Iurii Zaikin <yzaikin@google.com>, shuah <shuah@kernel.org>,
John Johansen <john.johansen@canonical.com>,
jmorris@namei.org, serge@hallyn.com,
Alan Maguire <alan.maguire@oracle.com>,
David Gow <davidgow@google.com>,
Luis Chamberlain <mcgrof@kernel.org>,
"Theodore Ts'o" <tytso@mit.edu>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-security-module@vger.kernel.org,
KUnit Development <kunit-dev@googlegroups.com>,
"open list:KERNEL SELFTEST FRAMEWORK"
<linux-kselftest@vger.kernel.org>,
Mike Salvatore <mike.salvatore@canonical.com>
Subject: Re: [PATCH linux-kselftest/test v1] apparmor: add AppArmor KUnit tests for policy unpack
Date: Tue, 5 Nov 2019 16:37:16 -0800 [thread overview]
Message-ID: <CAFd5g47Qn7ESPLvm9t_ifGPhjJ9dXgV9KVObg64bN3UNnoQPdA@mail.gmail.com> (raw)
In-Reply-To: <CAFd5g47gfEJqRUW1PR1rtgrzekwLVqRRw0iJ4EVRW4xzUiW2Yw@mail.gmail.com>
On Tue, Nov 5, 2019 at 4:35 PM Brendan Higgins
<brendanhiggins@google.com> wrote:
>
> On Wed, Oct 30, 2019 at 11:59 AM Kees Cook <keescook@chromium.org> wrote:
> >
> > On Thu, Oct 17, 2019 at 05:33:56PM -0700, Iurii Zaikin wrote:
> > > On Thu, Oct 17, 2019 at 5:19 PM Brendan Higgins
> > > <brendanhiggins@google.com> wrote:
> > >
> > > > +config SECURITY_APPARMOR_TEST
> > > > + bool "Build KUnit tests for policy_unpack.c"
> > > > + default n
> >
> > New options already already default n, this can be left off.
> >
> > > > + depends on KUNIT && SECURITY_APPARMOR
> > > > + help
> > > >
> > > select SECURITY_APPARMOR ?
> >
> > "select" doesn't enforce dependencies, so just a "depends ..." is
> > correct.
> >
> > > > + KUNIT_EXPECT_EQ(test, size, TEST_BLOB_DATA_SIZE);
> > > > + KUNIT_EXPECT_TRUE(test,
> > > > + memcmp(blob, TEST_BLOB_DATA, TEST_BLOB_DATA_SIZE) == 0);
> > > I think this must be KUNIT_ASSERT_EQ(test, size, TEST_BLOB_DATA_SIZE);,
> > > otherwise there could be a buffer overflow in memcmp. All tests that
> > > follow such pattern
> >
> > Agreed.
> >
> > > are suspect. Also, not sure about your stylistic preference for
> > > KUNIT_EXPECT_TRUE(test,
> > > memcmp(blob, TEST_BLOB_DATA, TEST_BLOB_DATA_SIZE) == 0);
> > > vs
> > > KUNIT_EXPECT_EQ(test,
> > > 0,
> > > memcmp(blob, TEST_BLOB_DATA, TEST_BLOB_DATA_SIZE));
> >
> > I like == 0.
>
> Oh, I almost missed this. I think the *_EQ(...) is better than the
> *_TRUE(...) because the EQ is able to provide more debug information
> if the test fails (otherwise there would really be no point in
> providing all these variants).
>
> Any objections?
>
> Thanks for the catch Iurii!
Wait, nevermind.
Either way is fine because memcmp probably won't show terribly
interesting information in the non-zero case. I'll just leave it the
way Mike wrote it.
Sorry!
next prev parent reply other threads:[~2019-11-06 0:37 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-18 0:18 [PATCH linux-kselftest/test v1] apparmor: add AppArmor KUnit tests for policy unpack Brendan Higgins
2019-10-18 0:33 ` Iurii Zaikin
2019-10-30 18:59 ` Kees Cook
2019-11-06 0:35 ` Brendan Higgins
2019-11-06 0:37 ` Brendan Higgins [this message]
2019-10-18 0:43 ` Brendan Higgins
2019-10-18 16:25 ` Theodore Y. Ts'o
2019-10-18 21:41 ` Brendan Higgins
2019-10-30 19:02 ` Kees Cook
2019-10-31 9:01 ` Brendan Higgins
2019-10-18 12:29 ` Luis Chamberlain
2019-10-19 12:56 ` Alan Maguire
2019-10-19 18:36 ` Luis Chamberlain
2019-10-24 0:42 ` Brendan Higgins
2019-10-24 10:15 ` Luis Chamberlain
2019-10-30 19:09 ` Kees Cook
2019-10-30 20:11 ` Iurii Zaikin
2019-10-31 1:40 ` John Johansen
2019-10-31 9:33 ` Brendan Higgins
2019-10-31 18:40 ` Kees Cook
2019-11-05 16:43 ` Mike Salvatore
2019-11-05 23:59 ` Brendan Higgins
2019-10-31 1:37 ` John Johansen
2019-10-31 9:17 ` Brendan Higgins
2019-11-01 12:30 ` Alan Maguire
2019-11-05 23:44 ` Brendan Higgins
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=CAFd5g47Qn7ESPLvm9t_ifGPhjJ9dXgV9KVObg64bN3UNnoQPdA@mail.gmail.com \
--to=brendanhiggins@google.com \
--cc=alan.maguire@oracle.com \
--cc=davidgow@google.com \
--cc=jmorris@namei.org \
--cc=john.johansen@canonical.com \
--cc=keescook@chromium.org \
--cc=kunit-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mike.salvatore@canonical.com \
--cc=serge@hallyn.com \
--cc=shuah@kernel.org \
--cc=tytso@mit.edu \
--cc=yzaikin@google.com \
/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;
as well as URLs for NNTP newsgroup(s).