From: Matthew Wilcox <willy@infradead.org>
To: Linke Li <lilinke99@foxmail.com>
Cc: linux-mm@kvack.org, mike.kravetz@oracle.com,
muchun.song@linux.dev, nathan@kernel.org,
ndesaulniers@google.com, trix@redhat.com,
linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
dan.carpenter@linaro.org, Linke Li <lilinke99@gmail.com>
Subject: Re: [PATCH v3] hugetlbfs: Fix integer overflow check in hugetlbfs_file_mmap()
Date: Mon, 24 Jul 2023 04:47:33 +0100 [thread overview]
Message-ID: <ZL30Vaj8RYxmsF9o@casper.infradead.org> (raw)
In-Reply-To: <tencent_C2D6865561F23A8141BB145149ACC682B408@qq.com>
On Thu, Jul 20, 2023 at 10:49:52PM +0800, Linke Li wrote:
> +++ b/fs/hugetlbfs/inode.c
> @@ -154,10 +154,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
> if (vma->vm_pgoff & (~huge_page_mask(h) >> PAGE_SHIFT))
> return -EINVAL;
>
> - 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)
> + if (check_add_overflow(vma_len, (loff_t)vma->vm_pgoff << PAGE_SHIFT, &len))
> return -EINVAL;
Doesn't this check duplicate that performed by file_mmap_ok()? Can't we
just delete the check, or is there a code path that leads here while
avoiding file_mmap_ok()?
next prev parent reply other threads:[~2023-07-24 3:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-20 14:49 [PATCH v3] hugetlbfs: Fix integer overflow check in hugetlbfs_file_mmap() Linke Li
2023-07-20 18:41 ` Mike Kravetz
2023-07-20 19:03 ` Nick Desaulniers
2023-07-20 23:36 ` kernel test robot
2023-07-24 3:47 ` Matthew Wilcox [this message]
2023-07-24 18:59 ` Mike Kravetz
2023-07-24 8:11 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ZL30Vaj8RYxmsF9o@casper.infradead.org \
--to=willy@infradead.org \
--cc=dan.carpenter@linaro.org \
--cc=lilinke99@foxmail.com \
--cc=lilinke99@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
--cc=mike.kravetz@oracle.com \
--cc=muchun.song@linux.dev \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=trix@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).