linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Michael Kerrisk
	<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	"linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	GNU C Library
	<libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org>
Cc: Florian Weimer <fweimer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH] getcwd.3: Mention that "(unreachable)" is no longer returned for glibc > 2.27.
Date: Mon, 5 Feb 2018 12:34:49 -0800	[thread overview]
Message-ID: <94a3f8a3-5c0e-9fa5-ce2c-3f7e4b097a97@redhat.com> (raw)

Michael,

With glibc fix 52a713fdd0a30e1bd79818e2e3c4ab44ddca1a94 for
CVE-2018-1000001 (Sourceware BZ #22679) the implementation in the
just released glibc 2.27 has been changed such that instead of
returning "(unreachable)" the implementation now returns ENOENT
as it would have if the current directory had been unlinked.

I see that in 2015 the quirk was documented in commit
a2ac97c78bf05a55f8f616fc39a4724372dcfa95, and this is no longer
true with glibc 2.27, but may continue to be true in other C libraries,
so I reference NOTES from the paragraph in the central text.

Signed-off-by: Carlos O'Donell <carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

diff --git a/man3/getcwd.3 b/man3/getcwd.3
index ff953a7d0..3c41736c9 100644
--- a/man3/getcwd.3
+++ b/man3/getcwd.3
@@ -91,7 +91,9 @@ the current directory into another mount namespace.
 When dealing with paths from untrusted sources, callers of these
 functions should consider checking whether the returned path starts
 with '/' or '(' to avoid misinterpreting an unreachable path
-as a relative path.
+as a relative path. This is no longer true under some C libraries,
+see
+.BR NOTES .
 .PP
 The
 .BR getcwd ()
@@ -270,6 +272,16 @@ generic implementation is called.
 Only in that case can
 these calls fail under Linux with
 .BR EACCES .
+.PP
+Since Linux commit v2.6.36 which added "(unreachable)" the glibc
+.BR getcwd ()
+has failed to conform to POSIX and returned a relative path when the API
+contract requires an absolute path. With glibc 2.27 onwards this is corrected;
+calling
+.BR getcwd ()
+from such a path will now result in failure with
+.BR ENOENT .
+
 .PP
 These functions are often used to save the location of the current working
 directory for the purpose of returning to it later.
---

-- 
Cheers,
Carlos.
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2018-02-05 20:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-05 20:34 Carlos O'Donell [this message]
2018-04-12 11:50 ` [PATCH] getcwd.3: Mention that "(unreachable)" is no longer returned for glibc > 2.27 Michael Kerrisk (man-pages)

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=94a3f8a3-5c0e-9fa5-ce2c-3f7e4b097a97@redhat.com \
    --to=carlos-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
    --cc=fweimer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org \
    --cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.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
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).