glibc/socket
Siddhesh Poyarekar a643f60c53 Make sure that the fortified function conditionals are constant
In _FORTIFY_SOURCE=3, the size expression may be non-constant,
resulting in branches in the inline functions remaining intact and
causing a tiny overhead.  Clang (and in future, gcc) make sure that
the -1 case is always safe, i.e. any comparison of the generated
expression with (size_t)-1 is always false so that bit is taken care
of.  The rest is avoidable since we want the _chk variant whenever we
have a size expression and it's not -1.

Rework the conditionals in a uniform way to clearly indicate two
conditions at compile time:

- Either the size is unknown (-1) or we know at compile time that the
  operation length is less than the object size.  We can call the
  original function in this case.  It could be that either the length,
  object size or both are non-constant, but the compiler, through
  range analysis, is able to fold the *comparison* to a constant.

- The size and length are known and the compiler can see at compile
  time that operation length > object size.  This is valid grounds for
  a warning at compile time, followed by emitting the _chk variant.

For everything else, emit the _chk variant.

This simplifies most of the fortified function implementations and at
the same time, ensures that only one call from _chk or the regular
function is emitted.

Signed-off-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
2021-10-20 18:12:41 +05:30
..
bits Make sure that the fortified function conditionals are constant 2021-10-20 18:12:41 +05:30
sys socket: Add time64 alias for setsockopt 2021-07-22 19:16:26 +02:00
accept4.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
accept.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
bind.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
connect.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
getpeername.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
getsockname.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
getsockopt.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
isfdtype.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
listen.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
Makefile socket: Add time64 alias for getsockopt 2021-07-22 19:16:25 +02:00
opensock.c Linux: Simplify __opensock and fix race condition [BZ #28353] 2021-09-28 18:55:49 +02:00
recv.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
recvfrom.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
recvmmsg.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
recvmsg.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sa_len.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
send.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sendmmsg.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sendmsg.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sendto.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
setsockopt.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
shutdown.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
sockatmark.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
socket.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
socketpair.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-accept4.c Update copyright dates with scripts/update-copyrights 2021-01-02 12:17:34 -08:00
tst-sockopt-time64.c socket: Add time64 alias for getsockopt 2021-07-22 19:16:25 +02:00
tst-sockopt.c socket: Add time64 alias for getsockopt 2021-07-22 19:16:25 +02:00
Versions Fix mq_notify socket, recv namespace (bug 18546). 2015-06-17 20:20:08 +00:00