linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Hao Ge <hao.ge@linux.dev>,
	surenb@google.com, kent.overstreet@linux.dev,
	akpm@linux-foundation.org
Cc: oe-kbuild-all@lists.linux.dev, linux-mm@kvack.org,
	linux-kernel@vger.kernel.org, hao.ge@linux.dev,
	Hao Ge <gehao@kylinos.cn>, Ben Greear <greearb@candelatech.com>
Subject: Re: [PATCH v3] mm/alloc_tag: Fix panic when CONFIG_KASAN enabled and CONFIG_KASAN_VMALLOC not enabled
Date: Thu, 12 Dec 2024 01:18:16 +0800	[thread overview]
Message-ID: <202412120143.l3g6vx8b-lkp@intel.com> (raw)
In-Reply-To: <20241211025755.56173-1-hao.ge@linux.dev>

Hi Hao,

kernel test robot noticed the following build errors:

[auto build test ERROR on akpm-mm/mm-everything]

url:    https://github.com/intel-lab-lkp/linux/commits/Hao-Ge/mm-alloc_tag-Fix-panic-when-CONFIG_KASAN-enabled-and-CONFIG_KASAN_VMALLOC-not-enabled/20241211-110206
base:   https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link:    https://lore.kernel.org/r/20241211025755.56173-1-hao.ge%40linux.dev
patch subject: [PATCH v3] mm/alloc_tag: Fix panic when CONFIG_KASAN enabled and CONFIG_KASAN_VMALLOC not enabled
config: i386-buildonly-randconfig-005-20241211 (https://download.01.org/0day-ci/archive/20241212/202412120143.l3g6vx8b-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241212/202412120143.l3g6vx8b-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412120143.l3g6vx8b-lkp@intel.com/

All errors (new ones prefixed by >>):

   lib/alloc_tag.c: In function 'vm_module_tags_populate':
>> lib/alloc_tag.c:409:40: error: 'KASAN_SHADOW_SCALE_SHIFT' undeclared (first use in this function)
     409 |                                  (2 << KASAN_SHADOW_SCALE_SHIFT) - 1) >> KASAN_SHADOW_SCALE_SHIFT;
         |                                        ^~~~~~~~~~~~~~~~~~~~~~~~
   lib/alloc_tag.c:409:40: note: each undeclared identifier is reported only once for each function it appears in


vim +/KASAN_SHADOW_SCALE_SHIFT +409 lib/alloc_tag.c

   402	
   403	static int vm_module_tags_populate(void)
   404	{
   405		unsigned long phys_end = ALIGN_DOWN(module_tags.start_addr, PAGE_SIZE) +
   406					 (vm_module_tags->nr_pages << PAGE_SHIFT);
   407		unsigned long new_end = module_tags.start_addr + module_tags.size;
   408		unsigned long phys_idx = (vm_module_tags->nr_pages +
 > 409					 (2 << KASAN_SHADOW_SCALE_SHIFT) - 1) >> KASAN_SHADOW_SCALE_SHIFT;
   410		unsigned long new_idx = 0;
   411	
   412		if (phys_end < new_end) {
   413			struct page **next_page = vm_module_tags->pages + vm_module_tags->nr_pages;
   414			unsigned long more_pages;
   415			unsigned long nr;
   416	
   417			more_pages = ALIGN(new_end - phys_end, PAGE_SIZE) >> PAGE_SHIFT;
   418			nr = alloc_pages_bulk_array_node(GFP_KERNEL | __GFP_NOWARN,
   419							 NUMA_NO_NODE, more_pages, next_page);
   420			if (nr < more_pages ||
   421			    vmap_pages_range(phys_end, phys_end + (nr << PAGE_SHIFT), PAGE_KERNEL,
   422					     next_page, PAGE_SHIFT) < 0) {
   423				/* Clean up and error out */
   424				for (int i = 0; i < nr; i++)
   425					__free_page(next_page[i]);
   426				return -ENOMEM;
   427			}
   428	
   429			vm_module_tags->nr_pages += nr;
   430	
   431			new_idx = (vm_module_tags->nr_pages +
   432				  (2 << KASAN_SHADOW_SCALE_SHIFT) - 1) >> KASAN_SHADOW_SCALE_SHIFT;
   433	
   434			/*
   435			 * Kasan allocates 1 byte of shadow for every 8 bytes of data.
   436			 * When kasan_alloc_module_shadow allocates shadow memory,
   437			 * its unit of allocation is a page.
   438			 * Therefore, here we need to align to MODULE_ALIGN.
   439			 *
   440			 * For every KASAN_SHADOW_SCALE_SHIFT, a shadow page is allocated.
   441			 * So, we determine whether to allocate based on whether the
   442			 * number of pages falls within the scope of the same KASAN_SHADOW_SCALE_SHIFT.
   443			 */
   444			if (phys_idx != new_idx)
   445				kasan_alloc_module_shadow((void *)round_up(phys_end, MODULE_ALIGN),
   446							  (new_idx - phys_idx) * MODULE_ALIGN,
   447							  GFP_KERNEL);
   448		}
   449	
   450		/*
   451		 * Mark the pages as accessible, now that they are mapped.
   452		 * With hardware tag-based KASAN, marking is skipped for
   453		 * non-VM_ALLOC mappings, see __kasan_unpoison_vmalloc().
   454		 */
   455		kasan_unpoison_vmalloc((void *)module_tags.start_addr,
   456					new_end - module_tags.start_addr,
   457					KASAN_VMALLOC_PROT_NORMAL);
   458	
   459		return 0;
   460	}
   461	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki


  parent reply	other threads:[~2024-12-11 17:18 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-10  4:15 [PATCH] mm/alloc_tag: Add kasan_alloc_module_shadow when CONFIS_KASAN_VMALLOC disabled Hao Ge
2024-12-10  6:53 ` [PATCH v2] " Hao Ge
2024-12-10 17:55   ` Suren Baghdasaryan
2024-12-10 18:45     ` Hao Ge
2024-12-10 19:20       ` Suren Baghdasaryan
2024-12-10 19:36         ` Hao Ge
2024-12-10 20:04           ` Suren Baghdasaryan
2024-12-11  1:10             ` Hao Ge
2024-12-11  2:57               ` [PATCH v3] mm/alloc_tag: Fix panic when CONFIG_KASAN enabled and CONFIG_KASAN_VMALLOC not enabled Hao Ge
2024-12-11 16:32                 ` Suren Baghdasaryan
2024-12-12  1:07                   ` Hao Ge
2024-12-12  1:37                     ` [PATCH v4] " Hao Ge
2024-12-12  6:48                       ` Suren Baghdasaryan
2024-12-12  7:03                         ` [PATCH v5] " Hao Ge
2024-12-12  7:21                           ` [PATCH v6] " Hao Ge
2024-12-12 14:07                             ` Adrian Huang12
2024-12-11 17:18                 ` kernel test robot [this message]
2024-12-12  2:23                   ` [PATCH v3] " Hao Ge
2024-12-10 18:56     ` [PATCH v2] mm/alloc_tag: Add kasan_alloc_module_shadow when CONFIS_KASAN_VMALLOC disabled Ben Greear

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=202412120143.l3g6vx8b-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=gehao@kylinos.cn \
    --cc=greearb@candelatech.com \
    --cc=hao.ge@linux.dev \
    --cc=kent.overstreet@linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=surenb@google.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