Bug#967938: libc6: systemd-sysusers SEGV due to glibc bug in fgetgsent

2022-01-04 Thread Jinpu Wang
Dear maintainers,

We are still seeing the same SEGV with Bullseye, I did a forward
porting of the minimum bugfix.

Is it possible to get it upstream.

The patch is against glibc 2.31-13+deb11u2.

Thanks! Regards

Jinpu Wang

Sr. Linux Kernel Storage Programmer
Compute Platform Development Cloud

IONOS SE | Revaler Str. 30 | 10245 Berlin | Deutschland
Phone:
E-Mail: jinpu.w...@ionos.com | Web: www.ionos.de

Hauptsitz Montabaur, Amtsgericht Montabaur, HRB 24498

Vorstand: Hüseyin Dogan, Dr. Martin Endreß, Claudia Frese, Henning
Kettler, Arthur Mai, Britta Schmidt, Achim Weiß
Aufsichtsratsvorsitzender: Markus Kadelke


Member of United Internet

Diese E-Mail kann vertrauliche und/oder gesetzlich geschützte
Informationen enthalten. Wenn Sie nicht der bestimmungsgemäße Adressat
sind oder diese E-Mail irrtümlich erhalten haben, unterrichten Sie
bitte den Absender und vernichten Sie diese E-Mail. Anderen als dem
bestimmungsgemäßen Adressaten ist untersagt, diese E-Mail zu
speichern, weiterzuleiten oder ihren Inhalt auf welche Weise auch
immer zu verwenden.

This e-mail may contain confidential and/or privileged information. If
you are not the intended recipient of this e-mail, you are hereby
notified that saving, distribution or use of the content of this
e-mail in any way is prohibited. If you have received this e-mail in
error, please notify the sender and delete the e-mail.
From 2e7c36a5319198cfc28546a3d452f2246f050698 Mon Sep 17 00:00:00 2001
From: Jack Wang 
Date: Tue, 4 Aug 2020 15:05:27 +0200
Subject: [PATCH 1/3] gshadow: Handle the parser's full buffer error code

The fgetgsent function isn't handling errors from parse_line.  That
means it can run out of buffer space when adding pointers to group
members and exit early without setting all members of the static result
struct.  The static result's members will remain pointing at buffer
locations from the previous line, which have been overwritten with
incompatible data, causing segfaults after it is returned normally.

https://sourceware.org/legacy-ml/libc-alpha/2016-06/msg01015.html
https://sourceware.org/bugzilla/show_bug.cgi?id=20338
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=967938

add local copies of the new functions, so that the
GLIBC_PRIVATE ABI remains unchanged, as suggested by
Florian Weimer 

Signed-off-by: Jack Wang 
Signed-off-by: Benjamin Drung 
---
 gshadow/fgetsgent_r.c | 183 ++
 1 file changed, 149 insertions(+), 34 deletions(-)

diff --git a/gshadow/fgetsgent_r.c b/gshadow/fgetsgent_r.c
index a7a1860c76d3..0b15cd59733b 100644
--- a/gshadow/fgetsgent_r.c
+++ b/gshadow/fgetsgent_r.c
@@ -19,6 +19,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 /* Define a line parsing function using the common code
used in the nss_files module.  */
@@ -30,46 +32,159 @@ struct sgent_data {};
 
 #include 
 
+/* Set the error indicator on FP.  */
+static inline void
+fseterr_unlocked (FILE *fp)
+{
+  fp->_flags |= _IO_ERR_SEEN;
+}
 
-/* Read one shadow entry from the given stream.  */
-int
-__fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
-	   struct sgrp **result)
+static int
+__nss_readline_seek (FILE *fp, off64_t offset)
 {
-  char *p;
+  if (offset < 0 /* __ftello64 failed.  */
+  || __fseeko64 (fp, offset, SEEK_SET) < 0)
+{
+  /* Without seeking support, it is not possible to
+ re-read the same line, so this is a hard failure.  */
+  fseterr_unlocked (fp);
+  __set_errno (ESPIPE);
+  return ESPIPE;
+}
+  else
+{
+  __set_errno (ERANGE);
+  return ERANGE;
+}
+}
 
-  _IO_flockfile (stream);
-  do
+static int
+__nss_readline (FILE *fp, char *buf, size_t len, off64_t *poffset)
+{
+  /* We need space for at least one character, the line terminator,
+ and the NUL byte.  */
+  if (len < 3)
 {
-  buffer[buflen - 1] = '\xff';
-  p = fgets_unlocked (buffer, buflen, stream);
-  if (p == NULL && feof_unlocked (stream))
-	{
-	  _IO_funlockfile (stream);
-	  *result = NULL;
-	  __set_errno (ENOENT);
-	  return errno;
-	}
-  if (p == NULL || buffer[buflen - 1] != '\xff')
-	{
-	  _IO_funlockfile (stream);
-	  *result = NULL;
-	  __set_errno (ERANGE);
-	  return errno;
-	}
-
-  /* Skip leading blanks.  */
+  *poffset = -1;
+  __set_errno (ERANGE);
+  return ERANGE;
+}
+
+  while (true)
+{
+  /* Keep original offset for retries.  */
+  *poffset = __ftello64 (fp);
+
+  buf[len - 1] = '\xff';/* Marker to recognize truncation.  */
+  if (fgets_unlocked (buf, len, fp) == NULL)
+{
+  if (feof_unlocked (fp))
+{
+  __set_errno (ENOENT);
+  return ENOENT;
+}
+  else
+{
+  /* Any other error.  Do not return ERANGE in this case
+ because the caller would retry.  */
+  if (errno == ERANGE)
+__set_errno (EINVAL);
+

[Git][glibc-team/glibc][glibc-2.34] 11 commits: hurd-i386/unsubmitted-getaux_at_secure.diff: Fix according to new __getauxval2 function

2022-01-04 Thread Samuel Thibault (@sthibault)


Samuel Thibault pushed to branch glibc-2.34 at GNU Libc Maintainers / glibc


Commits:
96d7afb5 by Samuel Thibault at 2021-12-13T20:30:26+00:00
hurd-i386/unsubmitted-getaux_at_secure.diff: Fix according to new __getauxval2 
function

- - - - -
49bca983 by Samuel Thibault at 2021-12-30T20:10:01+01:00
debian/libc0.3.symbols.hurd-i386: Add vm_region_create_proxy

- - - - -
8c1bf054 by Samuel Thibault at 2021-12-31T17:27:17+00:00
debian/patches/hurd-i386/git-large-text.diff: Fix clang startup

- - - - -
4e300122 by Samuel Thibault at 2021-12-31T17:28:20+00:00
debian/patches/hurd-i386/git-lib-map.diff: Unlock libraries load addresses

- - - - -
16ad3a28 by Samuel Thibault at 2022-01-01T10:02:09+01:00
Restore UNRELEASED state

- - - - -
f38f08f5 by Samuel Thibault at 2022-01-02T01:56:22+00:00
debian/patches/hurd-i386/git-get_dtable.diff: Implement msg_get_dtable.

This will be useful for implementing lsof

- - - - -
b714230a by Samuel Thibault at 2022-01-02T01:57:00+00:00
debian/patches/hurd-i386/git-auth-leak.diff: Fix auth port leaks

- - - - -
fca79289 by Samuel Thibault at 2022-01-02T03:11:58+00:00
debian/patches/hurd-i386/git-nuke_ports_on_exec.diff: Fix ports leaks

- - - - -
85b974bd by Samuel Thibault at 2022-01-04T14:39:16+01:00
debian/testsuite-xfail-debian.mk: Update hurd tests

(cherry picked from commit b9d04c9bf93df43ba4ceb49a139a6483ea1550a9)

- - - - -
38fbb03f by Samuel Thibault at 2022-01-04T15:31:12+00:00
Merge branch sid of salsa.debian.org:glibc-team/glibc into sid

- - - - -
c438452e by Samuel Thibault at 2022-01-04T15:56:43+00:00
Merge branch sid of salsa.debian.org:glibc-team/glibc into glibc-2.34

- - - - -


11 changed files:

- debian/changelog
- debian/libc0.3.symbols.hurd-i386
- + debian/patches/hurd-i386/git-auth-leak.diff
- + debian/patches/hurd-i386/git-get_dtable.diff
- + debian/patches/hurd-i386/git-large-text.diff
- + debian/patches/hurd-i386/git-lib-map.diff
- + debian/patches/hurd-i386/git-nuke_ports_on_exec.diff
- debian/patches/hurd-i386/local-exec_filename.diff
- debian/patches/hurd-i386/unsubmitted-getaux_at_secure.diff
- debian/patches/series
- debian/testsuite-xfail-debian.mk


View it on GitLab: 
https://salsa.debian.org/glibc-team/glibc/-/compare/92a7f354fd02cbcd3363d8de0451e8a21159fa3c...c438452ee192f6dc61b3addcae6c80c3055ab2b7

-- 
View it on GitLab: 
https://salsa.debian.org/glibc-team/glibc/-/compare/92a7f354fd02cbcd3363d8de0451e8a21159fa3c...c438452ee192f6dc61b3addcae6c80c3055ab2b7
You're receiving this email because of your account on salsa.debian.org.




[Git][glibc-team/glibc][sid] debian/testsuite-xfail-debian.mk: Update hurd tests

2022-01-04 Thread Samuel Thibault (@sthibault)


Samuel Thibault pushed to branch sid at GNU Libc Maintainers / glibc


Commits:
85b974bd by Samuel Thibault at 2022-01-04T14:39:16+01:00
debian/testsuite-xfail-debian.mk: Update hurd tests

(cherry picked from commit b9d04c9bf93df43ba4ceb49a139a6483ea1550a9)

- - - - -


2 changed files:

- debian/changelog
- debian/testsuite-xfail-debian.mk


View it on GitLab: 
https://salsa.debian.org/glibc-team/glibc/-/commit/85b974bd97082545df634bcddf15b7719b7248af

-- 
View it on GitLab: 
https://salsa.debian.org/glibc-team/glibc/-/commit/85b974bd97082545df634bcddf15b7719b7248af
You're receiving this email because of your account on salsa.debian.org.




[Git][glibc-team/glibc][glibc-2.34] debian/testsuite-xfail-debian.mk: Update hurd tests.

2022-01-04 Thread Samuel Thibault (@sthibault)


Samuel Thibault pushed to branch glibc-2.34 at GNU Libc Maintainers / glibc


Commits:
92a7f354 by Samuel Thibault at 2022-01-04T12:49:53+01:00
debian/testsuite-xfail-debian.mk: Update hurd tests.

- - - - -


1 changed file:

- debian/testsuite-xfail-debian.mk


View it on GitLab: 
https://salsa.debian.org/glibc-team/glibc/-/commit/92a7f354fd02cbcd3363d8de0451e8a21159fa3c

-- 
View it on GitLab: 
https://salsa.debian.org/glibc-team/glibc/-/commit/92a7f354fd02cbcd3363d8de0451e8a21159fa3c
You're receiving this email because of your account on salsa.debian.org.