From: Paul Moore <paul@paul-moore.com>
To: Frederick Lawler <fred@cloudflare.com>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-aio@kvack.org, linux-fsdevel@vger.kernel.org,
linux-cachefs@redhat.com, linux-cifs@vger.kernel.org,
samba-technical@lists.samba.org, linux-mm@kvack.org,
linux-nfs@vger.kernel.org, linux-unionfs@vger.kernel.org,
linux-security-module@vger.kernel.org, netdev@vger.kernel.org,
keyrings@vger.kernel.org, selinux@vger.kernel.org,
serge@hallyn.com, amir73il@gmail.com,
kernel-team@cloudflare.com
Subject: Re: [PATCH v2] cred: Propagate security_prepare_creds() error code
Date: Fri, 27 May 2022 16:05:26 -0400 [thread overview]
Message-ID: <CAHC9VhS=_RvB66J9D5AZ+XnyDKupvTQpFzni2uvz348REPUT5A@mail.gmail.com> (raw)
In-Reply-To: <20220525183703.466936-1-fred@cloudflare.com>
On Wed, May 25, 2022 at 2:37 PM Frederick Lawler <fred@cloudflare.com> wrote:
>
> While experimenting with the security_prepare_creds() LSM hook, we
> noticed that our EPERM error code was not propagated up the callstack.
> Instead ENOMEM is always returned. As a result, some tools may send a
> confusing error message to the user:
>
> $ unshare -rU
> unshare: unshare failed: Cannot allocate memory
>
> A user would think that the system didn't have enough memory, when
> instead the action was denied.
>
> This problem occurs because prepare_creds() and prepare_kernel_cred()
> return NULL when security_prepare_creds() returns an error code. Later,
> functions calling prepare_creds() and prepare_kernel_cred() return
> ENOMEM because they assume that a NULL meant there was no memory
> allocated.
>
> Fix this by propagating an error code from security_prepare_creds() up
> the callstack.
>
> Signed-off-by: Frederick Lawler <fred@cloudflare.com>
>
> ---
> Changes since v1:
> - Revert style churn in ovl_create_or_link() noted by Amir
> - Revert style churn in prepare_nsset() noted by Serge
> - Update documentation for prepare_creds()
> - Set ofs->creator_cred in ovl_fill_super() and req->creds in aio_fsync()
> to NULL on error noted by Amir
> ---
> Documentation/security/credentials.rst | 6 +++---
> fs/aio.c | 9 +++++++--
> fs/cachefiles/security.c | 8 ++++----
> fs/cifs/cifs_spnego.c | 4 ++--
> fs/cifs/cifsacl.c | 4 ++--
> fs/coredump.c | 2 +-
> fs/exec.c | 14 ++++++++-----
> fs/ksmbd/smb_common.c | 4 ++--
> fs/nfs/flexfilelayout/flexfilelayout.c | 7 +++++--
> fs/nfs/nfs4idmap.c | 4 ++--
> fs/nfsd/auth.c | 4 ++--
> fs/nfsd/nfs4callback.c | 10 ++++-----
> fs/nfsd/nfs4recover.c | 4 ++--
> fs/nfsd/nfsfh.c | 4 ++--
> fs/open.c | 8 ++++----
> fs/overlayfs/dir.c | 6 ++++--
> fs/overlayfs/super.c | 6 ++++--
> kernel/capability.c | 4 ++--
> kernel/cred.c | 28 +++++++++++++++-----------
> kernel/groups.c | 4 ++--
> kernel/nsproxy.c | 9 ++++++++-
> kernel/sys.c | 28 +++++++++++++-------------
> kernel/trace/trace_events_user.c | 4 ++--
> kernel/umh.c | 5 +++--
> kernel/user_namespace.c | 6 ++++--
> net/dns_resolver/dns_key.c | 4 ++--
> security/apparmor/task.c | 12 +++++------
> security/commoncap.c | 20 +++++++++---------
> security/keys/keyctl.c | 8 ++++----
> security/keys/process_keys.c | 16 +++++++--------
> security/landlock/syscalls.c | 4 ++--
> security/selinux/hooks.c | 8 ++++----
> security/smack/smack_lsm.c | 8 ++++----
> security/smack/smackfs.c | 4 ++--
> 34 files changed, 153 insertions(+), 123 deletions(-)
The SELinux bits look fine to me.
Acked-by: Paul Moore <paul@paul-moore.com> (SELinux)
--
paul-moore.com
next prev parent reply other threads:[~2022-05-27 20:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-25 18:37 Frederick Lawler
2022-05-26 20:43 ` Jeff Moyer
2022-05-27 20:05 ` Paul Moore [this message]
2022-05-28 1:37 ` Serge E. Hallyn
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='CAHC9VhS=_RvB66J9D5AZ+XnyDKupvTQpFzni2uvz348REPUT5A@mail.gmail.com' \
--to=paul@paul-moore.com \
--cc=amir73il@gmail.com \
--cc=fred@cloudflare.com \
--cc=kernel-team@cloudflare.com \
--cc=keyrings@vger.kernel.org \
--cc=linux-aio@kvack.org \
--cc=linux-cachefs@redhat.com \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=samba-technical@lists.samba.org \
--cc=selinux@vger.kernel.org \
--cc=serge@hallyn.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