* bug#30176: readlinkat and _FORTIFY_SOURCE on Cygwin
@ 2018-01-19 20:46 Ken Brown
2018-01-19 23:25 ` Paul Eggert
0 siblings, 1 reply; 3+ messages in thread
From: Ken Brown @ 2018-01-19 20:46 UTC (permalink / raw)
To: 30176; +Cc: Paul Eggert
The next release of Cygwin (2.10.0), expected within the next few weeks,
is going to have a new implementation of _FORTIFY_SOURCE guards for many
functions, including readlinkat. The implementation is based on that of
NetBSD and has the effect of adding code that looks essentially as
follows after preprocessing:
ssize_t
__ssp_real_readlinkat (int __dirfd1, const char *__path,
char *__buf, size_t __len)
__asm__("readlinkat");
extern __inline__ __attribute__((__always_inline__, __gnu_inline__))
ssize_t
readlinkat (int __dirfd1, const char *__path, char *__buf,
size_t __len)
__asm__("__ssp_protected_readlinkat");
extern __inline__ __attribute__((__always_inline__, __gnu_inline__))
ssize_t
readlinkat (int __dirfd1, const char *__path, char *__buf,
size_t __len)
{
if (__builtin_object_size(__buf, 2 > 1) != (size_t)-1
&& __len > __builtin_object_size(__buf, 2 > 1))
__chk_fail();
return __ssp_real_readlinkat (__dirfd1, __path, __buf, __len);
}
The occurrence of this code in fileio.c, combined with the use of a
pointer to readlinkat in the definition of emacs_readlinkat, leads to an
"undefined reference to `__ssp_protected_readlinkat'" linking error.
I'd appreciate some advice on how to fix this. I can think of three
possibilities, but maybe there's something better:
1. Add "#define _FORTIFY_SOURCE 0' at the top of fileio.c (Cygwin only).
2. Pretend like Cygwin doesn't have readlinkat. Then gnulib will create
its own definition, which will be found by the linker in libegnu.a.
3. Ask gnulib to come up with a fix.
Thanks in advance for any advice.
Ken
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#30176: readlinkat and _FORTIFY_SOURCE on Cygwin
2018-01-19 20:46 bug#30176: readlinkat and _FORTIFY_SOURCE on Cygwin Ken Brown
@ 2018-01-19 23:25 ` Paul Eggert
2018-01-20 12:30 ` Ken Brown
0 siblings, 1 reply; 3+ messages in thread
From: Paul Eggert @ 2018-01-19 23:25 UTC (permalink / raw)
To: Ken Brown, 30176
On 01/19/2018 12:46 PM, Ken Brown wrote:
> I can think of three possibilities, but maybe there's something better:
>
> 1. Add "#define _FORTIFY_SOURCE 0' at the top of fileio.c (Cygwin only).
>
> 2. Pretend like Cygwin doesn't have readlinkat. Then gnulib will
> create its own definition, which will be found by the linker in
> libegnu.a.
>
> 3. Ask gnulib to come up with a fix.
(2) is presumably not good, since the substitute readlinkat will have to
execute several system calls and this will be problematic.
(1) should work but kind of misses the point of fortification.
I don't know what would be involved in (3).
How about a better option, like this:
4. Fix Cygwin readlinkat so that it can be used as a function pointer
even when _FORTIFY_SOURCE is used.
Why not do what glibc does with readlinkat? It fortifies readlinkat, and
doesn't run into this problem.
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#30176: readlinkat and _FORTIFY_SOURCE on Cygwin
2018-01-19 23:25 ` Paul Eggert
@ 2018-01-20 12:30 ` Ken Brown
0 siblings, 0 replies; 3+ messages in thread
From: Ken Brown @ 2018-01-20 12:30 UTC (permalink / raw)
To: Paul Eggert, 30176-done
On 1/19/2018 6:25 PM, Paul Eggert wrote:
> 4. Fix Cygwin readlinkat so that it can be used as a function pointer
> even when _FORTIFY_SOURCE is used.
>
> Why not do what glibc does with readlinkat? It fortifies readlinkat, and
> doesn't run into this problem.
Sorry, that was stupid of me. I don't know why I was thinking that this
was an Emacs issue.
Ken
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-20 12:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-19 20:46 bug#30176: readlinkat and _FORTIFY_SOURCE on Cygwin Ken Brown
2018-01-19 23:25 ` Paul Eggert
2018-01-20 12:30 ` Ken Brown
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).