[PATCH xserver] os: Fix iteration over busfaults

Peter Hutterer peter.hutterer at who-t.net
Wed Feb 22 23:21:37 UTC 2017


On Fri, Feb 17, 2017 at 08:18:52AM +0000, Chris Wilson wrote:
> Fixes a regression from
> 
> commit 41da295eb50fa08eaacd0ecde99f43a716fcb41a
> Author: Keith Packard <keithp at 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 at chris-wilson.co.uk>
> ---
>  os/busfault.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/os/busfault.c b/os/busfault.c
> index d4afa6df3..a2d433a2e 100644
> --- a/os/busfault.c
> +++ b/os/busfault.c
> @@ -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
> -- 
> 2.11.0

remote: Updating patchwork state for https://patchwork.freedesktop.org/project/Xorg/list/
remote: I: patch #61165 updated using rev acdb5bf2de57c0080d2a6e730c788a0a428e13dc.
remote: I: 1 patch(es) updated to state Accepted.
To git+ssh://git.freedesktop.org/git/xorg/xserver
   dcb63de..acdb5bf  master -> master

thanks

Cheers,
   Peter


More information about the xorg-devel mailing list