os: Fix iteration over busfaults
Fixes a regression from
commit 41da295eb5
Author: Keith Packard <keithp@keithp.com>
Date:   Sun Nov 3 13:12:40 2013 -0800
    Trap SIGBUS to handle truncated shared memory segments
that causes the SIGBUS handler to fail to chain up correctly and
corrupts nearby memory instead.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
			
			
This commit is contained in:
		
							parent
							
								
									dcb63deb1b
								
							
						
					
					
						commit
						acdb5bf2de
					
				| 
						 | 
				
			
			@ -98,15 +98,16 @@ static void
 | 
			
		|||
busfault_sigaction(int sig, siginfo_t *info, void *param)
 | 
			
		||||
{
 | 
			
		||||
    void                *fault = info->si_addr;
 | 
			
		||||
    struct busfault     *busfault = NULL;
 | 
			
		||||
    struct busfault     *iter, *busfault = NULL;
 | 
			
		||||
    void                *new_addr;
 | 
			
		||||
 | 
			
		||||
    /* Locate the faulting address in our list of shared segments
 | 
			
		||||
     */
 | 
			
		||||
    xorg_list_for_each_entry(busfault, &busfaults, list) {
 | 
			
		||||
        if ((char *) busfault->addr <= (char *) fault && (char *) fault < (char *) busfault->addr + busfault->size) {
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
    xorg_list_for_each_entry(iter, &busfaults, list) {
 | 
			
		||||
	if ((char *) iter->addr <= (char *) fault && (char *) fault < (char *) iter->addr + iter->size) {
 | 
			
		||||
	    busfault = iter;
 | 
			
		||||
	    break;
 | 
			
		||||
	}
 | 
			
		||||
    }
 | 
			
		||||
    if (!busfault)
 | 
			
		||||
        goto panic;
 | 
			
		||||
| 
						 | 
				
			
			@ -132,7 +133,7 @@ panic:
 | 
			
		|||
    if (previous_busfault_sigaction)
 | 
			
		||||
        (*previous_busfault_sigaction)(sig, info, param);
 | 
			
		||||
    else
 | 
			
		||||
        FatalError("bus error");
 | 
			
		||||
        FatalError("bus error\n");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
Bool
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue