public inbox for libc-help@sourceware.org
 help / color / mirror / Atom feed
* Usage of C11 Annex K Bounds-checking interfaces on Glibc
@ 2019-12-10  7:41 li zi
  2019-12-10  9:53 ` Yann Droneaud
  0 siblings, 1 reply; 3+ messages in thread
From: li zi @ 2019-12-10  7:41 UTC (permalink / raw)
  To: libc-help

Hi All, 

We are using glibc in our projects and we found some of the C standard functions (like memcpy, strcpy) used in glibc may induce security vulnerablities like buffer overflow. Currently we have not found any instances which causes such issues. 
But we feel better to change these calls to C11 Annex K Bounds-checking interfaces like memcpy_s, strcpy_s etc. By defining a secure calls method (list of func pointers) and allowing application to register the method. I understand that this affects performance because of return value check added for xxxx_s calls, but this will relieve overflow kind of issues from code. And also currently using bounds-checking interfaces is a general industry practice. 
Please share your opinion on it, and if any discussion happened in community to do some changes in future.

Thanks. 
li


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Usage of C11 Annex K Bounds-checking interfaces on Glibc
  2019-12-10  7:41 Usage of C11 Annex K Bounds-checking interfaces on Glibc li zi
@ 2019-12-10  9:53 ` Yann Droneaud
  2019-12-11 21:52   ` <Alexander G. Riccio>
  0 siblings, 1 reply; 3+ messages in thread
From: Yann Droneaud @ 2019-12-10  9:53 UTC (permalink / raw)
  To: li zi, libc-help

Hi,

Le mardi 10 décembre 2019 à 07:41 +0000, li zi a écrit :
> 
> We are using glibc in our projects and we found some of the C
> standard functions (like memcpy, strcpy) used in glibc may induce
> security vulnerablities like buffer overflow. Currently we have not
> found any instances which causes such issues. 
> But we feel better to change these calls to C11 Annex K Bounds-
> checking interfaces like memcpy_s, strcpy_s etc. By defining a secure
> calls method (list of func pointers) and allowing application to
> register the method. I understand that this affects performance
> because of return value check added for xxxx_s calls, but this will
> relieve overflow kind of issues from code. And also currently using
> bounds-checking interfaces is a general industry practice. 
> Please share your opinion on it, and if any discussion happened in
> community to do some changes in future.

You might want to compile with -D_FORTIFY_SOURCE=2 to enable best
effort bound checking on the standard functions at compile and run
time.

You might want to compile with -fstack-protector-strong to enable stack
overflow checking on runtime.

One of GLIBC maintainer made a nice blog post about those and more
https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/

Then this is ASan, address sanitizer (and other sanitizers), see 
https://developers.redhat.com/blog/2014/12/02/address-and-thread-sanitizers-gcc/

So GNU has the tool to develop hardened programs.

C11 Annex K is optional, and seen by some people as a Microsoft Windows
only feature.

Anyway, have a look to the archives:

https://sourceware.org/ml/libc-alpha/2007-05/msg00027.html
https://sourceware.org/ml/libc-alpha/2012-10/msg00915.html
https://sourceware.org/ml/libc-alpha/2014-08/msg00133.html
https://sourceware.org/ml/libc-help/2019-01/msg00035.html

Regards.

-- 
Yann Droneaud
OPTEYA


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Usage of C11 Annex K Bounds-checking interfaces on Glibc
  2019-12-10  9:53 ` Yann Droneaud
@ 2019-12-11 21:52   ` <Alexander G. Riccio>
  0 siblings, 0 replies; 3+ messages in thread
From: <Alexander G. Riccio> @ 2019-12-11 21:52 UTC (permalink / raw)
  To: Yann Droneaud; +Cc: li zi, libc-help

Hey, I mentioned it on libc-help once too:

https://sourceware.org/ml/libc-help/2018-01/msg00005.html

On Tue, Dec 10, 2019, 4:53 AM Yann Droneaud <ydroneaud@opteya.com> wrote:

> Hi,
>
> Le mardi 10 décembre 2019 à 07:41 +0000, li zi a écrit :
> >
> > We are using glibc in our projects and we found some of the C
> > standard functions (like memcpy, strcpy) used in glibc may induce
> > security vulnerablities like buffer overflow. Currently we have not
> > found any instances which causes such issues.
> > But we feel better to change these calls to C11 Annex K Bounds-
> > checking interfaces like memcpy_s, strcpy_s etc. By defining a secure
> > calls method (list of func pointers) and allowing application to
> > register the method. I understand that this affects performance
> > because of return value check added for xxxx_s calls, but this will
> > relieve overflow kind of issues from code. And also currently using
> > bounds-checking interfaces is a general industry practice.
> > Please share your opinion on it, and if any discussion happened in
> > community to do some changes in future.
>
> You might want to compile with -D_FORTIFY_SOURCE=2 to enable best
> effort bound checking on the standard functions at compile and run
> time.
>
> You might want to compile with -fstack-protector-strong to enable stack
> overflow checking on runtime.
>
> One of GLIBC maintainer made a nice blog post about those and more
>
> https://developers.redhat.com/blog/2018/03/21/compiler-and-linker-flags-gcc/
>
> Then this is ASan, address sanitizer (and other sanitizers), see
>
> https://developers.redhat.com/blog/2014/12/02/address-and-thread-sanitizers-gcc/
>
> So GNU has the tool to develop hardened programs.
>
> C11 Annex K is optional, and seen by some people as a Microsoft Windows
> only feature.
>
> Anyway, have a look to the archives:
>
> https://sourceware.org/ml/libc-alpha/2007-05/msg00027.html
> https://sourceware.org/ml/libc-alpha/2012-10/msg00915.html
> https://sourceware.org/ml/libc-alpha/2014-08/msg00133.html
> https://sourceware.org/ml/libc-help/2019-01/msg00035.html
>
> Regards.
>
> --
> Yann Droneaud
> OPTEYA
>
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-12-11 21:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-10  7:41 Usage of C11 Annex K Bounds-checking interfaces on Glibc li zi
2019-12-10  9:53 ` Yann Droneaud
2019-12-11 21:52   ` <Alexander G. Riccio>

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).