All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: Christian Brauner <brauner@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>, Aleksa Sarai <cyphar@cyphar.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	linux-fsdevel@vger.kernel.org,
	Christian Brauner <christian.brauner@ubuntu.com>
Subject: Re: [PATCH 3/3] test: add openat2() test for invalid upper 32 bit flag value
Date: Fri, 30 Apr 2021 11:24:00 -0400	[thread overview]
Message-ID: <20210430152400.GY3141668@madcap2.tricolour.ca> (raw)
In-Reply-To: <20210423111037.3590242-3-brauner@kernel.org>

On 2021-04-23 13:10, Christian Brauner wrote:
> From: Christian Brauner <christian.brauner@ubuntu.com>
> 
> Test that openat2() rejects unknown flags in the upper 32 bit range.
> 
> Cc: Richard Guy Briggs <rgb@redhat.com>
> Cc: Aleksa Sarai <cyphar@cyphar.com>
> Cc: linux-fsdevel@vger.kernel.org
> Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
> ---
>  tools/testing/selftests/openat2/openat2_test.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
> index 381d874cce99..7379e082a994 100644
> --- a/tools/testing/selftests/openat2/openat2_test.c
> +++ b/tools/testing/selftests/openat2/openat2_test.c
> @@ -155,7 +155,7 @@ struct flag_test {
>  	int err;
>  };
>  
> -#define NUM_OPENAT2_FLAG_TESTS 24
> +#define NUM_OPENAT2_FLAG_TESTS 25
>  
>  void test_openat2_flags(void)
>  {
> @@ -229,6 +229,11 @@ void test_openat2_flags(void)
>  		{ .name = "invalid how.resolve and O_PATH",
>  		  .how.flags = O_PATH,
>  		  .how.resolve = 0x1337, .err = -EINVAL },
> +
> +		/* Invalid flags in the upper 32 bits must be rejected. */
> +		{ .name = "invalid flags (1 << 63)",
> +		  .how.flags = O_RDONLY | (1ULL << 63),
> +		  .how.resolve = 0, .err = -EINVAL },

This doesn't appear to specifically test for flags over 32 bits.  It
appears to test for flags not included in VALID_OPEN_FLAGS.

"1ULL << 2" would accomplish the same thing, as would "1ULL << 31" due
to the unused flags in the bottom 32 bits.

The test appears to be useful, but misnamed.

If a new flag was added at 1ULL << 33, this test wouldn't notice and it
would still get dropped in build_open_flags() when flags gets assigned
to op->open_flags.

>  	};
>  
>  	BUILD_BUG_ON(ARRAY_LEN(tests) != NUM_OPENAT2_FLAG_TESTS);
> -- 
> 2.27.0
> 

- RGB

--
Richard Guy Briggs <rgb@redhat.com>
Sr. S/W Engineer, Kernel Security, Base Operating Systems
Remote, Ottawa, Red Hat Canada
IRC: rgb, SunRaycer
Voice: +1.647.777.2635, Internal: (81) 32635


  reply	other threads:[~2021-04-30 15:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 11:10 [PATCH 1/3] fcntl: remove unused VALID_UPGRADE_FLAGS Christian Brauner
2021-04-23 11:10 ` [PATCH 2/3] open: don't silently ignore unknown O-flags in openat2() Christian Brauner
2021-04-23 13:50   ` Richard Guy Briggs
2021-04-26 13:34   ` Christoph Hellwig
2021-05-01  0:53   ` Aleksa Sarai
2021-04-23 11:10 ` [PATCH 3/3] test: add openat2() test for invalid upper 32 bit flag value Christian Brauner
2021-04-30 15:24   ` Richard Guy Briggs [this message]
2021-04-30 16:09     ` Christian Brauner
2021-04-30 16:46       ` Richard Guy Briggs
2021-04-30 17:08         ` Christian Brauner
2021-04-30 17:22           ` Richard Guy Briggs
2021-04-23 12:36 ` [PATCH 1/3] fcntl: remove unused VALID_UPGRADE_FLAGS Richard Guy Briggs
2021-04-26 13:33 ` Christoph Hellwig

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=20210430152400.GY3141668@madcap2.tricolour.ca \
    --to=rgb@redhat.com \
    --cc=brauner@kernel.org \
    --cc=christian.brauner@ubuntu.com \
    --cc=cyphar@cyphar.com \
    --cc=hch@lst.de \
    --cc=linux-fsdevel@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.