From 9c4830a9912ffafb3903eeeda85b06aaa67b23fc Mon Sep 17 00:00:00 2001 From: Pavel Tikhomirov Date: Thu, 26 Mar 2026 18:09:39 +0100 Subject: [PATCH] proc_parse: Preallocate extra space for possible option string growth The logic in sb_opt_cb converts uid and gid to using userns map, it means that the option string can extend. Worse case we had original id "0" and got INVALID_ID ("4294967295") back. Signed-off-by: Pavel Tikhomirov --- criu/proc_parse.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/criu/proc_parse.c b/criu/proc_parse.c index 6f9fad3df..9605ff209 100644 --- a/criu/proc_parse.c +++ b/criu/proc_parse.c @@ -1547,7 +1547,13 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname) new->fstype = find_fstype_by_name(*fsname); - new->options = xmalloc(strlen(opt) + 1); + /* + * sb_opt_cb() may translate uid=/gid= values via userns mappings, + * producing longer decimal strings than the original. Let's + * reserve extra space for the worst-case expansion of both a uid= + * and a gid= value to 10-digit numbers. + */ + new->options = xmalloc(strlen(opt) + 1 + 2 * (sizeof("4294967295") - 1)); if (!new->options) goto err;