From: Kamil Rytarowski <n54@gmx.com>
To: Alan Modra <amodra@gmail.com>, binutils@sourceware.org
Subject: Re: Invalid read in process_netbsd_elf_note
Date: Thu, 19 Mar 2020 13:05:13 +0100 [thread overview]
Message-ID: <84a0af30-1380-a2e7-888f-9cfbbf05f60a@gmx.com> (raw)
In-Reply-To: <20200319032608.GB4583@bubble.grove.modra.org>
[-- Attachment #1.1: Type: text/plain, Size: 2154 bytes --]
Looks OK.
On 19.03.2020 04:26, Alan Modra via Binutils wrote:
> * readelf.c (process_netbsd_elf_note): Validate descsz before
> accessing descdata. Formatting.
>
> diff --git a/binutils/readelf.c b/binutils/readelf.c
> index a11297845e..c8ca66e52c 100644
> --- a/binutils/readelf.c
> +++ b/binutils/readelf.c
> @@ -18402,15 +18402,17 @@ process_netbsd_elf_note (Elf_Internal_Note * pnote)
> switch (pnote->type)
> {
> case NT_NETBSD_IDENT:
> + if (pnote->descsz < 1)
> + break;
> version = byte_get ((unsigned char *) pnote->descdata, sizeof (version));
> if ((version / 10000) % 100)
> - printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u%s%c)\n", pnote->descsz,
> + printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u%s%c)\n", pnote->descsz,
> version, version / 100000000, (version / 1000000) % 100,
> (version / 10000) % 100 > 26 ? "Z" : "",
> 'A' + (version / 10000) % 26);
> else
> printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u.%u)\n", pnote->descsz,
> - version, version / 100000000, (version / 1000000) % 100,
> + version, version / 100000000, (version / 1000000) % 100,
> (version / 100) % 100);
> return TRUE;
>
> @@ -18421,6 +18423,8 @@ process_netbsd_elf_note (Elf_Internal_Note * pnote)
>
> #ifdef NT_NETBSD_PAX
> case NT_NETBSD_PAX:
> + if (pnote->descsz < 1)
> + break;
> version = byte_get ((unsigned char *) pnote->descdata, sizeof (version));
> printf (" NetBSD\t\t0x%08lx\tPaX <%s%s%s%s%s%s>\n", pnote->descsz,
> ((version & NT_NETBSD_PAX_MPROTECT) ? "+mprotect" : ""),
> @@ -18431,12 +18435,11 @@ process_netbsd_elf_note (Elf_Internal_Note * pnote)
> ((version & NT_NETBSD_PAX_NOASLR) ? "-ASLR" : ""));
> return TRUE;
> #endif
> -
> - default:
> - printf (" NetBSD\t0x%08lx\tUnknown note type: (0x%08lx)\n", pnote->descsz,
> - pnote->type);
> - return FALSE;
> }
> +
> + printf (" NetBSD\t0x%08lx\tUnknown note type: (0x%08lx)\n",
> + pnote->descsz, pnote->type);
> + return FALSE;
> }
>
> static const char *
>
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
prev parent reply other threads:[~2020-03-19 12:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-19 3:26 Alan Modra
2020-03-19 12:05 ` Kamil Rytarowski [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=84a0af30-1380-a2e7-888f-9cfbbf05f60a@gmx.com \
--to=n54@gmx.com \
--cc=amodra@gmail.com \
--cc=binutils@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).