All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf] security: Fix the default value of fs_context_parse_param hook
@ 2020-04-30 15:52 KP Singh
  2020-05-01  3:46 ` James Morris
  2020-05-01  7:30 ` Mikko Ylinen
  0 siblings, 2 replies; 4+ messages in thread
From: KP Singh @ 2020-04-30 15:52 UTC (permalink / raw)
  To: linux-kernel, bpf, linux-security-module
  Cc: Mikko Ylinen, Alexei Starovoitov, Daniel Borkmann, James Morris,
	Kees Cook, Jann Horn

From: KP Singh <kpsingh@google.com>

security_fs_context_parse_param is called by vfs_parse_fs_param and
a succussful return value (i.e 0) implies that a parameter will be
consumed by the LSM framework. This stops all further parsing of the
parmeter by VFS. Furthermore, if an LSM hook returns a success, the
remaining LSM hooks are not invoked for the parameter.

The current default behavior of returning success means that all the
parameters are expected to be parsed by the LSM hook and none of them
end up being populated by vfs in fs_context

This was noticed when lsm=bpf is supplied on the command line before any
other LSM. As the bpf lsm uses this default value to implement a default
hook, this resulted in a failure to parse any fs_context parameters and
a failure to mount the root filesystem.

Fixes: 98e828a0650f ("security: Refactor declaration of LSM hooks")
Reported-by: Mikko Ylinen <mikko.ylinen@linux.intel.com>
Signed-off-by: KP Singh <kpsingh@google.com>
---
 include/linux/lsm_hook_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 9cd4455528e5..1bdd027766d4 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -55,7 +55,7 @@ LSM_HOOK(void, LSM_RET_VOID, bprm_committing_creds, struct linux_binprm *bprm)
 LSM_HOOK(void, LSM_RET_VOID, bprm_committed_creds, struct linux_binprm *bprm)
 LSM_HOOK(int, 0, fs_context_dup, struct fs_context *fc,
 	 struct fs_context *src_sc)
-LSM_HOOK(int, 0, fs_context_parse_param, struct fs_context *fc,
+LSM_HOOK(int, -ENOPARAM, fs_context_parse_param, struct fs_context *fc,
 	 struct fs_parameter *param)
 LSM_HOOK(int, 0, sb_alloc_security, struct super_block *sb)
 LSM_HOOK(void, LSM_RET_VOID, sb_free_security, struct super_block *sb)
-- 
2.26.2.303.gf8c07b1a785-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] security: Fix the default value of fs_context_parse_param hook
  2020-04-30 15:52 [PATCH bpf] security: Fix the default value of fs_context_parse_param hook KP Singh
@ 2020-05-01  3:46 ` James Morris
  2020-05-07  5:50   ` Alexei Starovoitov
  2020-05-01  7:30 ` Mikko Ylinen
  1 sibling, 1 reply; 4+ messages in thread
From: James Morris @ 2020-05-01  3:46 UTC (permalink / raw)
  To: KP Singh
  Cc: linux-kernel, bpf, linux-security-module, Mikko Ylinen,
	Alexei Starovoitov, Daniel Borkmann, Kees Cook, Jann Horn

On Thu, 30 Apr 2020, KP Singh wrote:

> From: KP Singh <kpsingh@google.com>
> 

Applied to:
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git for-v5.7


-- 
James Morris
<jmorris@namei.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] security: Fix the default value of fs_context_parse_param hook
  2020-04-30 15:52 [PATCH bpf] security: Fix the default value of fs_context_parse_param hook KP Singh
  2020-05-01  3:46 ` James Morris
@ 2020-05-01  7:30 ` Mikko Ylinen
  1 sibling, 0 replies; 4+ messages in thread
From: Mikko Ylinen @ 2020-05-01  7:30 UTC (permalink / raw)
  To: KP Singh, linux-kernel, bpf, linux-security-module
  Cc: Alexei Starovoitov, Daniel Borkmann, James Morris, Kees Cook, Jann Horn



On 30/04/2020 18:52, KP Singh wrote:
> This was noticed when lsm=bpf is supplied on the command line before any
> other LSM. As the bpf lsm uses this default value to implement a default
> hook, this resulted in a failure to parse any fs_context parameters and
> a failure to mount the root filesystem.

Tested-by: Mikko Ylinen <mikko.ylinen@linux.intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf] security: Fix the default value of fs_context_parse_param hook
  2020-05-01  3:46 ` James Morris
@ 2020-05-07  5:50   ` Alexei Starovoitov
  0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2020-05-07  5:50 UTC (permalink / raw)
  To: James Morris
  Cc: KP Singh, LKML, bpf, LSM List, Mikko Ylinen, Alexei Starovoitov,
	Daniel Borkmann, Kees Cook, Jann Horn

On Thu, Apr 30, 2020 at 8:46 PM James Morris <jmorris@namei.org> wrote:
>
> On Thu, 30 Apr 2020, KP Singh wrote:
>
> > From: KP Singh <kpsingh@google.com>
> >
>
> Applied to:
> git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git for-v5.7
>

James,
could you please send PR to Linus this week to make sure
the fix makes it into the next -rc ?
Few other people reported issues that are fixed by this patch.
Thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-07  5:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-30 15:52 [PATCH bpf] security: Fix the default value of fs_context_parse_param hook KP Singh
2020-05-01  3:46 ` James Morris
2020-05-07  5:50   ` Alexei Starovoitov
2020-05-01  7:30 ` Mikko Ylinen

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.