lkml.org 
[lkml]   [2023]   [Jul]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH] hugetlbfs: Fix integer overflow check in hugetlbfs_file_mmap()
From
On 10.07.23 10:32, Linke Li wrote:
> From: Linke Li <lilinke99@gmail.com>
>
> vma_len = (loff_t)(vma->vm_end - vma->vm_start);
> len = vma_len + ((loff_t)vma->vm_pgoff << PAGE_SHIFT);
> /* check for overflow */
> if (len < vma_len)
> return -EINVAL;
>
> The existing code includes an integer overflow check, which indicates
> that the variable len has the potential to overflow, leading to undefined
> behavior according to the C standard. However, both GCC and Clang
> compilers may eliminate this overflow check based on the assumption
> that there will be no undefined behavior. Although the Linux kernel
> disables these optimizations by using the -fno-strict-overflow option,
> there is still a risk if the compilers make mistakes in the future.

So we're adding code to handle eventual future compiler bugs? That
sounds wrong, but maybe I misunderstood the problem you are trying to solve?

--
Cheers,

David / dhildenb

\
 
 \ /
  Last update: 2023-07-11 13:50    [W:1.142 / U:0.048 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site