diff mbox series

cifs: fix negative option value parsing

Message ID 165870800544.18681.3152428501550287295.stgit@donald.themaw.net (mailing list archive)
State New
Headers show
Series cifs: fix negative option value parsing | expand

Commit Message

Ian Kent July 25, 2022, 12:13 a.m. UTC
The valid values of options that are defined with fsparam_u32() should
be positive.

But the fs parser will return a fail for values that are negative and
if the sloppy option is given success will then be returned resulting
in the option being silently ignored.

Also the sloppy option handling is meant to return success for invalid
options not valid options with invalid values.

Restricting the sloppy option override to handle failure returns for
invalid options only is sufficient to resolve these problems.

Signed-off-by: Ian Kent <raven@themaw.net>
Signed-off-by: Leif Sahlberg <lsahlber@redhat.com>
---
 fs/cifs/fs_context.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/fs/cifs/fs_context.c b/fs/cifs/fs_context.c
index 8dc0d923ef6a..2dc5cdeee354 100644
--- a/fs/cifs/fs_context.c
+++ b/fs/cifs/fs_context.c
@@ -863,7 +863,7 @@  static int smb3_fs_context_parse_param(struct fs_context *fc,
 	if (!skip_parsing) {
 		opt = fs_parse(fc, smb3_fs_parameters, param, &result);
 		if (opt < 0)
-			return ctx->sloppy ? 1 : opt;
+			return (opt == -ENOPARAM && ctx->sloppy) ? 1 : opt;
 	}
 
 	switch (opt) {