On Thu, 24 Oct 2024 02:18:59 +0300 Dmitry Kozlyuk <dmitry.kozl...@gmail.com> wrote:
> +static int > +enable_shared_hugepage_coredump(void) > +{ > + const char *path = "/proc/self/coredump_filter"; > + const unsigned long shared_hugepage_flag = RTE_BIT64(6); > + > + FILE *f; > + uint64_t coredump_filter; > + > + f = fopen(path, "r"); > + if (f == NULL) { > + rte_errno = errno; > + EAL_LOG(ERR, "Failed to open %s for reading: %s", path, > strerror(errno)); > + return -1; > + } > + > + if (fscanf(f, "%"SCNx64, &coredump_filter) != 1) { > + rte_errno = errno; > + EAL_LOG(ERR, "Failed to parse %s: %s", path, strerror(errno)); > + fclose(f); > + return -1; > + } > + > + fclose(f); > + > + if (coredump_filter & shared_hugepage_flag) > + return 0; > + > + f = fopen(path, "w"); > + if (f == NULL) { > + rte_errno = errno; > + EAL_LOG(ERR, "Failed to open %s for writing: %s", path, > strerror(errno)); > + return -1; > + } > + > + coredump_filter |= shared_hugepage_flag; > + if (fprintf(f, "%"PRIx64, coredump_filter) <= 0) { > + rte_errno = EIO; > + EAL_LOG(ERR, "Failed to write %"PRIx64" to %s", > coredump_filter, path); > + fclose(f); > + return -1; > + } > + > + fclose(f); > + return 0; > +} > + Having a process set a system global value like coredump_filter via an internal call seems like a potential problem. What about other processes on the system? It may not even be allowed if using a hardened kernel. I would prefer that madvise() be used, and document the required change to coredump_filter.