* [PATCH dhowells/mount-api] fs: return -ENOPARAM from security_fs_context_parse_param by default
2018-09-06 10:16 ` David Howells
@ 2018-09-06 18:44 ` Andrei Vagin
2018-09-06 23:08 ` [PATCH dhowells/mount-api] fs: fix checking an error code of security_fs_context_parse_param Andrei Vagin
2018-09-11 20:15 ` [PATCH dhowells/mount-api] fs: return -ENOPARAM from security_fs_context_parse_param by default David Howells
2 siblings, 0 replies; 8+ messages in thread
From: Andrei Vagin @ 2018-09-06 18:44 UTC (permalink / raw)
To: David Howells; +Cc: linux-fsdevel, Andrei Vagin
From: Andrei Vagin <avagin@gmail.com>
It returns 0 to indicate that it processed the argument and that
the argument doesn't belong to the filesystem. It returns -ENOPARAM to
indicate that the argument should be passed along to the filesystem. Any
other error is an actual error. // David Howells <dhowells@redhat.com>
Signed-off-by: Andrei Vagin <avagin@gmail.com>
---
include/linux/lsm_hooks.h | 4 ++++
include/linux/security.h | 2 +-
security/security.c | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/include/linux/lsm_hooks.h b/include/linux/lsm_hooks.h
index ceb487c3fbc7..d333ceebf056 100644
--- a/include/linux/lsm_hooks.h
+++ b/include/linux/lsm_hooks.h
@@ -103,6 +103,10 @@
* Validate the filesystem context preparatory to applying it. This is
* done after all the options have been parsed.
* @fc indicates the filesystem context.
+ * Returns 0 to indicate that it processed the argument and that the argument
+ * doesn't belong to the filesystem. It returns -ENOPARAM to indicate that
+ * the argument should be passed along to the filesystem. Any other error is
+ * an actual error.
* @sb_get_tree:
* Assign the security to a newly created superblock.
* @fc indicates the filesystem context.
diff --git a/include/linux/security.h b/include/linux/security.h
index dbed5326b45c..bae191a96c73 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -576,7 +576,7 @@ static inline void security_fs_context_free(struct fs_context *fc)
static inline int security_fs_context_parse_param(struct fs_context *fc,
struct fs_parameter *param)
{
- return 0;
+ return -ENOPARAM;
}
static inline int security_fs_context_validate(struct fs_context *fc)
{
diff --git a/security/security.c b/security/security.c
index 94420f3616a7..64304d20aae1 100644
--- a/security/security.c
+++ b/security/security.c
@@ -380,7 +380,7 @@ void security_fs_context_free(struct fs_context *fc)
int security_fs_context_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
- return call_int_hook(fs_context_parse_param, 0, fc, param);
+ return call_int_hook(fs_context_parse_param, -ENOPARAM, fc, param);
}
int security_fs_context_validate(struct fs_context *fc)
--
2.17.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH dhowells/mount-api] fs: fix checking an error code of security_fs_context_parse_param
2018-09-06 10:16 ` David Howells
2018-09-06 18:44 ` [PATCH dhowells/mount-api] fs: return -ENOPARAM from security_fs_context_parse_param by default Andrei Vagin
@ 2018-09-06 23:08 ` Andrei Vagin
2018-09-11 20:15 ` [PATCH dhowells/mount-api] fs: return -ENOPARAM from security_fs_context_parse_param by default David Howells
2 siblings, 0 replies; 8+ messages in thread
From: Andrei Vagin @ 2018-09-06 23:08 UTC (permalink / raw)
To: David Howells; +Cc: Andrei Vagin, linux-fsdevel, Andrei Vagin
On Thu, Sep 06, 2018 at 11:16:24AM +0100, David Howells wrote:
> Andrei Vagin <avagin@openvz.org> wrote:
>
> > security_fs_context_parse_param() returns 0 if everything is okay.
>
> Not quite. It returns 0 to indicate that it processed the argument and that
> the argument doesn't belong to the filesystem. It returns -ENOPARAM to
> indicate that the argument should be passed along to the filesystem. Any
> other error is an actual error.
>
> > ret = security_fs_context_parse_param(fc, param);
> > - if (ret != -ENOPARAM)
> > + if (ret)
>
> So this change is wrong.
It depends from what point to see on it. Without this patch, the
linux-next kernel doesn't boot:
VFS: Cannot open root device "vda2" or unknown-block(253,2): error -2
Please append a correct "root=" boot option; here are the available partitions:
fd00 25165824 vda
driver: virtio_blk
fd01 512000 vda1 5065bd2c-01
fd02 23601152 vda2 5065bd2c-02
fd03 1044480 vda3 5065bd2c-03
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(253,2)
CPU: 1 PID: 1 Comm: swapper/0 Not tainted 4.19.0-rc1-00106-g679a89690477 #38
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20180531_142017-buildhw-08.phx2.fedoraproject.org-1.fc28 04/01/2014
Call Trace:
dump_stack+0x85/0xc0
panic+0xec/0x251
mount_block_root+0x23e/0x2e7
? do_early_param+0x8e/0x8e
prepare_namespace+0x135/0x16b
kernel_init_freeable+0x28b/0x2af
? rest_init+0xb9/0xb9
kernel_init+0xa/0x10e
ret_from_fork+0x3a/0x50
Kernel Offset: 0x10000000 from 0xffffffff81000000 (relocation range: 0xffffffff80000000-0xffffffffbfffffff)
---[ end Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(253,2) ]---
I agree that I haven't understood the idea of this code. I found that
security_fs_context_parse_param returns 0 by default and decided that this
patch would fix the problem. I have sent an update version of the patch.
Pls, take a look at it. And we need to push this patch to linux-next. We can't
run CRIU tests for linux-next without it.
Thanks,
Andrei
>
> The change that needs making is to the documentation - in particular
> lsm_hooks.h.
>
> David
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH dhowells/mount-api] fs: return -ENOPARAM from security_fs_context_parse_param by default
2018-09-06 10:16 ` David Howells
2018-09-06 18:44 ` [PATCH dhowells/mount-api] fs: return -ENOPARAM from security_fs_context_parse_param by default Andrei Vagin
2018-09-06 23:08 ` [PATCH dhowells/mount-api] fs: fix checking an error code of security_fs_context_parse_param Andrei Vagin
@ 2018-09-11 20:15 ` David Howells
2 siblings, 0 replies; 8+ messages in thread
From: David Howells @ 2018-09-11 20:15 UTC (permalink / raw)
To: Andrei Vagin; +Cc: dhowells, linux-fsdevel, Andrei Vagin
Andrei Vagin <avagin@openvz.org> wrote:
> It returns 0 to indicate that it processed the argument and that
> the argument doesn't belong to the filesystem. It returns -ENOPARAM to
> indicate that the argument should be passed along to the filesystem. Any
> other error is an actual error. // David Howells <dhowells@redhat.com>
I made these changes already, thanks.
David
^ permalink raw reply [flat|nested] 8+ messages in thread