From: Jamie Hill-Daniel Date: Tue, 18 Jan 2022 07:06:04 +0000 (+0100) Subject: vfs: fs_context: fix up param length parsing in legacy_parse_param X-Git-Tag: archive/raspbian/5.15.15-2+rpi1~1^2~18 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=faf68ffd2f76a3140ce4f1e4cd5a6fe249d41a30;p=linux.git vfs: fs_context: fix up param length parsing in legacy_parse_param Origin: https://git.kernel.org/linus/722d94847de29310e8aa03fcbdb41fc92c521756 Bug-Debian-Security: https://security-tracker.debian.org/tracker/CVE-2022-0185 The "PAGE_SIZE - 2 - size" calculation in legacy_parse_param() is an unsigned type so a large value of "size" results in a high positive value instead of a negative value as expected. Fix this by getting rid of the subtraction. Signed-off-by: Jamie Hill-Daniel Signed-off-by: William Liu Tested-by: Salvatore Bonaccorso Tested-by: Thadeu Lima de Souza Cascardo Acked-by: Dan Carpenter Acked-by: Al Viro Signed-off-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds Gbp-Pq: Topic bugfix/all Gbp-Pq: Name vfs-fs_context-fix-up-param-length-parsing-in-legacy.patch --- diff --git a/fs/fs_context.c b/fs/fs_context.c index b7e43a780a6..24ce12f0db3 100644 --- a/fs/fs_context.c +++ b/fs/fs_context.c @@ -548,7 +548,7 @@ static int legacy_parse_param(struct fs_context *fc, struct fs_parameter *param) param->key); } - if (len > PAGE_SIZE - 2 - size) + if (size + len + 2 > PAGE_SIZE) return invalf(fc, "VFS: Legacy: Cumulative options too large"); if (strchr(param->key, ',') || (param->type == fs_value_is_string &&