Bug#994102: unistd.h: non-null check not correct for getcwd()

2021-09-12 Thread Aurelien Jarno
On 2021-09-12 12:10, Jan-Benedict Glaw wrote:
> On Sun, 2021-09-12 00:16:01 +0200, Aurelien Jarno  
> wrote:
> > On 2021-09-11 22:06, Jan-Benedict Glaw wrote:
> > > Until glibc's Bugzilla issue is finally resolved
> > > (https://sourceware.org/bugzilla/show_bug.cgi?id=26545), maybe the
> > > Debian package could be changed to drop the access attribute?
> > 
> > No. Once we have patched it, we will have to differ from upstream almost
> > forever, and we want to avoid that. I already have sent a patch [1], I
> > am waiting for feedback.
> 
> Sure, but I hope Debian's libc6-dev won't keep the instrumentation
> enabled even after the patch is accepted upstream to remove it,
> waiting for the next upstream glibc to be pulled for libc6 / libc-dev?

No the point is not to wait for a released version, but to wait for a
decision if this patch is acceptable or if the support for this GNU
extension is simply dropped. In the latter case, the various software
will have to be patched, just like other distributions using glibc >=
2.32 have already done.

Regards,
Aurelien

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net


signature.asc
Description: PGP signature


Bug#994102: unistd.h: non-null check not correct for getcwd()

2021-09-12 Thread Jan-Benedict Glaw
On Sun, 2021-09-12 00:16:01 +0200, Aurelien Jarno  wrote:
> On 2021-09-11 22:06, Jan-Benedict Glaw wrote:
> > Until glibc's Bugzilla issue is finally resolved
> > (https://sourceware.org/bugzilla/show_bug.cgi?id=26545), maybe the
> > Debian package could be changed to drop the access attribute?
> 
> No. Once we have patched it, we will have to differ from upstream almost
> forever, and we want to avoid that. I already have sent a patch [1], I
> am waiting for feedback.

Sure, but I hope Debian's libc6-dev won't keep the instrumentation
enabled even after the patch is accepted upstream to remove it,
waiting for the next upstream glibc to be pulled for libc6 / libc-dev?

In the meantime, I'll probably rebuild the containers to locally patch
it away.

Thanks,
  Jan-Benedict

-- 


signature.asc
Description: PGP signature


Bug#994102: unistd.h: non-null check not correct for getcwd()

2021-09-11 Thread Aurelien Jarno
On 2021-09-11 22:06, Jan-Benedict Glaw wrote:
> Until glibc's Bugzilla issue is finally resolved
> (https://sourceware.org/bugzilla/show_bug.cgi?id=26545), maybe the
> Debian package could be changed to drop the access attribute?

No. Once we have patched it, we will have to differ from upstream almost
forever, and we want to avoid that. I already have sent a patch [1], I
am waiting for feedback.

Regards,
Aurelien

[1] https://sourceware.org/pipermail/libc-alpha/2021-September/130886.html

-- 
Aurelien Jarno  GPG: 4096R/1DDD8C9B
aurel...@aurel32.net http://www.aurel32.net


signature.asc
Description: PGP signature


Bug#994102: unistd.h: non-null check not correct for getcwd()

2021-09-11 Thread Jan-Benedict Glaw
Package: libc6-dev
Version: 2.32-2

Current getcwd() is declared as:

/usr/include/unistd.h:

513:/* Get the pathname of the current working directory,
514:   and put it in SIZE bytes of BUF.  Returns NULL if the
515:   directory couldn't be determined or SIZE was too small.
516:   If successful, returns BUF.  In GNU, if BUF is NULL,
517:   an array is allocated with `malloc'; the array is SIZE
518:   bytes long, unless SIZE == 0, in which case it is as
519:   big as necessary.  */
520:extern char *getcwd (char *__buf, size_t __size) __THROW __wur
521:__attr_access ((__write_only__, 1, 2));


Documentation (man page) states:

   As an extension to the POSIX.1-2001 standard,  glibc's  getcwd()  allo-
   cates  the  buffer dynamically using malloc(3) if buf is NULL.  In this
   case, the allocated buffer has the length size  unless  size  is  zero,
   when  buf  is allocated as big as necessary.  The caller should free(3)
   the returned buffer.


The current check doesn't accept the NULL pointer with recent GCC
versions and breaks, for example, building GCC from sources due to
fixincl.c using NULL as the buffer argument so it doesn't need to
allocate on its own:

[all 2021-09-11 18:34:38] make[1]: Entering directory 
'/var/lib/laminar/run/gcc-bfin-elf/6/toolchain-build/build-x86_64-pc-linux-gnu/fixincludes'
[all 2021-09-11 18:34:38] /usr/lib/gcc-snapshot/bin/gcc -c -g -O2 -W -Wall 
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition 
-Wmissing-format-attribute -Wno-overlength-strings -pedantic -Wno-long-long 
-Werror  -DHAVE_CONFIG_H -I. -I../../../gcc/fixincludes -I../include 
-I../../../gcc/fixincludes/../include ../../../gcc/fixincludes/fixincl.c
[all 2021-09-11 18:34:39] ../../../gcc/fixincludes/fixincl.c: In function 
'process':
[all 2021-09-11 18:34:39] ../../../gcc/fixincludes/fixincl.c:1356:7: error: 
argument 1 is null but the corresponding size argument 2 value is 4096 
[-Werror=nonnull]
[all 2021-09-11 18:34:39]  1356 |   fprintf (stderr, "Cannot access %s from 
%s\n\terror %d (%s)\n",
[all 2021-09-11 18:34:39]   |   
^~~
[all 2021-09-11 18:34:39]  1357 |pz_curr_file, getcwd ((char *) 
NULL, MAXPATHLEN),
[all 2021-09-11 18:34:39]   |
~
[all 2021-09-11 18:34:39]  1358 |erno, xstrerror (erno));
[all 2021-09-11 18:34:39]   |~~~
[all 2021-09-11 18:34:39] In file included from 
../../../gcc/fixincludes/system.h:192,
[all 2021-09-11 18:34:39]  from 
../../../gcc/fixincludes/fixlib.h:29,
[all 2021-09-11 18:34:39]  from 
../../../gcc/fixincludes/fixincl.c:24:
[all 2021-09-11 18:34:39] /usr/include/unistd.h:520:14: note: in a call to 
function 'getcwd' declared with attribute 'access (write_only, 1, 2)'
[all 2021-09-11 18:34:39]   520 | extern char *getcwd (char *__buf, size_t 
__size) __THROW __wur
[all 2021-09-11 18:34:39]   |  ^~
[all 2021-09-11 18:34:39] cc1: all warnings being treated as errors
[all 2021-09-11 18:34:39] make[1]: *** [Makefile:76: fixincl.o] Error 1
[all 2021-09-11 18:34:39] make[1]: Leaving directory 
'/var/lib/laminar/run/gcc-bfin-elf/6/toolchain-build/build-x86_64-pc-linux-gnu/fixincludes'
[all 2021-09-11 18:34:39] make: *** [Makefile:2854: all-build-fixincludes] 
Error 2

(That's from a not-yet publically announced auto-builder that does
build GCC/Binutils, Linux Kernel, NetBSD and SIMH to check for them
being buildable for a good number of configurations.)

  For comparison, with libc6-dev at 2.31-16, declaration was like this:

504:/* Get the pathname of the current working directory,
505:   and put it in SIZE bytes of BUF.  Returns NULL if the
506:   directory couldn't be determined or SIZE was too small.
507:   If successful, returns BUF.  In GNU, if BUF is NULL,
508:   an array is allocated with `malloc'; the array is SIZE
509:   bytes long, unless SIZE == 0, in which case it is as
510:   big as necessary.  */
511:extern char *getcwd (char *__buf, size_t __size) __THROW __wur;


Until glibc's Bugzilla issue is finally resolved
(https://sourceware.org/bugzilla/show_bug.cgi?id=26545), maybe the
Debian package could be changed to drop the access attribute?

Thanks,
  Jan-Benedict

-- 


signature.asc
Description: PGP signature