From: Arseny Maslennikov <arseny@altlinux.org>
To: ALT Linux Team development discussions <devel@lists.altlinux.org>
Subject: Re: [devel] [PATCH hasher-priv v3 3/7] chrootuid: explicitly reset signal mask before forking off payload
Date: Fri, 3 Dec 2021 18:03:31 +0300
Message-ID: <Yaoxw9Io5ox27Gjd@cello> (raw)
In-Reply-To: <20211201192336.GA12855@altlinux.org>
[-- Attachment #1: Type: text/plain, Size: 1967 bytes --]
On Wed, Dec 01, 2021 at 10:23:37PM +0300, Dmitry V. Levin wrote:
> On Tue, Aug 24, 2021 at 11:24:32AM +0300, Arseny Maslennikov wrote:
> > Signed-off-by: Arseny Maslennikov <arseny@altlinux.org>
> > ---
> > hasher-priv/chrootuid.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/hasher-priv/chrootuid.c b/hasher-priv/chrootuid.c
> > index 89c112e..357d3ef 100644
> > --- a/hasher-priv/chrootuid.c
> > +++ b/hasher-priv/chrootuid.c
> > @@ -134,6 +134,11 @@ chrootuid(uid_t uid, gid_t gid, const char *ehome,
> > /* Set close-on-exec flag on all non-standard descriptors. */
> > cloexec_fds();
> >
> > + sigset_t sigmask;
> > +
> > + sigemptyset(&sigmask);
> > + sigprocmask(SIG_SETMASK, &sigmask, NULL);
> > +
> > block_signal_handler(SIGCHLD, SIG_BLOCK);
> >
> > if ((pid = fork()) < 0)
>
> Assuming it really should reset the signal mask (I don't have the context
Parent processes use signalfd(2) to handle signals and block those
signals before opening the signalfd.
% git grep -nF 'sigprocmask('
hasher-priv/caller_server.c:236: sigprocmask(SIG_SETMASK, &mask, NULL);
hasher-priv/chrootuid.c:140: sigprocmask(SIG_SETMASK, &sigmask, NULL);
hasher-priv/hasher-privd.c:315: sigprocmask(SIG_SETMASK, &mask, NULL);
hasher-priv/signal.c:27: if (sigprocmask(what, &set, 0) < 0)
> to say whether it should or not), looks like it should rather be written as
>
> block_signal_handler(SIGCHLD, SIG_SETMASK);
>
> instead of
>
> sigset_t sigmask;
> sigemptyset(&sigmask);
> sigprocmask(SIG_SETMASK, &sigmask, NULL);
> block_signal_handler(SIGCHLD, SIG_BLOCK);
>
> ?
I'd never seen a call like block_signal_handler(*, SIG_SETMASK)
in hasher-priv codebase at the time + I decided to make the patches as
non-intrusive to the unchanged part of the codebase as possible.
That's why I wrote this as is; I don't mind to change it, though.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2021-12-03 15:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 8:24 [devel] [PATCH hasher-priv v3 0/7] hasher-privd Arseny Maslennikov
2021-08-24 8:24 ` [devel] [PATCH hasher-priv v3 1/7] Turn hasher-priv into a daemon Arseny Maslennikov
2021-08-24 8:24 ` [devel] [PATCH hasher-priv v3 2/7] sockets: xsendmsg: get rid of SIGPIPE on socket writes Arseny Maslennikov
2021-08-24 8:24 ` [devel] [PATCH hasher-priv v3 3/7] chrootuid: explicitly reset signal mask before forking off payload Arseny Maslennikov
2021-12-01 19:23 ` Dmitry V. Levin
2021-12-03 15:03 ` Arseny Maslennikov [this message]
2021-12-03 16:06 ` Dmitry V. Levin
2021-08-24 8:24 ` [devel] [PATCH hasher-priv v3 4/7] Link with libsetproctitle by Dmitry V. Levin Arseny Maslennikov
2021-08-24 8:24 ` [devel] [PATCH hasher-priv v3 5/7] daemon: set titles for subprocesses Arseny Maslennikov
2021-08-24 8:24 ` [devel] [PATCH hasher-priv v3 6/7] Add systemd and sysvinit service files Arseny Maslennikov
2021-08-24 8:24 ` [devel] [PATCH hasher-priv v3 7/7] Install hasher-priv without set ugids Arseny Maslennikov
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=Yaoxw9Io5ox27Gjd@cello \
--to=arseny@altlinux.org \
--cc=devel@lists.altlinux.org \
/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
ALT Linux Team development discussions
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel/0 devel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel devel/ http://lore.altlinux.org/devel \
devel@altlinux.org devel@altlinux.ru devel@lists.altlinux.org devel@lists.altlinux.ru devel@linux.iplabs.ru mandrake-russian@linuxteam.iplabs.ru sisyphus@linuxteam.iplabs.ru
public-inbox-index devel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git