diff options
author | Radostin Stoyanov <rstoyanov@fedoraproject.org> | 2022-04-13 22:12:11 +0300 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2022-04-29 03:53:52 +0300 |
commit | 5b872c7183b3073dd9d1ed231d4325be8a7cac50 (patch) | |
tree | e3580a644102fb8336575c48442ba96fa325f18b | |
parent | d40b332cef9c145a7a683500d95c5dd0aa27dee8 (diff) |
proc_parse: Fix parsing bpf map_extra
The map_extra field has been introduced in Linux Kernel release 5.16
and does not exist in older kernel versions. The current parsing
implementation fails when map_extra is missing.
In particular, it tries to parse the `memlock` field as `map_extra` and
fails but it does not exit with an error because map_extra is marked as
"optional". It then tries to parse the `map_id` field as `memlock` and
fails with an error because map_id is not optional:
Error (criu/proc_parse.c:2161): parse_fdinfo_pid_s: error parsing [map_type:\t2] for 19: Success'
To correctly handle this, we should try to parse again the next field
when parsing of `map_extra` fails, without reading the next line from
the bpfmap.
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
-rw-r--r-- | criu/proc_parse.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/criu/proc_parse.c b/criu/proc_parse.c index 3c71476fa..b3badb6e4 100644 --- a/criu/proc_parse.c +++ b/criu/proc_parse.c @@ -1796,14 +1796,11 @@ static int parse_bpfmap(struct bfd *f, char *str, BpfmapFileEntry *bpf) int i; for (i = 0; i < n; i++) { - bool parsing_failed = false; if (sscanf(str, map[i].fmt, map[i].value) != 1) { - parsing_failed = true; - } - if (map[i].optional && !parsing_failed) - *map[i].optional = true; - if (!map[i].optional && parsing_failed) + if (map[i].optional) + continue; return -1; + } if (i == n - 1) break; |