[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <672a4d84-219c-4d45-b3a7-8d9d96e90e01@linux.ibm.com>
Date: Tue, 28 Jan 2025 11:50:25 +0100
From: Jens Remus <jremus@...ux.ibm.com>
To: Andrii Nakryiko <andrii.nakryiko@...il.com>,
Josh Poimboeuf <jpoimboe@...nel.org>
Cc: x86@...nel.org, Peter Zijlstra <peterz@...radead.org>,
Steven Rostedt <rostedt@...dmis.org>, Ingo Molnar <mingo@...nel.org>,
Arnaldo Carvalho de Melo <acme@...nel.org>,
linux-kernel@...r.kernel.org, Indu Bhagat <indu.bhagat@...cle.com>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
Jiri Olsa <jolsa@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Ian Rogers <irogers@...gle.com>,
Adrian Hunter <adrian.hunter@...el.com>,
linux-perf-users@...r.kernel.org, Mark Brown <broonie@...nel.org>,
linux-toolchains@...r.kernel.org, Jordan Rome <jordalgo@...a.com>,
Sam James <sam@...too.org>, linux-trace-kernel@...r.kernel.org,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Florian Weimer <fweimer@...hat.com>, Andy Lutomirski <luto@...nel.org>,
Masami Hiramatsu <mhiramat@...nel.org>, Weinan Liu <wnliu@...gle.com>,
heiko Carstens <hca@...ux.ibm.com>, Vasily Gorbik <gor@...ux.ibm.com>
Subject: Re: [PATCH v4 19/39] unwind_user/sframe: Add support for reading
.sframe contents
On 28.01.2025 01:39, Andrii Nakryiko wrote:
> On Fri, Jan 24, 2025 at 1:41 PM Josh Poimboeuf <jpoimboe@...nel.org> wrote:
>> On Fri, Jan 24, 2025 at 10:02:46AM -0800, Andrii Nakryiko wrote:
>>> On Tue, Jan 21, 2025 at 6:32 PM Josh Poimboeuf <jpoimboe@...nel.org> wrote:
>>>> + UNSAFE_GET_USER_INC(info, cur, 1, Efault);
>>>> + offset_count = SFRAME_FRE_OFFSET_COUNT(info);
>>>> + offset_size = offset_size_enum_to_size(SFRAME_FRE_OFFSET_SIZE(info));
>>>> + if (!offset_count || !offset_size)
>>>> + return -EFAULT;
>>>> +
>>>> + if (cur + (offset_count * offset_size) > sec->fres_end)
>>>
>>> offset_count * offset_size done in u8 can overflow, no? maybe upcast
>>> to unsigned long or use check_add_overflow?
The maximum offset_count * offset_size is 15 * 4 = 60 if I am not wrong:
>> offset_size is <= 2 as returned by offset_size_enum_to_size().
SFrame V2 FRE offset sizes are either 1, 2, or 4 bytes. This is also
reflected in offset_size_enum_to_size().
>> offset_count is expected to be <= 3, enforced by the !offset_count check
>> at the bottom.
SFrame V2 FRE offset count is 4 bits unsigned, so 0 <= offset_count <= 15.
>> An overflow here would be harmless as it would be caught by the
>> !offset_count anyway. Though I also notice offset_count isn't big
>> enough to hold the 2-byte SFRAME_FRE_OFFSET_COUNT() value. Which is
>> harmless for the same reason, but yeah I'll make offset_count an
>> unsigned int.
As mentioned above the FRE offset count is 4 bits, not 2 bytes. This is
also reflected in SFRAME_FRE_OFFSET_COUNT().
Regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
+49-7031-16-1128 Office
jremus@...ibm.com
IBM
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Böblingen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
Powered by blists - more mailing lists