Debian Codegraph @

debian/patches/library_lxc_leak

raw
1 Description: library: Recover from meminfo seek() in LXC
2 Running procps tools under LXC may fail with the message:
3 "Unable to create meminfo structure"
4 .
5 This is due to a lseek() failing with a ESPIPE error.
6 It doesn't appear to impact all LXC installations and it's
7 unclear why some are impacted and some not.
8 .
9 The fix is to check for that error and reopen the file
10 if required.
11 Author: Paul Slootman <[email protected]>
12 Origin: upstream, https://gitlab.com/procps-ng/procps/-/commit/104b3ce3df67092eeb868ba5e019cb895ebdf32d
13 Bug-Debian: https://bugs.debian.org/1072831
14 Applied-Upstream: 4.0.5
15 Last-Update: 2025-04-14
16 ---
17 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
18 --- a/library/meminfo.c
19 +++ b/library/meminfo.c
20 @@ -646,12 +646,20 @@
21 // clear out the soon to be 'current' values
22 memset(&info->hist.new, 0, sizeof(struct meminfo_data));
23
24 - if (-1 == info->meminfo_fd
25 - && (-1 == (info->meminfo_fd = open(MEMINFO_FILE, O_RDONLY))))
26 - return 1;
27 -
28 - if (lseek(info->meminfo_fd, 0L, SEEK_SET) == -1)
29 - return 1;
30 + if (-1 == info->meminfo_fd) {
31 + if (-1 == (info->meminfo_fd = open(MEMINFO_FILE, O_RDONLY)))
32 + return 1;
33 + }
34 + else {
35 + if (lseek(info->meminfo_fd, 0L, SEEK_SET) == -1)
36 + if (ESPIPE == errno) {
37 + close(info->meminfo_fd);
38 + if (-1 == (info->meminfo_fd = open(MEMINFO_FILE, O_RDONLY)))
39 + return 1;
40 + }
41 + else
42 + return 1;
43 + }
44
45 for (;;) {
46 if ((size = read(info->meminfo_fd, buf, sizeof(buf)-1)) < 0) {