From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26399 invoked by alias); 13 Apr 2017 17:33:52 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 26383 invoked by uid 89); 13 Apr 2017 17:33:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.4 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-qk0-f179.google.com X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=TUkuU6jenamtBCLpqxQh/bI8sGGpgWejY28ReVyABT4=; b=uCCJWIjzHD4ZSL/zdoM0kNUfuomXBDDeqVf8QFxD17HiAEmJJ0qvmt2MenXh851v59 JpJDsAtw7/hpyIqsBx8i6ok2n4/iDTd82uPpEGF16y2D5Ks/i45l5sBe1j5ROaWuCbzv 3HjvNLRgXw1xgJR8+c5jKbFxa1TsyQKC1q9Azrj2kmupSyStZJEas1a1z9PSXgy+JIQg aYHzMcxGb5ZxP1V/i60JUEhaTU6E/i4sZm4eqfC847Lh4p7FemACE/0ryzScKc7dnRCO qubX38+tauASOmwagg6hx4H6nMzg6eF1RhcnkOTDXU5vcR2lnMp3BLRonhlTSxMcmpM/ Q4AA== X-Gm-Message-State: AN3rC/5Z8Z6GYS6Dfx4ocZAOktxb+tpehWDfFe4mhA1PvGL7i5LQAI+y zyb5tD6qY2/LRI/zZEMxvg== X-Received: by 10.55.4.6 with SMTP id 6mr3480968qke.222.1492104830143; Thu, 13 Apr 2017 10:33:50 -0700 (PDT) Subject: Re: [PATCH] Assume that O_NOFOLLOW is always defined To: libc-alpha@sourceware.org References: <20170413141642.87B5E401B4727@oldenburg.str.redhat.com> From: Adhemerval Zanella Message-ID: Date: Thu, 13 Apr 2017 17:33:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170413141642.87B5E401B4727@oldenburg.str.redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-04/txt/msg00243.txt.bz2 On 13/04/2017 11:16, Florian Weimer wrote: > 2017-04-13 Florian Weimer > > * csu/check_fds.c (__libc_check_standard_fds): Assume O_NOFOLLOW > is defined. > * elf/rtld.c (process_envvars): Likewise. > * sysdeps/posix/shm_open.c (shm_open): Likewise. > * elf/dl-profile.c (EXTRA_FLAGS): Remove definition. Use > O_NOFOLLOW directly. > * gmon/gmon.c (O_NOFOLLOW): Remove definition. LGTM with some nits. > > diff --git a/csu/check_fds.c b/csu/check_fds.c > index bec2a53..4b4eb81 100644 > --- a/csu/check_fds.c > +++ b/csu/check_fds.c > @@ -87,14 +87,10 @@ check_one_fd (int fd, int mode) > void > __libc_check_standard_fds (void) > { > - /* This is really paranoid but some people actually are. If /dev/null > - should happen to be a symlink to somewhere else and not the device > - commonly known as "/dev/null" we bail out. We can detect this with > - the O_NOFOLLOW flag for open() but only on some system. */ > -#ifndef O_NOFOLLOW > -# define O_NOFOLLOW 0 > -#endif > - /* Check all three standard file descriptors. */ > + /* Check all three standard file descriptors. The O_NOFOLLOW flag > + really paranoid but some people actually are. If /dev/null This sentence sounds strange, shouldn't be 'The O_NOFOLLOW flag *is* really paranoid, but some people actually are.'? > + should happen to be a symlink to somewhere else and not the > + device commonly known as "/dev/null" we bail out. */ > check_one_fd (STDIN_FILENO, O_WRONLY | O_NOFOLLOW); > check_one_fd (STDOUT_FILENO, O_RDONLY | O_NOFOLLOW); > check_one_fd (STDERR_FILENO, O_RDONLY | O_NOFOLLOW); > diff --git a/elf/dl-profile.c b/elf/dl-profile.c > index 01aaf31..a4f1108 100644 > --- a/elf/dl-profile.c > +++ b/elf/dl-profile.c > @@ -325,12 +325,7 @@ _dl_start_profile (void) > *cp++ = '/'; > __stpcpy (__stpcpy (cp, GLRO(dl_profile)), ".profile"); > > -#ifdef O_NOFOLLOW > -# define EXTRA_FLAGS | O_NOFOLLOW > -#else > -# define EXTRA_FLAGS > -#endif > - fd = __open (filename, O_RDWR | O_CREAT EXTRA_FLAGS, DEFFILEMODE); > + fd = __open (filename, O_RDWR | O_CREAT | O_NOFOLLOW, DEFFILEMODE); > if (fd == -1) > { > char buf[400]; > diff --git a/elf/rtld.c b/elf/rtld.c > index 5986eaf..319ef06 100644 > --- a/elf/rtld.c > +++ b/elf/rtld.c > @@ -2525,11 +2525,7 @@ process_envvars (enum mode *modep) > messages to this file. */ > else if (any_debug && debug_output != NULL) > { > -#ifdef O_NOFOLLOW > const int flags = O_WRONLY | O_APPEND | O_CREAT | O_NOFOLLOW; > -#else > - const int flags = O_WRONLY | O_APPEND | O_CREAT; > -#endif > size_t name_len = strlen (debug_output); > char buf[name_len + 12]; > char *startp; > diff --git a/gmon/gmon.c b/gmon/gmon.c > index e9988c0..f394a78 100644 > --- a/gmon/gmon.c > +++ b/gmon/gmon.c > @@ -336,10 +336,6 @@ write_gmon (void) > int fd = -1; > char *env; > > -#ifndef O_NOFOLLOW > -# define O_NOFOLLOW 0 > -#endif > - > env = getenv ("GMON_OUT_PREFIX"); > if (env != NULL && !__libc_enable_secure) > { > diff --git a/sysdeps/posix/shm_open.c b/sysdeps/posix/shm_open.c > index aac0da4..56a9965 100644 > --- a/sysdeps/posix/shm_open.c > +++ b/sysdeps/posix/shm_open.c > @@ -34,9 +34,7 @@ shm_open (const char *name, int oflag, mode_t mode) > { > SHM_GET_NAME (EINVAL, -1, ""); > > -# ifdef O_NOFOLLOW > oflag |= O_NOFOLLOW; > -# endif > # ifdef O_CLOEXEC > oflag |= O_CLOEXEC; > # endif >