diff options
author | avg <avg@FreeBSD.org> | 2011-03-25 18:23:10 +0000 |
---|---|---|
committer | avg <avg@FreeBSD.org> | 2011-03-25 18:23:10 +0000 |
commit | 15ff949f29fb67c87a63a332b0078a87a5bf9027 (patch) | |
tree | a640364299759a0dc9bf862c1792bf7be232043a /libexec | |
parent | eeb1ebf124d9c1b108ce628aa98d1af7875d3334 (diff) | |
download | FreeBSD-src-15ff949f29fb67c87a63a332b0078a87a5bf9027.zip FreeBSD-src-15ff949f29fb67c87a63a332b0078a87a5bf9027.tar.gz |
rtld: eliminate double call to close(2) that may occur in load_object
The second close(2) call resulted in heisenbugs in some multi-threaded
applications where e.g. dlopen(3) call in one thread could close a file
descriptor for a file having been opened in other thread concurrently.
My litmus test for this issue was an openoffice.org build.
Reviewed by: jhb
MFC after: 2 weeks
Diffstat (limited to 'libexec')
-rw-r--r-- | libexec/rtld-elf/rtld.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/libexec/rtld-elf/rtld.c b/libexec/rtld-elf/rtld.c index 948cf49..5c2db0a 100644 --- a/libexec/rtld-elf/rtld.c +++ b/libexec/rtld-elf/rtld.c @@ -1633,12 +1633,9 @@ load_object(const char *name, const Obj_Entry *refobj, int flags) free(path); return NULL; } - for (obj = obj_list->next; obj != NULL; obj = obj->next) { - if (obj->ino == sb.st_ino && obj->dev == sb.st_dev) { - close(fd); + for (obj = obj_list->next; obj != NULL; obj = obj->next) + if (obj->ino == sb.st_ino && obj->dev == sb.st_dev) break; - } - } if (obj != NULL) { object_add_name(obj, name); free(path); |