From: Kuniyuki Iwashima <kuniyu@amazon.com>
To: <brauner@kernel.org>
Cc: <bluca@debian.org>, <daan.j.demeyer@gmail.com>,
<davem@davemloft.net>, <david@readahead.eu>,
<edumazet@google.com>, <horms@kernel.org>, <jack@suse.cz>,
<kuba@kernel.org>, <kuniyu@amazon.com>, <lennart@poettering.net>,
<linux-fsdevel@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<me@yhndnzj.com>, <netdev@vger.kernel.org>, <oleg@redhat.com>,
<pabeni@redhat.com>, <viro@zeniv.linux.org.uk>,
<zbyszek@in.waw.pl>
Subject: Re: [PATCH RFC 3/3] coredump: support AF_UNIX sockets
Date: Wed, 30 Apr 2025 17:25:19 -0700 [thread overview]
Message-ID: <20250501003048.49502-1-kuniyu@amazon.com> (raw)
In-Reply-To: <20250430-work-coredump-socket-v1-3-2faf027dbb47@kernel.org>
From: Christian Brauner <brauner@kernel.org>
Date: Wed, 30 Apr 2025 13:05:03 +0200
> @@ -801,6 +837,49 @@ void do_coredump(const kernel_siginfo_t *siginfo)
> }
> break;
> }
> + case COREDUMP_SOCK: {
> + struct file *file __free(fput) = NULL;
> + struct sockaddr_un unix_addr = {
> + .sun_family = AF_UNIX,
> + };
> + struct sockaddr_storage *addr;
> +
> + retval = strscpy(unix_addr.sun_path, cn.corename, sizeof(unix_addr.sun_path));
> + if (retval < 0)
> + goto close_fail;
> +
> + file = __sys_socket_file(AF_UNIX, SOCK_STREAM, 0);
> + if (IS_ERR(file))
> + goto close_fail;
> +
> + /*
> + * It is possible that the userspace process which is
> + * supposed to handle the coredump and is listening on
> + * the AF_UNIX socket coredumps. This should be fine
> + * though. If this was the only process which was
> + * listen()ing on the AF_UNIX socket for coredumps it
> + * obviously won't be listen()ing anymore by the time it
> + * gets here. So the __sys_connect_file() call will
> + * often fail with ECONNREFUSED and the coredump.
> + *
> + * In general though, userspace should just mark itself
> + * non dumpable and not do any of this nonsense. We
> + * shouldn't work around this.
> + */
> + addr = (struct sockaddr_storage *)(&unix_addr);
> + retval = __sys_connect_file(file, addr, sizeof(unix_addr), O_CLOEXEC);
The 3rd argument should be offsetof(struct sockaddr_un, sun_path)
+ retval of strscpy() above ?
I guess you could see an unexpected error when
CONFIG_INIT_STACK_NONE=y and cn.corename has garbage at tail.
next prev parent reply other threads:[~2025-05-01 0:31 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 11:05 [PATCH RFC 0/3] coredump: support AF_UNIX sockets Christian Brauner
2025-04-30 11:05 ` [PATCH RFC 1/3] coredump: massage format_corname() Christian Brauner
2025-04-30 11:05 ` [PATCH RFC 2/3] coredump: massage do_coredump() Christian Brauner
2025-04-30 11:05 ` [PATCH RFC 3/3] coredump: support AF_UNIX sockets Christian Brauner
2025-04-30 11:14 ` Christian Brauner
2025-05-01 0:25 ` Kuniyuki Iwashima [this message]
2025-04-30 11:14 ` [PATCH RFC 0/3] " Christian Brauner
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=20250501003048.49502-1-kuniyu@amazon.com \
--to=kuniyu@amazon.com \
--cc=bluca@debian.org \
--cc=brauner@kernel.org \
--cc=daan.j.demeyer@gmail.com \
--cc=davem@davemloft.net \
--cc=david@readahead.eu \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jack@suse.cz \
--cc=kuba@kernel.org \
--cc=lennart@poettering.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=me@yhndnzj.com \
--cc=netdev@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=pabeni@redhat.com \
--cc=viro@zeniv.linux.org.uk \
--cc=zbyszek@in.waw.pl \
/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).