Re: [PATCH 02/12] fs_parse: fix fs_param_v_optional handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 28/11/2019 15:59, Miklos Szeredi wrote:
String options always have parameters, hence the check for optional
parameter will never trigger.

Check for param type being a flag first (flag is the only type that does
not have a parameter) and report "Missing value" if the parameter is
mandatory.

Tested with gfs2's "quota" option, which is currently the only user of
fs_param_v_optional.

It's not clear to me what the bug is here. My tests with the quota option are giving expected results. Perhaps I missed a case?

Andy

Signed-off-by: Miklos Szeredi <mszeredi@xxxxxxxxxx>
Cc: Andrew Price <anprice@xxxxxxxxxx>
Cc: David Howells <dhowells@xxxxxxxxxx>
Fixes: 31d921c7fb96 ("vfs: Add configuration parser helpers")
Cc: <stable@xxxxxxxxxxxxxxx> # v5.4
---
  fs/fs_parser.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index d1930adce68d..5d8833d71b37 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -127,13 +127,15 @@ int fs_parse(struct fs_context *fc,
  	case fs_param_is_u64:
  	case fs_param_is_enum:
  	case fs_param_is_string:
-		if (param->type != fs_value_is_string)
-			goto bad_value;
-		if (!result->has_value) {
+		if (param->type == fs_value_is_flag) {
  			if (p->flags & fs_param_v_optional)
  				goto okay;
-			goto bad_value;
+
+			return invalf(fc, "%s: Missing value for '%s'",
+				      desc->name, param->key);
  		}
+		if (param->type != fs_value_is_string)
+			goto bad_value;
  		/* Fall through */
  	default:
  		break;





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux