From 7d9acbfa8474d048b6d2c1e7b7f3b0f7b2cfc2bf Mon Sep 17 00:00:00 2001 From: Packit Service Date: Jan 06 2021 22:39:01 +0000 Subject: Apply patch glibc-rh1810142-5.patch patch_name: glibc-rh1810142-5.patch present_in_specfile: true location_in_specfile: 264 --- diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c index e0901a9..a86f476 100644 --- a/resolv/resolv_conf.c +++ b/resolv/resolv_conf.c @@ -136,18 +136,25 @@ __resolv_conf_get_current (void) { /* Parse configuration while holding the lock. This avoids duplicate work. */ - conf = __resolv_conf_load (NULL, NULL); + struct file_change_detection after_load; + conf = __resolv_conf_load (NULL, &after_load); if (conf != NULL) { if (global_copy->conf_current != NULL) conf_decrement (global_copy->conf_current); global_copy->conf_current = conf; /* Takes ownership. */ - /* Update file modification stamps. The configuration we - read could be a newer version of the file, but this does - not matter because this will lead to an extraneous reload - later. */ - global_copy->file_resolve_conf = initial; + /* Update file change detection data, but only if it matches + the initial measurement. This avoids an ABA race in case + /etc/resolv.conf is temporarily replaced while the file + is read (after the initial measurement), and restored to + the initial version later. */ + if (file_is_unchanged (&initial, &after_load)) + global_copy->file_resolve_conf = after_load; + else + /* If there is a discrepancy, trigger a reload during the + next use. */ + global_copy->file_resolve_conf.size = -1; } }