lkml.org 
[lkml]   [2023]   [Aug]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v26 2/5] fs/proc/task_mmu: Implement IOCTL to get and optionally clear info about PTEs
On Thu, 3 Aug 2023 at 17:09, Andrei Vagin <avagin@gmail.com> wrote:
> On Thu, Jul 27, 2023 at 02:36:34PM +0500, Muhammad Usama Anjum wrote:
[...]
> > + n_pages = (*end - addr) / PAGE_SIZE;
> > + if (check_add_overflow(p->found_pages, n_pages, &total_pages) ||
> > + total_pages > p->arg.max_pages) {
>
> why do we need to use check_add_overflow here?
>
> > + size_t n_too_much = total_pages - p->arg.max_pages;
>
> it is unsafe to use total_pages if check_add_overflow returns non-zero.

Since we're adding unsigned integers, this is well defined even after overflow.

Best Regards
Michał Mirosław

\
 
 \ /
  Last update: 2023-08-03 17:26    [W:0.156 / U:0.380 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site