[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v2 01/20] livepatch: Bubble up sanity checks on Elf relocs



On Thu, Aug 25, 2016 at 09:37:16AM -0400, Konrad Rzeszutek Wilk wrote:
> The checks for SHT_REL[,A] ELF sanity checks does not need to
> be in the platform specific file and can be bubbled up
> in the platform agnostic file.
> 
> This makes the ARM 32/64 implementation easier as the
> duplicate checks don't have to be in the platform specific files.
> 
> Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> 
> ---
> Cc: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
> Cc: Ross Lagerwall <ross.lagerwall@xxxxxxxxxx>

Ross, could you review the patch please?


> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
> 
> v1: First submission
> v2: Mirror checks for SHT_REL case.
> ---
>  xen/arch/x86/livepatch.c   | 12 ------------
>  xen/common/livepatch_elf.c | 17 +++++++++++++++++
>  2 files changed, 17 insertions(+), 12 deletions(-)
> 
> diff --git a/xen/arch/x86/livepatch.c b/xen/arch/x86/livepatch.c
> index 952e897..5b0c863 100644
> --- a/xen/arch/x86/livepatch.c
> +++ b/xen/arch/x86/livepatch.c
> @@ -146,18 +146,6 @@ int arch_livepatch_perform_rela(struct livepatch_elf 
> *elf,
>      uint64_t val;
>      uint8_t *dest;
>  
> -    /* Nothing to do. */
> -    if ( !rela->sec->sh_size )
> -        return 0;
> -
> -    if ( rela->sec->sh_entsize < sizeof(Elf_RelA) ||
> -         rela->sec->sh_size % rela->sec->sh_entsize )
> -    {
> -        dprintk(XENLOG_ERR, LIVEPATCH "%s: Section relative header is 
> corrupted!\n",
> -                elf->name);
> -        return -EINVAL;
> -    }
> -
>      for ( i = 0; i < (rela->sec->sh_size / rela->sec->sh_entsize); i++ )
>      {
>          r = rela->data + i * rela->sec->sh_entsize;
> diff --git a/xen/common/livepatch_elf.c b/xen/common/livepatch_elf.c
> index 789e8fc..cda9b27 100644
> --- a/xen/common/livepatch_elf.c
> +++ b/xen/common/livepatch_elf.c
> @@ -335,6 +335,7 @@ int livepatch_elf_perform_relocs(struct livepatch_elf 
> *elf)
>      struct livepatch_elf_sec *r, *base;
>      unsigned int i;
>      int rc = 0;
> +    size_t sz;
>  
>      ASSERT(elf->sym);
>  
> @@ -365,6 +366,22 @@ int livepatch_elf_perform_relocs(struct livepatch_elf 
> *elf)
>          }
>  
>          if ( r->sec->sh_type == SHT_RELA )
> +            sz = sizeof(Elf_RelA);
> +        else
> +            sz = sizeof(Elf_Rel);
> +
> +        if ( !r->sec->sh_size )
> +            continue;
> +
> +        if ( r->sec->sh_entsize < sz || r->sec->sh_size % r->sec->sh_entsize 
> )
> +        {
> +            dprintk(XENLOG_ERR, LIVEPATCH "%s: Section relative header is 
> corrupted!\n",
> +                    elf->name);
> +            rc = -EINVAL;
> +            break;
> +        }
> +
> +        if ( r->sec->sh_type == SHT_RELA )
>              rc = arch_livepatch_perform_rela(elf, base, r);
>          else /* SHT_REL */
>              rc = arch_livepatch_perform_rel(elf, base, r);
> -- 
> 2.4.11
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.