* [PATCH v3 1/2] nss: add assert to DB_LOOKUP_FCT (BZ #28752)
@ 2022-06-04 4:30 Sam James
2022-06-04 4:30 ` [PATCH v3 2/2] nss: handle stat failure in check_reload_and_get " Sam James
0 siblings, 1 reply; 2+ messages in thread
From: Sam James @ 2022-06-04 4:30 UTC (permalink / raw)
To: libc-alpha
It's interesting if we have a null action list,
so an assert is worthwhile.
Suggested-by: DJ Delorie <dj@redhat.com>
Signed-off-by: Sam James <sam@gentoo.org>
---
nss/XXX-lookup.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c
index db95937674..bfc57b8e64 100644
--- a/nss/XXX-lookup.c
+++ b/nss/XXX-lookup.c
@@ -15,6 +15,7 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
+#include <assert.h>
#include "nsswitch.h"
/*******************************************************************\
@@ -54,6 +55,10 @@ DB_LOOKUP_FCT (nss_action_list *ni, const char *fct_name, const char *fct2_name,
*ni = DATABASE_NAME_SYMBOL;
+ /* We want to know about it if we've somehow got a NULL action list;
+ in the past, we had bad state if seccomp interfered with setup. */
+ assert(*ni != NULL);
+
return __nss_lookup (ni, fct_name, fct2_name, fctp);
}
libc_hidden_def (DB_LOOKUP_FCT)
--
2.35.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH v3 2/2] nss: handle stat failure in check_reload_and_get (BZ #28752)
2022-06-04 4:30 [PATCH v3 1/2] nss: add assert to DB_LOOKUP_FCT (BZ #28752) Sam James
@ 2022-06-04 4:30 ` Sam James
0 siblings, 0 replies; 2+ messages in thread
From: Sam James @ 2022-06-04 4:30 UTC (permalink / raw)
To: libc-alpha
Skip the chroot test if the database isn't loaded
correctly (because the chroot test uses some
existing DB state).
The __stat64_time64 -> fstatat call can fail if
running under an (aggressive) seccomp filter,
like Firefox seems to use.
This manifested in a crash when using glib built
with FAM support with such a Firefox build.
Suggested-by: DJ Delorie <dj@redhat.com>
Signed-off-by: Sam James <sam@gentoo.org>
---
nss/nss_database.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/nss/nss_database.c b/nss/nss_database.c
index d56c5b798d..4ff9bf5696 100644
--- a/nss/nss_database.c
+++ b/nss/nss_database.c
@@ -420,23 +420,27 @@ nss_database_check_reload_and_get (struct nss_database_state *local,
return true;
}
- /* Before we reload, verify that "/" hasn't changed. We assume that
- errors here are very unlikely, but the chance that we're entering
- a container is also very unlikely, so we err on the side of both
- very unlikely things not happening at the same time. */
- if (__stat64_time64 ("/", &str) != 0
- || (local->root_ino != 0
- && (str.st_ino != local->root_ino
- || str.st_dev != local->root_dev)))
- {
- /* Change detected; disable reloading and return current state. */
- atomic_store_release (&local->data.reload_disabled, 1);
- *result = local->data.services[database_index];
- __libc_lock_unlock (local->lock);
- return true;
- }
- local->root_ino = str.st_ino;
- local->root_dev = str.st_dev;
+ if (local->data.services[database_index] != NULL) {
+ /* Before we reload, verify that "/" hasn't changed. We assume that
+ errors here are very unlikely, but the chance that we're entering
+ a container is also very unlikely, so we err on the side of both
+ very unlikely things not happening at the same time. */
+ if (__stat64_time64 ("/", &str) != 0
+ || (local->root_ino != 0
+ && (str.st_ino != local->root_ino
+ || str.st_dev != local->root_dev)))
+ {
+ /* Change detected; disable reloading and return current state. */
+ atomic_store_release (&local->data.reload_disabled, 1);
+ *result = local->data.services[database_index];
+ __libc_lock_unlock (local->lock);
+ return true;
+ }
+
+ local->root_ino = str.st_ino;
+ local->root_dev = str.st_dev;
+ }
+
__libc_lock_unlock (local->lock);
/* Avoid overwriting the global configuration until we have loaded
--
2.35.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-06-04 4:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-04 4:30 [PATCH v3 1/2] nss: add assert to DB_LOOKUP_FCT (BZ #28752) Sam James
2022-06-04 4:30 ` [PATCH v3 2/2] nss: handle stat failure in check_reload_and_get " Sam James
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).