summaryrefslogtreecommitdiff
path: root/src/lib/eina/eina_file.c
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-08-30 12:03:41 +0900
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2017-08-30 12:03:41 +0900
commita5c8e883d8f9b3389e9a6233ba79c47df3bdc420 (patch)
tree670b9ce1adc8d8f2a3b6735873edcd1bf46545b2 /src/lib/eina/eina_file.c
parent15cdd9b71b6d5abef5adc563410b4aa9a3443800 (diff)
eina mmap safety - only map zeropages if it's an eina file that sigbuses
restrict mapping /dev/zero to only eina files having a sigbus reported. the mmap was before all our file access used eina_file i think thus the raw mmap of it. now walk all eina files and find the candidate and only then if it exists flag is as having a faulty i/o backing and map the zerto pages then return, otherwise call abort. more restricted mapping and perhaps a fix for not trapping non-efl issues. @fix
Diffstat (limited to 'src/lib/eina/eina_file.c')
-rw-r--r--src/lib/eina/eina_file.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/lib/eina/eina_file.c b/src/lib/eina/eina_file.c
index 7e154db..c2c7f8f 100644
--- a/src/lib/eina/eina_file.c
+++ b/src/lib/eina/eina_file.c
@@ -418,30 +418,28 @@ _eina_file_mmap_faulty_one(void *addr, long page_size,
418 return EINA_FALSE; 418 return EINA_FALSE;
419} 419}
420 420
421void 421Eina_Bool
422eina_file_mmap_faulty(void *addr, long page_size) 422eina_file_mmap_faulty(void *addr, long page_size)
423{ 423{
424 Eina_File_Map *m; 424 Eina_File_Map *m;
425 Eina_File *f; 425 Eina_File *f;
426 Eina_Iterator *itf; 426 Eina_Iterator *itf;
427 Eina_Iterator *itm; 427 Eina_Iterator *itm;
428 Eina_Bool faulty = EINA_FALSE;
428 429
429 /* NOTE: I actually don't know if other thread are running, I will try to take the lock.
430 It may be possible that if other thread are not running and they were in the middle of
431 accessing an Eina_File this lock are still taken and we will result as a deadlock. */
432 eina_lock_take(&_eina_file_lock_cache); 430 eina_lock_take(&_eina_file_lock_cache);
433 431
434 itf = eina_hash_iterator_data_new(_eina_file_cache); 432 itf = eina_hash_iterator_data_new(_eina_file_cache);
435 EINA_ITERATOR_FOREACH(itf, f) 433 EINA_ITERATOR_FOREACH(itf, f)
436 { 434 {
437 Eina_Bool faulty = EINA_FALSE;
438
439 eina_lock_take(&f->lock); 435 eina_lock_take(&f->lock);
440 436
441 if (f->global_map != MAP_FAILED) 437 if (f->global_map != MAP_FAILED)
442 { 438 {
443 if ((unsigned char *) addr < (((unsigned char *)f->global_map) + f->length) && 439 if ((unsigned char *)addr <
444 (((unsigned char *) addr) + page_size) >= (unsigned char *) f->global_map) 440 (((unsigned char *)f->global_map) + f->length) &&
441 (((unsigned char *)addr) + page_size) >=
442 (unsigned char *)f->global_map)
445 { 443 {
446 f->global_faulty = EINA_TRUE; 444 f->global_faulty = EINA_TRUE;
447 faulty = EINA_TRUE; 445 faulty = EINA_TRUE;
@@ -477,6 +475,7 @@ eina_file_mmap_faulty(void *addr, long page_size)
477 eina_iterator_free(itf); 475 eina_iterator_free(itf);
478 476
479 eina_lock_release(&_eina_file_lock_cache); 477 eina_lock_release(&_eina_file_lock_cache);
478 return faulty;
480} 479}
481 480
482/* ================================================================ * 481/* ================================================================ *