On Fri, Jan 24, 2025 at 1:41 PM Josh Poimboeuf <jpoimboe@xxxxxxxxxx> 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@xxxxxxxxxx> 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?
offset_size is <= 2 as returned by offset_size_enum_to_size().
offset_count is expected to be <= 3, enforced by the !offset_count check
at the bottom.
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.