[PATCH] mount: support the sizelimit and offset option for loop devices
Denys Vlasenko
vda.linux at googlemail.com
Wed Sep 30 22:33:19 UTC 2020
Apologies for an extremely late reply!
On Wed, Jul 29, 2020 at 10:44 AM Steffen Trumtrar
<s.trumtrar at pengutronix.de> wrote:
> Starting with linux kernel v5.4 squashfs has a more strict parameter
> checking implemented. Unlike util-linux mount, busybox never supported
> the sizelimit option but simply forwards it to the kernel.
> Since v5.4 mounting will fail with
>
> squashfs: Unknown parameter 'sizelimit'
>
> Support the sizelimit parameter by setting it in the LOOP_SET_STATUS64
> structure before handing it to the kernel.
>
> While at it also add support for the offset option, which currently will
> always be set to 0.
>
> Signed-off-by: Steffen Trumtrar <s.trumtrar at pengutronix.de>
> + /* parse options */
> + if (filteropts)
> + for (opt = strtok(filteropts, ","); opt; opt = strtok(NULL, ",")) {
> + char *opteq = strchr(opt, '=');
> + int len = strlen(opt);
> + char *match;
> +
> + if (opteq) {
> + int idx;
> + static const char options[] ALIGN1 =
> + /* 0 */ "offset\0"
> + /* 1 */ "sizelimit\0";
> +
> + *opteq++ = '\0';
This will destroy any non-matching options, no?
(By truncating them at the first '=' - you never restore it)
> + idx = index_in_strings(options, opt);
> + switch (idx) {
> + case 0: // "offset"
> + offset = strtoull(opteq, 0, 0);
No error checking?
> + match = strstr(filteropts, opt);
What are you searching for here? "Where is OPT string in FILTEROPTS?"
Obviously, it is at OPT pointer - it points into FILTEROPTS string.
Or worse yet, your FILTEROPTS has a duplicate earlier on, like
"offset,offset=123"
and now you will perform this surgery:
> + *match = '\0';
> + strcat(filteropts, match+len);
on the *wrong part of the string* (you would delete "offset," not
"...,offset=123" part).
Also, you need to use len + 1, no?
These three lines should be replaced with just
strcpy(opt, opt + len + 1);
...but there is another bug: you are operating on strtok'ed string.
If you edit it like this, subsequent calls of strtok can fail.
I'm committing a modified patch. Please try current git.
Thank you.
More information about the busybox
mailing list