diff --git a/0001-systemd.patch b/0001-systemd.patch index 0ee064bbefa0acf43b57967f5a2c641313462e93..89eadcfd34ec03fac103a5acfb2ec09465d80405 100644 --- a/0001-systemd.patch +++ b/0001-systemd.patch @@ -1,7 +1,7 @@ -From 04c55841409a238f8b12c15395006c5793b4a508 Mon Sep 17 00:00:00 2001 +From c0a2baa7e79ef6d7a0060611b4244c4946c246b8 Mon Sep 17 00:00:00 2001 From: vegbir Date: Tue, 11 Jul 2023 08:41:53 +0000 -Subject: [PATCH 01/16] systemd +Subject: [PATCH 01/15] systemd append:remove-lxcfs-tools-dependency-for-common-use diff --git a/0002-show-dev-name-in-container.patch b/0002-show-dev-name-in-container.patch index 0d9cb2393dd1b172d3d4f008dd92133f5725223c..fa5d8c13a5fde08c27e7c10359cedc72b4000954 100644 --- a/0002-show-dev-name-in-container.patch +++ b/0002-show-dev-name-in-container.patch @@ -1,7 +1,7 @@ -From a6346a7a51385ee588a624775a91ce7ac3fb4dd3 Mon Sep 17 00:00:00 2001 +From 79d335011ffccfee542ee5068fda6257a9ac1e59 Mon Sep 17 00:00:00 2001 From: vegbir -Date: Tue, 11 Jul 2023 09:18:09 +0000 -Subject: [PATCH 02/16] show dev name in container +Date: Thu, 27 Jul 2023 06:40:47 +0000 +Subject: [PATCH 02/15] show dev name in container append: fix hang append: limit-stat-by-quota-period-setting @@ -16,7 +16,7 @@ Signed-off-by: vegbir 1 file changed, 181 insertions(+), 2 deletions(-) diff --git a/src/proc_fuse.c b/src/proc_fuse.c -index 23e0b43..4503373 100644 +index 25af10a..cde48ca 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c @@ -28,6 +28,7 @@ @@ -78,7 +78,7 @@ index 23e0b43..4503373 100644 + struct dirent *ptr; + struct stat dev_stat; + struct devinfo *head = NULL, *end; -+ char fpath[261], dev_name[256]; ++ char fpath[261], dev_name[101]; + pid_t child_pid; + int mypipe[2]; + int dev_num; @@ -156,7 +156,7 @@ index 23e0b43..4503373 100644 + wait_for_pid(child_pid); + child_pid = 0; + memset(dev_name, 0, sizeof(dev_name)); -+ while (fscanf(stream, "%255s%d", dev_name, &dev_num) == 2) { ++ while (fscanf(stream, "%100s%d", dev_name, &dev_num) == 2) { + if (dev_num == 0) { + break; + } @@ -236,8 +236,8 @@ index 23e0b43..4503373 100644 get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Read", &stats.read); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Write", &stats.write); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Discard", &stats.discard); -@@ -664,10 +838,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, - continue; +@@ -672,10 +846,14 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, + } l = snprintf(cache, cache_size, "%s", lbuf); - if (l < 0) @@ -253,7 +253,7 @@ index 23e0b43..4503373 100644 cache += l; cache_size -= l; -@@ -679,6 +857,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, +@@ -687,6 +865,7 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, if (total_len > size) total_len = size; memcpy(buf, d->buf, total_len); diff --git a/0003-lxcfs-fix-cpuinfo-print.patch b/0003-lxcfs-fix-cpuinfo-print.patch index 6facdfdb92e37dd88ab2a91fc7360dd93a981eec..697e04225a8a1f222396c8513250e8ed95b0c786 100644 --- a/0003-lxcfs-fix-cpuinfo-print.patch +++ b/0003-lxcfs-fix-cpuinfo-print.patch @@ -1,7 +1,7 @@ -From 2a7730cfc9d7ca747b6ff4c99a1fc6508f667b27 Mon Sep 17 00:00:00 2001 +From 735d69c8696b5ddc8090ad7906f07fe2fe5f9992 Mon Sep 17 00:00:00 2001 From: vegbir -Date: Tue, 11 Jul 2023 09:26:08 +0000 -Subject: [PATCH 03/16] lxcfs fix cpuinfo print +Date: Thu, 27 Jul 2023 07:00:28 +0000 +Subject: [PATCH 03/15] lxcfs fix cpuinfo print Signed-off-by: vegbir --- @@ -9,10 +9,10 @@ Signed-off-by: vegbir 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/proc_cpuview.c b/src/proc_cpuview.c -index 89f3666..0cf37eb 100644 +index f5464de..76f8089 100644 --- a/src/proc_cpuview.c +++ b/src/proc_cpuview.c -@@ -1048,7 +1048,17 @@ int proc_cpuinfo_read(char *buf, size_t size, off_t offset, +@@ -1051,7 +1051,17 @@ int proc_cpuinfo_read(char *buf, size_t size, off_t offset, } if (am_printing) { diff --git a/0004-fix-memory-leak.patch b/0004-fix-memory-leak.patch index 58e09391303bab23d4d58a8a0376af8080343833..20947db291b3fedd36e250b215614630b42f2162 100644 --- a/0004-fix-memory-leak.patch +++ b/0004-fix-memory-leak.patch @@ -1,7 +1,7 @@ -From b2c83183e7ace5049bab265ec3084335165ff570 Mon Sep 17 00:00:00 2001 +From 611a0dec7317fa0441a5923a8e825e804060c998 Mon Sep 17 00:00:00 2001 From: vegbir -Date: Wed, 12 Jul 2023 07:07:16 +0000 -Subject: [PATCH 04/16] fix memory leak +Date: Thu, 27 Jul 2023 07:07:55 +0000 +Subject: [PATCH 04/15] fix memory leak Signed-off-by: vegbir --- @@ -9,7 +9,7 @@ Signed-off-by: vegbir 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/proc_fuse.c b/src/proc_fuse.c -index 4503373..c615e8e 100644 +index cde48ca..ed70ea7 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c @@ -304,6 +304,8 @@ static uint64_t get_min_memlimit(const char *cgroup, bool swap) @@ -30,7 +30,7 @@ index 4503373..c615e8e 100644 ret = cgroup_ops->get_memory_current(cgroup_ops, cgroup, &memusage_str); if (ret < 0) -@@ -1442,6 +1446,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset, +@@ -1453,6 +1457,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset, return read_file_fuse("/proc/meminfo", buf, size, d); memlimit = get_min_memlimit(cgroup, false); @@ -39,7 +39,7 @@ index 4503373..c615e8e 100644 /* * Following values are allowed to fail, because swapaccount might be -@@ -1456,9 +1462,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset, +@@ -1467,9 +1473,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset, memusage /= 1024; memlimit /= 1024; diff --git a/0005-fix-concurrency-problem.patch b/0005-fix-concurrency-problem.patch index 2598e4212e8884488dc24acce1acdad069497497..0cfdd63548aa5e04f32ea853c122e93d3f81d147 100644 --- a/0005-fix-concurrency-problem.patch +++ b/0005-fix-concurrency-problem.patch @@ -1,7 +1,7 @@ -From fb10b60dd72ba36752978c0740b66b572ded4feb Mon Sep 17 00:00:00 2001 +From a7f9759ef8ce354ab2ad420d4a8c5b4260d491fc Mon Sep 17 00:00:00 2001 From: vegbir -Date: Wed, 12 Jul 2023 07:19:20 +0000 -Subject: [PATCH 05/16] fix concurrency problem +Date: Thu, 27 Jul 2023 07:24:18 +0000 +Subject: [PATCH 05/15] fix concurrency problem Signed-off-by: vegbir --- @@ -81,10 +81,10 @@ index f431686..d4c8598 100644 extern char *readat_file(int fd, const char *path); extern char *read_file_strip_newline(const char *fnam); diff --git a/src/proc_fuse.c b/src/proc_fuse.c -index c615e8e..80db328 100644 +index ed70ea7..0af559f 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c -@@ -1736,6 +1736,9 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size, +@@ -1747,6 +1747,9 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size, { struct file_info *f = INTTYPE_TO_PTR(fi->fh); diff --git a/0006-set-null-after-free.patch b/0006-set-null-after-free.patch index 537530324f8d0fc841b2045e7c55534ec1272309..aef6ff0b49b0e4499628e886a8e8e739b7b94ebf 100644 --- a/0006-set-null-after-free.patch +++ b/0006-set-null-after-free.patch @@ -1,7 +1,7 @@ -From 615f5343cd8180308fa4b1a42faf17686c9f7651 Mon Sep 17 00:00:00 2001 +From 6a744fd9ba541e535e611f066c4038330605fe2b Mon Sep 17 00:00:00 2001 From: vegbir Date: Wed, 12 Jul 2023 07:48:40 +0000 -Subject: [PATCH 06/16] set null after free +Subject: [PATCH 06/15] set null after free Signed-off-by: vegbir --- diff --git a/0007-limit-stat-by-quota-period-setting.patch b/0007-limit-stat-by-quota-period-setting.patch index 2314172e8b6c8d8ba4723f6a1e463d185ba5b40a..45ccd075f973a1b99c3f3eac7b07c33027cfa387 100644 --- a/0007-limit-stat-by-quota-period-setting.patch +++ b/0007-limit-stat-by-quota-period-setting.patch @@ -1,7 +1,7 @@ -From ded1a411d27dde558cc3d057cd65909e9cba1974 Mon Sep 17 00:00:00 2001 +From a6e4ec48f7ad6e64eb95bcd46e8656f1cef95cfd Mon Sep 17 00:00:00 2001 From: vegbir Date: Wed, 12 Jul 2023 08:25:20 +0000 -Subject: [PATCH 07/16] limit stat by quota period setting +Subject: [PATCH 07/15] limit stat by quota period setting Signed-off-by: vegbir --- @@ -9,10 +9,10 @@ Signed-off-by: vegbir 1 file changed, 12 insertions(+) diff --git a/src/proc_fuse.c b/src/proc_fuse.c -index 80db328..dfcd72c 100644 +index 0af559f..e69e867 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c -@@ -1079,6 +1079,8 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, +@@ -1087,6 +1087,8 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, size_t linelen = 0, total_len = 0; int curcpu = -1; /* cpu numbering starts at 0 */ int physcpu = 0; @@ -21,7 +21,7 @@ index 80db328..dfcd72c 100644 uint64_t user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guest_nice = 0; uint64_t user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0, -@@ -1127,6 +1129,13 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, +@@ -1138,6 +1140,13 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, if (!cpuset) return 0; @@ -30,12 +30,12 @@ index 80db328..dfcd72c 100644 + else + use_view = false; + if (use_view) -+ max_cpus = max_cpu_count(cg); ++ max_cpus = max_cpu_count(cg, cpu_cg); + f = fopen_cached("/proc/stat", "re", &fopen_cache); if (!f) return 0; -@@ -1175,6 +1184,9 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, +@@ -1186,6 +1195,9 @@ static int proc_stat_read(char *buf, size_t size, off_t offset, continue; } diff --git a/0008-diskstats-support-devicemapper-device.patch b/0008-diskstats-support-devicemapper-device.patch index 9c938518e1b7acd0f0d88c6f2e832d6c5262a0db..f3fb344ad9854a4155e96717a5bc19bcad855379 100644 --- a/0008-diskstats-support-devicemapper-device.patch +++ b/0008-diskstats-support-devicemapper-device.patch @@ -1,15 +1,15 @@ -From 21c359672300c687ad9b1f28c4c1be4ca00f590a Mon Sep 17 00:00:00 2001 +From 0dded445efa7b53886081beab5b74facf0378287 Mon Sep 17 00:00:00 2001 From: vegbir -Date: Wed, 12 Jul 2023 08:31:21 +0000 -Subject: [PATCH 08/16] diskstats support devicemapper device +Date: Thu, 27 Jul 2023 08:15:49 +0000 +Subject: [PATCH 08/15] diskstats support devicemapper device Signed-off-by: vegbir --- - src/proc_fuse.c | 99 ++++++++++++++++++++++++++++++++++++++----------- - 1 file changed, 77 insertions(+), 22 deletions(-) + src/proc_fuse.c | 133 ++++++++++++++++++++++++++++++++++++++++++------ + 1 file changed, 117 insertions(+), 16 deletions(-) diff --git a/src/proc_fuse.c b/src/proc_fuse.c -index dfcd72c..f68212d 100644 +index e69e867..1f732ff 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c @@ -638,6 +638,15 @@ void free_devinfo_list(struct devinfo *ptr) @@ -59,15 +59,99 @@ index dfcd72c..f68212d 100644 get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Read", &stats.read); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Write", &stats.write); get_blkio_io_value(io_serviced_str, stats.major, stats.minor, "Discard", &stats.discard); -@@ -800,27 +816,28 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, - if (stats.read || stats.write || stats.read_merged || stats.write_merged || +@@ -801,26 +817,111 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, stats.read_sectors || stats.write_sectors || stats.read_ticks || - stats.write_ticks || stats.ios_pgr || stats.total_ticks || stats.rq_ticks || -- stats.discard_merged || stats.discard_sectors || stats.discard_ticks) -- snprintf( -- lbuf, -- 256, -- "%u %u" /* major, minor */ + stats.write_ticks || stats.ios_pgr || stats.total_ticks || stats.rq_ticks || stats.discard || + stats.discard_merged || stats.discard_sectors || stats.discard_ticks) { ++ if (need_record_diskstats(stats.major, stats.minor)) { ++ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", ++ &stats.major, ++ &stats.minor, ++ tmp_dev_name, ++ &stats.read, ++ &stats.read_merged, ++ &stats.read_sectors, ++ &stats.read_ticks, ++ &stats.write, ++ &stats.write_merged, ++ &stats.write_sectors, ++ &stats.write_ticks, ++ &stats.ios_pgr, ++ &stats.total_ticks, ++ &stats.rq_ticks, ++ &stats.discard, ++ &stats.discard_merged, ++ &stats.discard_sectors, ++ &stats.discard_ticks); ++ } ++ ret = strnprintf( ++ lbuf, ++ sizeof(lbuf), ++ "%u %u" /* major, minor */ ++ " %s" /* dev_name */ ++ " %" PRIu64 /* read */ ++ " %" PRIu64 /* read_merged */ ++ " %" PRIu64 /* read_sectors */ ++ " %" PRIu64 /* read_ticks */ ++ " %" PRIu64 /* write */ ++ " %" PRIu64 /* write_merged */ ++ " %" PRIu64 /* write_sectors */ ++ " %" PRIu64 /* write_ticks */ ++ " %" PRIu64 /* ios_pgr */ ++ " %" PRIu64 /* total_ticks */ ++ " %" PRIu64 /* rq_ticks */ ++ " %" PRIu64 /* discard */ ++ " %" PRIu64 /* discard_merged */ ++ " %" PRIu64 /* discard_sectors */ ++ " %" PRIu64 /* discard_ticks */ ++ "\n", ++ stats.major, ++ stats.minor, ++ stats.dev_name, ++ stats.read, ++ stats.read_merged, ++ stats.read_sectors, ++ stats.read_ticks, ++ stats.write, ++ stats.write_merged, ++ stats.write_sectors, ++ stats.write_ticks, ++ stats.ios_pgr, ++ stats.total_ticks, ++ stats.rq_ticks, ++ stats.discard, ++ stats.discard_merged, ++ stats.discard_sectors, ++ stats.discard_ticks); ++ if (ret < 0) { ++ lxcfs_error("Insufficient buffer for %u:%u %s diskstats", ++ stats.major, stats.minor, stats.dev_name); ++ continue; ++ } ++ } else if (need_record_diskstats(stats.major, stats.minor)) { ++ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", ++ &stats.major, ++ &stats.minor, ++ tmp_dev_name, ++ &stats.read, ++ &stats.read_merged, ++ &stats.read_sectors, ++ &stats.read_ticks, ++ &stats.write, ++ &stats.write_merged, ++ &stats.write_sectors, ++ &stats.write_ticks, ++ &stats.ios_pgr, ++ &stats.total_ticks, ++ &stats.rq_ticks, ++ &stats.discard, ++ &stats.discard_merged, ++ &stats.discard_sectors, ++ &stats.discard_ticks); + ret = strnprintf( + lbuf, + sizeof(lbuf), + "%u %u" /* major, minor */ - " %s" /* dev_name */ - " %" PRIu64 /* read */ - " %" PRIu64 /* read_merged */ @@ -80,83 +164,29 @@ index dfcd72c..f68212d 100644 - " %" PRIu64 /* ios_pgr */ - " %" PRIu64 /* total_ticks */ - " %" PRIu64 /* rq_ticks */ +- " %" PRIu64 /* discard */ - " %" PRIu64 /* discard_merged */ - " %" PRIu64 /* discard_sectors */ - " %" PRIu64 /* discard_ticks */ -- "\n", -+ stats.discard_merged || stats.discard_sectors || stats.discard_ticks) { -+ if (need_record_diskstats(stats.major, stats.minor)) { -+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", -+ &stats.major, -+ &stats.minor, -+ tmp_dev_name, -+ &stats.read, -+ &stats.read_merged, -+ &stats.read_sectors, -+ &stats.read_ticks, -+ &stats.write, -+ &stats.write_merged, -+ &stats.write_sectors, -+ &stats.write_ticks, -+ &stats.ios_pgr, -+ &stats.total_ticks, -+ &stats.rq_ticks, -+ &stats.discard_merged, -+ &stats.discard_sectors, -+ &stats.discard_ticks); -+ } -+ snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", ++ " %s" /* dev_name */ ++ " %" PRIu64 /* read */ ++ " %" PRIu64 /* read_merged */ ++ " %" PRIu64 /* read_sectors */ ++ " %" PRIu64 /* read_ticks */ ++ " %" PRIu64 /* write */ ++ " %" PRIu64 /* write_merged */ ++ " %" PRIu64 /* write_sectors */ ++ " %" PRIu64 /* write_ticks */ ++ " %" PRIu64 /* ios_pgr */ ++ " %" PRIu64 /* total_ticks */ ++ " %" PRIu64 /* rq_ticks */ ++ " %" PRIu64 /* discard */ ++ " %" PRIu64 /* discard_merged */ ++ " %" PRIu64 /* discard_sectors */ ++ " %" PRIu64 /* discard_ticks */ + "\n", stats.major, stats.minor, - stats.dev_name, -@@ -838,8 +855,46 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, - stats.discard_merged, - stats.discard_sectors, - stats.discard_ticks); -- else -+ } else if (need_record_diskstats(stats.major, stats.minor)) { -+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", -+ &stats.major, -+ &stats.minor, -+ tmp_dev_name, -+ &stats.read, -+ &stats.read_merged, -+ &stats.read_sectors, -+ &stats.read_ticks, -+ &stats.write, -+ &stats.write_merged, -+ &stats.write_sectors, -+ &stats.write_ticks, -+ &stats.ios_pgr, -+ &stats.total_ticks, -+ &stats.rq_ticks, -+ &stats.discard_merged, -+ &stats.discard_sectors, -+ &stats.discard_ticks); -+ snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", -+ stats.major, -+ stats.minor, -+ stats.dev_name, -+ stats.read, -+ stats.read_merged, -+ stats.read_sectors, -+ stats.read_ticks, -+ stats.write, -+ stats.write_merged, -+ stats.write_sectors, -+ stats.write_ticks, -+ stats.ios_pgr, -+ stats.total_ticks, -+ stats.rq_ticks, -+ stats.discard_merged, -+ stats.discard_sectors, -+ stats.discard_ticks); -+ } else { - continue; -+ } - - l = snprintf(cache, cache_size, "%s", lbuf); - if (l < 0) { -- 2.41.0 diff --git a/0009-lxcfs-add-proc-partitions.patch b/0009-lxcfs-add-proc-partitions.patch index f4987944a8ed74f26b5ca971f57cb90c2db98c43..9f536b3b3d7bacd2792a425d9991e4b41c44b360 100644 --- a/0009-lxcfs-add-proc-partitions.patch +++ b/0009-lxcfs-add-proc-partitions.patch @@ -1,7 +1,7 @@ -From 60b82439ccb656ffe79c6499d251627404fd388c Mon Sep 17 00:00:00 2001 +From f230a8816877cc803d52661a444cb6d1b9d55f96 Mon Sep 17 00:00:00 2001 From: vegbir -Date: Wed, 12 Jul 2023 08:42:05 +0000 -Subject: [PATCH 09/16] lxcfs add proc partitions +Date: Thu, 27 Jul 2023 08:28:00 +0000 +Subject: [PATCH 09/15] lxcfs add proc partitions Signed-off-by: vegbir --- @@ -24,7 +24,7 @@ index 8d9d6eb..fcf408a 100644 LXC_TYPE_SYS_DEVICES, LXC_TYPE_SYS_DEVICES_SYSTEM, diff --git a/src/proc_fuse.c b/src/proc_fuse.c -index f68212d..e1896dd 100644 +index 1f732ff..0dbbefe 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c @@ -119,14 +119,15 @@ __lxcfs_fuse_ops int proc_getattr(const char *path, struct stat *sb) @@ -70,7 +70,7 @@ index f68212d..e1896dd 100644 if (type == -1) return -ENOENT; -@@ -921,6 +925,115 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, +@@ -975,6 +979,115 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, return total_len; } @@ -186,7 +186,7 @@ index f68212d..e1896dd 100644 #ifdef RELOADTEST static inline void iwashere(void) { -@@ -1855,6 +1968,12 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size, +@@ -1912,6 +2025,12 @@ __lxcfs_fuse_ops int proc_read(const char *path, char *buf, size_t size, return read_file_fuse_with_offset(LXC_TYPE_PROC_SLABINFO_PATH, buf, size, offset, f); diff --git a/0010-lxcfs-proc_diskstats_read-func-obtain-data-from-blki.patch b/0010-lxcfs-proc_diskstats_read-func-obtain-data-from-blki.patch index 1b450c65746c5ed81a3eebd557802cd86f05a427..8ecbf63e92146ace2ac341e300b49cf9270f8e03 100644 --- a/0010-lxcfs-proc_diskstats_read-func-obtain-data-from-blki.patch +++ b/0010-lxcfs-proc_diskstats_read-func-obtain-data-from-blki.patch @@ -1,7 +1,7 @@ -From b610b5534da182a7618d396da481e22624e5e7cf Mon Sep 17 00:00:00 2001 +From d7582ba91869e19936c76f4d63b803d82d8e1caf Mon Sep 17 00:00:00 2001 From: vegbir Date: Wed, 12 Jul 2023 08:53:42 +0000 -Subject: [PATCH 10/16] lxcfs proc_diskstats_read func obtain data from blki +Subject: [PATCH 10/15] lxcfs proc_diskstats_read func obtain data from blki Signed-off-by: vegbir --- diff --git a/0011-add-secure-compile-option-in-meson.patch b/0011-add-secure-compile-option-in-meson.patch index 9966ffaf8c5939e864a1e5ed1cfbfba87a87fc2a..99b90f7e7050efa171d2020aca5a466b9499532a 100644 --- a/0011-add-secure-compile-option-in-meson.patch +++ b/0011-add-secure-compile-option-in-meson.patch @@ -1,13 +1,13 @@ -From 4e468a948874f661a53b498ac1a30012c7860fd1 Mon Sep 17 00:00:00 2001 +From cd4988df0a9f7140758c0429485322dc6d9467d5 Mon Sep 17 00:00:00 2001 From: vegbir Date: Fri, 14 Jul 2023 07:54:27 +0000 -Subject: [PATCH 11/16] add secure compile option in meson +Subject: [PATCH 11/15] add secure compile option in meson Signed-off-by: vegbir --- Makefile | 2 +- - meson.build | 3 +++ - 2 files changed, 4 insertions(+), 1 deletion(-) + meson.build | 4 ++++ + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 94f2021..38fbe04 100644 @@ -23,16 +23,24 @@ index 94f2021..38fbe04 100644 .PHONY: meson meson: diff --git a/meson.build b/meson.build -index 379757f..56338b6 100644 +index a0289ad..7eb1f06 100644 --- a/meson.build +++ b/meson.build -@@ -109,6 +109,9 @@ possible_cc_flags = [ +@@ -12,6 +12,7 @@ project( + 'b_pie=true', + 'c_std=gnu11', + 'warning_level=2', ++ 'optimization=2', + ], + meson_version: '>= 0.50') + +@@ -109,6 +110,9 @@ possible_cc_flags = [ '-Wreturn-local-addr', '-fsanitize=cfi', '-Wstringop-overflow', + '-ftrapv', + '-fPIC', -+ '-O2 -D_FORTIFY_SOURCE=2', ++ '-D_FORTIFY_SOURCE=2', ] possible_link_flags = [ diff --git a/0012-lxcfs-adapt-4.18-kernel.patch b/0012-lxcfs-adapt-4.18-kernel.patch index 141425de05736fdd43d8e26a7c180f20b3ce17e6..26c30a1446963b7cb17bf8a3da5342cd040f893c 100644 --- a/0012-lxcfs-adapt-4.18-kernel.patch +++ b/0012-lxcfs-adapt-4.18-kernel.patch @@ -1,7 +1,7 @@ -From 390636cc3246ecaaea6903ae4f97552248b663c5 Mon Sep 17 00:00:00 2001 +From 60eefa396251acebd02f06538ccee1081dcdcd0d Mon Sep 17 00:00:00 2001 From: vegbir -Date: Fri, 14 Jul 2023 09:02:39 +0000 -Subject: [PATCH 12/16] lxcfs adapt 4.18 kernel +Date: Thu, 27 Jul 2023 09:10:52 +0000 +Subject: [PATCH 12/15] lxcfs adapt 4.18 kernel Signed-off-by: vegbir --- @@ -9,7 +9,7 @@ Signed-off-by: vegbir 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/src/proc_fuse.c b/src/proc_fuse.c -index e1896dd..fa5b055 100644 +index 0dbbefe..392115c 100644 --- a/src/proc_fuse.c +++ b/src/proc_fuse.c @@ -686,8 +686,8 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, @@ -116,7 +116,7 @@ index e1896dd..fa5b055 100644 - stats.total_ticks = stats.total_ticks / 1000000; + stats.total_ticks = total_ticks / 1000000; - memset(lbuf, 0, 256); + memset(lbuf, 0, sizeof(lbuf)); if (stats.read || stats.write || stats.read_merged || stats.write_merged || -- 2.41.0 diff --git a/0013-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch b/0013-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch index bbf66985a31a0cd18e03de22e73dded044803c6a..fc1bf103bd47e1d259e725d06c880b0134e60079 100644 --- a/0013-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch +++ b/0013-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch @@ -1,7 +1,7 @@ -From 9b853f8d16f08e837ec330c5906e918ebac70d78 Mon Sep 17 00:00:00 2001 +From 30f3e8cf0c6e34c5a8e4dd9d599c6c96646bd2ba Mon Sep 17 00:00:00 2001 From: vegbir Date: Sat, 15 Jul 2023 03:43:12 +0000 -Subject: [PATCH 13/16] enable cfs option to show correct proc cpuinfo view +Subject: [PATCH 13/15] enable cfs option to show correct proc cpuinfo view Signed-off-by: vegbir --- diff --git a/0014-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch b/0014-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch index a0707a38eb1a4b08b8de80b02f9cc069baae0243..c2618704ec1383e311bd7480901deb3a79098b7c 100644 --- a/0014-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch +++ b/0014-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch @@ -1,7 +1,7 @@ -From 35b8b46aeea72d27d931b0bc767ce1e8d3b32db4 Mon Sep 17 00:00:00 2001 +From 2c07195cd633c270ddcc6ef5349dbbc7063302d5 Mon Sep 17 00:00:00 2001 From: vegbir Date: Sat, 15 Jul 2023 04:25:53 +0000 -Subject: [PATCH 14/16] fix pidfd_open pidfd_send_signal function compilation +Subject: [PATCH 14/15] fix pidfd_open pidfd_send_signal function compilation Signed-off-by: vegbir --- diff --git a/0016-adapt-meson-build-install.patch b/0015-adapt-meson-build-install.patch similarity index 52% rename from 0016-adapt-meson-build-install.patch rename to 0015-adapt-meson-build-install.patch index 03055d91903958c2de608d8f9cdbf946d1678c35..3ed0994a5f5c921aed248a81e87cc633936a13d6 100644 --- a/0016-adapt-meson-build-install.patch +++ b/0015-adapt-meson-build-install.patch @@ -1,13 +1,13 @@ -From 4dadabe36fb3277996870869c62d5cffab72f781 Mon Sep 17 00:00:00 2001 +From c79ce840026f83a8582d31e5e80529f0c230126c Mon Sep 17 00:00:00 2001 From: vegbir -Date: Mon, 17 Jul 2023 08:36:34 +0000 -Subject: [PATCH 16/16] adapt meson build & install +Date: Thu, 27 Jul 2023 09:18:15 +0000 +Subject: [PATCH 15/15] adapt meson build & install Signed-off-by: vegbir --- Makefile | 2 +- - config/init/meson.build | 3 ++- - 2 files changed, 3 insertions(+), 2 deletions(-) + config/init/meson.build | 1 + + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 38fbe04..891d7ad 100644 @@ -23,18 +23,9 @@ index 38fbe04..891d7ad 100644 .PHONY: dist dist: meson diff --git a/config/init/meson.build b/config/init/meson.build -index 8445955..c781b59 100644 +index 5200570..c781b59 100644 --- a/config/init/meson.build +++ b/config/init/meson.build -@@ -2,7 +2,7 @@ - - if 'systemd' in init_script - systemd = dependency('systemd') -- systemd_system_unit_dir = get_option('prefix') + systemd.get_pkgconfig_variable('systemdsystemunitdir') -+ systemd_system_unit_dir = systemd.get_pkgconfig_variable('systemdsystemunitdir') - systemd_service = custom_target( - 'lxcfs.service', - input: 'systemd/lxcfs.service.in', @@ -14,6 +14,7 @@ if 'systemd' in init_script '@OUTPUT@', ], diff --git a/0015-proc-fix-proc-diskstats-output-format.patch b/0015-proc-fix-proc-diskstats-output-format.patch deleted file mode 100644 index 7fb6d9e2eaaa1ecb141110cdd8d66e8305429a34..0000000000000000000000000000000000000000 --- a/0015-proc-fix-proc-diskstats-output-format.patch +++ /dev/null @@ -1,92 +0,0 @@ -From 19bedb98bf93ac67d78cc0606d66e03217e15cbb Mon Sep 17 00:00:00 2001 -From: vegbir -Date: Sat, 15 Jul 2023 08:15:57 +0000 -Subject: [PATCH 15/16] proc fix proc diskstats output format - -Signed-off-by: vegbir ---- - src/proc_fuse.c | 24 +++++++++++++++++++----- - 1 file changed, 19 insertions(+), 5 deletions(-) - -diff --git a/src/proc_fuse.c b/src/proc_fuse.c -index fa5b055..97bfff8 100644 ---- a/src/proc_fuse.c -+++ b/src/proc_fuse.c -@@ -810,10 +810,10 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, - memset(lbuf, 0, 256); - if (stats.read || stats.write || stats.read_merged || stats.write_merged || - stats.read_sectors || stats.write_sectors || stats.read_ticks || -- stats.write_ticks || stats.ios_pgr || stats.total_ticks || stats.rq_ticks || -+ stats.write_ticks || stats.ios_pgr || stats.total_ticks || stats.rq_ticks || stats.discard || - stats.discard_merged || stats.discard_sectors || stats.discard_ticks) { - if (need_record_diskstats(stats.major, stats.minor)) { -- sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", -+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", - &stats.major, - &stats.minor, - tmp_dev_name, -@@ -828,11 +828,12 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, - &stats.ios_pgr, - &stats.total_ticks, - &stats.rq_ticks, -+ &stats.discard, - &stats.discard_merged, - &stats.discard_sectors, - &stats.discard_ticks); - } -- snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", -+ ret = snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", - stats.major, - stats.minor, - stats.dev_name, -@@ -847,11 +848,17 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, - stats.ios_pgr, - stats.total_ticks, - stats.rq_ticks, -+ stats.discard, - stats.discard_merged, - stats.discard_sectors, - stats.discard_ticks); -+ if(ret >= 256) { -+ lxcfs_error("Insufficient buffer for %u:%u %s diskstats", -+ stats.major, stats.minor, stats.dev_name); -+ continue; -+ } - } else if (need_record_diskstats(stats.major, stats.minor)) { -- sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", -+ sscanf(line, "%u %u %71s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", - &stats.major, - &stats.minor, - tmp_dev_name, -@@ -866,10 +873,11 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, - &stats.ios_pgr, - &stats.total_ticks, - &stats.rq_ticks, -+ &stats.discard, - &stats.discard_merged, - &stats.discard_sectors, - &stats.discard_ticks); -- snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", -+ ret = snprintf(lbuf, 256, "%u %u %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n", - stats.major, - stats.minor, - stats.dev_name, -@@ -884,9 +892,15 @@ static int proc_diskstats_read(char *buf, size_t size, off_t offset, - stats.ios_pgr, - stats.total_ticks, - stats.rq_ticks, -+ stats.discard, - stats.discard_merged, - stats.discard_sectors, - stats.discard_ticks); -+ if(ret >= 256) { -+ lxcfs_error("Insufficient buffer for %u:%u %s diskstats", -+ stats.major, stats.minor, stats.dev_name); -+ continue; -+ } - } else { - continue; - } --- -2.41.0 - diff --git a/lxcfs-5.0.3.tar.gz b/lxcfs-5.0.3.tar.gz deleted file mode 100644 index 6db7e216ff160209f9e5c94c99a0c30e2c436cac..0000000000000000000000000000000000000000 Binary files a/lxcfs-5.0.3.tar.gz and /dev/null differ diff --git a/lxcfs-5.0.4.tar.gz b/lxcfs-5.0.4.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..7cd442c6fa05ec75e456ef7c5572824de2547fc6 Binary files /dev/null and b/lxcfs-5.0.4.tar.gz differ diff --git a/lxcfs.spec b/lxcfs.spec index 142eadb9f76d751f119f59a6a0fd2e37443f0581..872801fe626138d5ac0940ceaa27c1765361a6e4 100644 --- a/lxcfs.spec +++ b/lxcfs.spec @@ -3,7 +3,7 @@ #Basic Information Name: lxcfs -Version: 5.0.3 +Version: 5.0.4 Release: 1 Summary: FUSE filesystem for LXC License: LGPL 2.1+ @@ -24,8 +24,7 @@ Patch9011: 0011-add-secure-compile-option-in-meson.patch Patch9012: 0012-lxcfs-adapt-4.18-kernel.patch Patch9013: 0013-enable-cfs-option-to-show-correct-proc-cpuinfo-view.patch Patch9014: 0014-fix-pidfd_open-pidfd_send_signal-function-compilatio.patch -Patch9015: 0015-proc-fix-proc-diskstats-output-format.patch -Patch9016: 0016-adapt-meson-build-install.patch +Patch9015: 0015-adapt-meson-build-install.patch #Dependency BuildRequires: meson python3-jinja2 help2man @@ -82,6 +81,12 @@ fi %{_unitdir}/* %changelog +* Thu July 27 2023 yangjiaqi - 5.0.4-1 +- Type:bugfix +- CVE:NA +- SUG:NA +- DESC:upgrade to 5.0.4 + * Mon July 17 2023 yangjiaqi - 5.0.3-1 - Type:bugfix - CVE:NA