Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <274f856f192b487b84a976b66ce473b1@sap.com>
Date: Tue, 10 Apr 2018 07:22:44 +0000
From: "Siebenborn, Axel" <axel.siebenborn@....com>
To: "musl@...ts.openwall.com" <musl@...ts.openwall.com>
Subject: FW: [PATCH] dl_addr: compare addr with sym->st_size.

Hi,
I just wanted to ask, if there something wrong with that patch, as there was no reaction.

Currently, I am fixing tests in the OpenJDK portola project (http://openjdk.java.net/projects/portola/).
Some tests fail, since we don't get correct stack traces due to the dladdr problem.

Regards,
Axel

> -----Original Message-----
> From: Siebenborn, Axel [mailto:axel.siebenborn@....com]
> Sent: Dienstag, 3. April 2018 15:06
> To: musl@...ts.openwall.com
> Subject: [CAUTION] [musl] [PATCH] dl_addr: compare addr with sym-
> >st_size.
> 
> Hi,
> this patch fixes a problem with dl_addr.
> 
> We found symbols, in cases we should not find a symbol, since the
> comparison with sym->st_size is missing.
> 
> According to the spec, dl_addr should not return an error in this case. Instead
> dli_sname and dli_addr should be set to NULL.
> 
> Regards,
> Axel
> 
> diff --git a/ldso/dynlink.c b/ldso/dynlink.c
> index 9bf6924..cc87dc0 100644
> --- a/ldso/dynlink.c
> +++ b/ldso/dynlink.c
> @@ -1958,7 +1958,7 @@ int dladdr(const void *addr, Dl_info *info)
>                  && (1<<(sym->st_info&0xf) & OK_TYPES)
>                  && (1<<(sym->st_info>>4) & OK_BINDS)) {
>                         void *symaddr = laddr(p, sym->st_value);
> -                       if (symaddr > addr || symaddr < best)
> +                       if (symaddr > addr || (void*) ((uint8_t*) symaddr + sym-
> >st_size) < addr || symaddr < best)
>                                 continue;
>                         best = symaddr;
>                         bestsym = sym;
> @@ -1967,13 +1967,16 @@ int dladdr(const void *addr, Dl_info *info)
>                 }
>         }
> 
> -       if (!best) return 0;
> -
> -       if (DL_FDPIC && (bestsym->st_info&0xf) == STT_FUNC)
> -               best = p->funcdescs + (bestsym - p->syms);
> -
>         info->dli_fname = p->name;
>         info->dli_fbase = p->map;
> +       if (!best) {
> +               info->dli_sname = 0;
> +               info->dli_saddr = 0;
> +               return 0
> +       }
> +
> +       if ( DL_FDPIC && (bestsym->st_info&0xf) == STT_FUNC)
> +               best = p->funcdescs + (bestsym - p->syms);
>         info->dli_sname = strings + bestsym->st_name;
>         info->dli_saddr = best;

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.