From: Eric Biggers <ebiggers@kernel.org>
To: linux-fscrypt@vger.kernel.org
Cc: linux-api@vger.kernel.org
Subject: Re: [PATCH] fscrypt: remove kernel-internal constants from UAPI header
Date: Mon, 16 Nov 2020 11:49:41 -0800 [thread overview]
Message-ID: <X7LX1RGLo/5NnHKE@sol.localdomain> (raw)
In-Reply-To: <20201024005132.495952-1-ebiggers@kernel.org>
On Fri, Oct 23, 2020 at 05:51:31PM -0700, Eric Biggers wrote:
> From: Eric Biggers <ebiggers@google.com>
>
> There isn't really any valid reason to use __FSCRYPT_MODE_MAX or
> FSCRYPT_POLICY_FLAGS_VALID in a userspace program. These constants are
> only meant to be used by the kernel internally, and they are defined in
> the UAPI header next to the mode numbers and flags only so that kernel
> developers don't forget to update them when adding new modes or flags.
>
> In https://lkml.kernel.org/r/20201005074133.1958633-2-satyat@google.com
> there was an example of someone wanting to use __FSCRYPT_MODE_MAX in a
> user program, and it was wrong because the program would have broken if
> __FSCRYPT_MODE_MAX were ever increased. So having this definition
> available is harmful. FSCRYPT_POLICY_FLAGS_VALID has the same problem.
>
> So, remove these definitions from the UAPI header. Replace
> FSCRYPT_POLICY_FLAGS_VALID with just listing the valid flags explicitly
> in the one kernel function that needs it. Move __FSCRYPT_MODE_MAX to
> fscrypt_private.h, remove the double underscores (which were only
> present to discourage use by userspace), and add a BUILD_BUG_ON() and
> comments to (hopefully) ensure it is kept in sync.
>
> Keep the old name FS_POLICY_FLAGS_VALID, since it's been around for
> longer and there's a greater chance that removing it would break source
> compatibility with some program. Indeed, mtd-utils is using it in
> an #ifdef, and removing it would introduce compiler warnings (about
> FS_POLICY_FLAGS_PAD_* being redefined) into the mtd-utils build.
> However, reduce its value to 0x07 so that it only includes the flags
> with old names (the ones present before Linux 5.4), and try to make it
> clear that it's now "frozen" and no new flags should be added to it.
>
> Fixes: 2336d0deb2d4 ("fscrypt: use FSCRYPT_ prefix for uapi constants")
> Cc: <stable@vger.kernel.org> # v5.4+
> Signed-off-by: Eric Biggers <ebiggers@google.com>
Applied to fscrypt.git#master for 5.11.
- Eric
prev parent reply other threads:[~2020-11-16 19:49 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-24 0:51 [PATCH] fscrypt: remove kernel-internal constants from UAPI header Eric Biggers
2020-11-16 19:49 ` Eric Biggers [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=X7LX1RGLo/5NnHKE@sol.localdomain \
--to=ebiggers@kernel.org \
--cc=linux-api@vger.kernel.org \
--cc=linux-fscrypt@vger.kernel.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