[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <6c8b9d6b-fc31-11d6-c5d4-c18b3854b4e9@huawei.com>
Date: Thu, 3 Mar 2022 19:48:35 +0800
From: Miaohe Lin <linmiaohe@...wei.com>
To: Dan Carpenter <dan.carpenter@...cle.com>,
Yang Shi <shy828301@...il.com>
CC: <lkp@...el.com>, <kbuild-all@...ts.01.org>, <linux-mm@...ck.org>,
<linux-fsdevel@...r.kernel.org>, <linux-ext4@...r.kernel.org>,
<linux-xfs@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<kbuild@...ts.01.org>, <vbabka@...e.cz>,
<kirill.shutemov@...ux.intel.com>, <songliubraving@...com>,
<riel@...riel.com>, <willy@...radead.org>, <ziy@...dia.com>,
<akpm@...ux-foundation.org>, <tytso@....edu>,
<adilger.kernel@...ger.ca>, <darrick.wong@...cle.com>
Subject: Re: [PATCH 4/8] mm: thp: only regular file could be THP eligible
On 2022/3/3 19:43, Dan Carpenter wrote:
> Hi Yang,
>
> url: https://github.com/0day-ci/linux/commits/Yang-Shi/Make-khugepaged-collapse-readonly-FS-THP-more-consistent/20220301-075903
> base: https://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4.git dev
> config: arm64-randconfig-m031-20220227 (https://download.01.org/0day-ci/archive/20220302/202203020034.2Ii9kTrs-lkp@intel.com/config)
> compiler: aarch64-linux-gcc (GCC) 11.2.0
>
> If you fix the issue, kindly add following tag as appropriate
> Reported-by: kernel test robot <lkp@...el.com>
> Reported-by: Dan Carpenter <dan.carpenter@...cle.com>
>
> smatch warnings:
> include/linux/huge_mm.h:179 file_thp_enabled() warn: variable dereferenced before check 'vma->vm_file' (see line 177)
> mm/khugepaged.c:468 hugepage_vma_check() error: we previously assumed 'vma->vm_file' could be null (see line 455)
> include/linux/huge_mm.h:179 file_thp_enabled() warn: variable dereferenced before check 'vma->vm_file' (see line 177)
>
> vim +179 include/linux/huge_mm.h
>
> 2224ed1155c07b Yang Shi 2022-02-28 175 static inline bool file_thp_enabled(struct vm_area_struct *vma)
> 2224ed1155c07b Yang Shi 2022-02-28 176 {
> 2224ed1155c07b Yang Shi 2022-02-28 @177 struct inode *inode = vma->vm_file->f_inode;
> ^^^^^^^^^^^^^^
> Dereference.
>
> 2224ed1155c07b Yang Shi 2022-02-28 178
> 2224ed1155c07b Yang Shi 2022-02-28 @179 return (IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS)) && vma->vm_file &&
> ^^^^^^^^^^^^
> Checked too late.
Yep. We should check vma->vm_file first before we access vma->vm_file->f_inode.
Thanks.
>
> 2224ed1155c07b Yang Shi 2022-02-28 180 (vma->vm_flags & VM_EXEC) &&
> 2224ed1155c07b Yang Shi 2022-02-28 181 !inode_is_open_for_write(inode) && S_ISREG(inode->i_mode);
> 2224ed1155c07b Yang Shi 2022-02-28 182 }
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
>
> .
>
Powered by blists - more mailing lists