From: Kris Van Hees <kris.van.hees@oracle.com>
To: ealmorshdy@d-matrix.ai
Cc: dtrace@lists.linux.dev, Kris Van Hees <kris.van.hees@oracle.com>,
Nick Alcock <nix@esperi.org.uk>
Subject: Re: [PATCH 1/2] libproc: fix readlink() typo in Psystem_daemon()
Date: Wed, 18 Nov 2026 23:42:41 -0500 [thread overview]
Message-ID: <av5-QbziRJgOa50Y@oracle.com> (raw)
In-Reply-To: <20261118-b4-bug008-daemon-readlink-v1-1-187c9eb22d11@d-matrix.ai>
On Wed, Nov 18, 2026 at 11:25:04PM +0000, Eslam Almorshdy via B4 Relay wrote:
> From: Eslam Almorshdy <ealmorshdy@d-matrix.ai>
>
> readlink() returns the number of bytes it stored or -1, never 0, so
> the check for a regular file outside /var never ran.
Thanks for finding and fixing this bug!
> Signed-off-by: Eslam Almorshdy <ealmorshdy@d-matrix.ai>
Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
> ---
> libproc/Pcontrol.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libproc/Pcontrol.c b/libproc/Pcontrol.c
> index f8440d5b..ece074e0 100644
> --- a/libproc/Pcontrol.c
> +++ b/libproc/Pcontrol.c
> @@ -3045,7 +3045,7 @@ Psystem_daemon(pid_t pid, uid_t useruid, const char *sysslice)
> */
> memset(buf, '\0', sizeof(buf));
> if (S_ISREG(s.st_mode) &&
> - (readlink(procname, buf, sizeof(buf)-1) == 0)) {
> + (readlink(procname, buf, sizeof(buf)-1) > 0)) {
> if((buf[0] == '/') && (strcmp(buf, "/var/") != 0))
> return 0;
> }
>
> --
> 2.55.0
>
next prev parent reply other threads:[~2026-11-19 4:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 23:25 [PATCH 0/2] Fix a readlink() typo in Psystem_daemon() Eslam Almorshdy via B4 Relay
2026-11-18 23:25 ` [PATCH 1/2] libproc: fix " Eslam Almorshdy via B4 Relay
2026-11-19 4:42 ` Kris Van Hees [this message]
2026-11-18 23:25 ` [PATCH 2/2] test: add test for system daemons with regular files as streams Eslam Almorshdy via B4 Relay
2026-11-19 4:42 ` Kris Van Hees
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=av5-QbziRJgOa50Y@oracle.com \
--to=kris.van.hees@oracle.com \
--cc=dtrace@lists.linux.dev \
--cc=ealmorshdy@d-matrix.ai \
--cc=nix@esperi.org.uk \
/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