Re: [PATCH] libdw: check memory access in get_(u|s)leb128

2023-02-13 Thread Aleksei Vetrov via Elfutils-devel
Hi Mark, On Sat, Feb 11, 2023 at 11:43 PM Mark Wielaard wrote: > After this code we will do: > > /* There might be one extra byte. */ > unsigned char b = **addrp; > ++*addrp; > > So I think we want to catch that too. Easiest imho seems to move (and > invert) the max check immediately afte

Re: [PATCH] libdw: check memory access in get_(u|s)leb128

2023-02-11 Thread Mark Wielaard
Hi Aleksei, On Wed, Jan 25, 2023 at 04:05:30PM +, Aleksei Vetrov via Elfutils-devel wrote: > From: Aleksei Vetrov > > __libdw_get_uleb128 and __libdw_get_sleb128 should check if addrp has > already reached the end before unrolling the first step. It is done by > moving __libdw_max_len to th

Re: [PATCH] libdw: check memory access in get_(u|s)leb128

2023-02-07 Thread Mark Wielaard
Hi Aleksei, On Tue, 2023-02-07 at 16:17 +, Aleksei Vetrov wrote: > > Did you actually find situations where these functions were called > > with addrp > > > = endp? > > Yes, for example libdw/libdw_form.c:91:7. > Urgh. There are actually 3 places in that function that need a guard. Then I s

Re: [PATCH] libdw: check memory access in get_(u|s)leb128

2023-02-07 Thread Aleksei Vetrov via Elfutils-devel
Hi Mark, > Did you actually find situations where these functions were called with addrp > >= endp? Yes, for example libdw/libdw_form.c:91:7. > It turns out that get_[su]leb128 dominates some operations and really does > have to be as fast as possible. So I do like to know what the impact is of

Re: [PATCH] libdw: check memory access in get_(u|s)leb128

2023-01-26 Thread Mark Wielaard
Hi Aleksei, On Wed, Jan 25, 2023 at 04:05:30PM +, Aleksei Vetrov via Elfutils-devel wrote: > From: Aleksei Vetrov > > __libdw_get_uleb128 and __libdw_get_sleb128 should check if addrp has > already reached the end before unrolling the first step. It is done by > moving __libdw_max_len to th

[PATCH] libdw: check memory access in get_(u|s)leb128

2023-01-25 Thread Aleksei Vetrov via Elfutils-devel
From: Aleksei Vetrov __libdw_get_uleb128 and __libdw_get_sleb128 should check if addrp has already reached the end before unrolling the first step. It is done by moving __libdw_max_len to the beginning of the function, which already has all the checks. Signed-off-by: Aleksei Vetrov --- libdw/m