From: Stephen Hemminger <stephen@networkplumber.org>
To: Dmitry Kozlyuk <dmitry.kozliuk@gmail.com>
Cc: dev@dpdk.org, Anatoly Burakov <anatoly.burakov@intel.com>,
Lewis Donzis <lew@perftech.com>
Subject: Re: [PATCH] eal: support including mapped memory in core dump
Date: Thu, 24 Oct 2024 09:38:14 -0700 [thread overview]
Message-ID: <20241024093814.779d86c7@hermes.local> (raw)
In-Reply-To: <20241023231859.1323727-1-kozlyuk@bifit.com>
On Thu, 24 Oct 2024 02:18:59 +0300
Dmitry Kozlyuk <dmitry.kozliuk@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.
prev parent reply other threads:[~2024-10-24 16:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-23 23:18 Dmitry Kozlyuk
2024-10-24 2:19 ` Stephen Hemminger
2024-10-24 2:31 ` Stephen Hemminger
2024-10-24 7:07 ` Morten Brørup
2024-10-24 7:22 ` Morten Brørup
2024-10-24 8:25 ` Dmitry Kozlyuk
2024-10-24 12:55 ` Lewis Donzis
2024-10-24 16:38 ` Stephen Hemminger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241024093814.779d86c7@hermes.local \
--to=stephen@networkplumber.org \
--cc=anatoly.burakov@intel.com \
--cc=dev@dpdk.org \
--cc=dmitry.kozliuk@gmail.com \
--cc=lew@perftech.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).