* [rppt:uffd/refactor/v0.2 1/11] mm/userfaultfd.c:271 mfill_copy_folio_locked() warn: maybe return -EFAULT instead of the bytes remaining?
@ 2026-01-19 6:05 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-01-19 0:27 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: Mike Rapoport <rppt@kernel.org>
TO: "Mike Rapoport (Microsoft)" <rppt@kernel.org>
Hi Mike,
FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git uffd/refactor/v0.2
head: 2db3a86a6de3247449e068d998305d26481c5522
commit: 46089d290ec3dea8bdbe9a706e3a8247f6c40490 [1/11] userfaultfd: introduce mfill_copy_folio_locked() helper
:::::: branch date: 5 hours ago
:::::: commit date: 9 hours ago
config: x86_64-randconfig-161-20260119 (https://download.01.org/0day-ci/archive/20260119/202601190828.nHc6Gmw1-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch version: v0.5.0-8985-g2614ff1a
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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202601190828.nHc6Gmw1-lkp@intel.com/
smatch warnings:
mm/userfaultfd.c:271 mfill_copy_folio_locked() warn: maybe return -EFAULT instead of the bytes remaining?
vim +271 mm/userfaultfd.c
153132571f0204d Axel Rasmussen 2021-06-30 240
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 241) static int mfill_copy_folio_locked(struct folio *folio, unsigned long src_addr)
c1a4de99fada21e Andrea Arcangeli 2015-09-04 242 {
07e6d4095c75bcf ZhangPeng 2023-04-10 243 void *kaddr;
c1a4de99fada21e Andrea Arcangeli 2015-09-04 244 int ret;
c1a4de99fada21e Andrea Arcangeli 2015-09-04 245
07e6d4095c75bcf ZhangPeng 2023-04-10 246 kaddr = kmap_local_folio(folio, 0);
5521de7dddd211e Ira Weiny 2022-10-23 247 /*
5521de7dddd211e Ira Weiny 2022-10-23 248 * The read mmap_lock is held here. Despite the
5521de7dddd211e Ira Weiny 2022-10-23 249 * mmap_lock being read recursive a deadlock is still
5521de7dddd211e Ira Weiny 2022-10-23 250 * possible if a writer has taken a lock. For example:
5521de7dddd211e Ira Weiny 2022-10-23 251 *
5521de7dddd211e Ira Weiny 2022-10-23 252 * process A thread 1 takes read lock on own mmap_lock
5521de7dddd211e Ira Weiny 2022-10-23 253 * process A thread 2 calls mmap, blocks taking write lock
5521de7dddd211e Ira Weiny 2022-10-23 254 * process B thread 1 takes page fault, read lock on own mmap lock
5521de7dddd211e Ira Weiny 2022-10-23 255 * process B thread 2 calls mmap, blocks taking write lock
5521de7dddd211e Ira Weiny 2022-10-23 256 * process A thread 1 blocks taking read lock on process B
5521de7dddd211e Ira Weiny 2022-10-23 257 * process B thread 1 blocks taking read lock on process A
5521de7dddd211e Ira Weiny 2022-10-23 258 *
5521de7dddd211e Ira Weiny 2022-10-23 259 * Disable page faults to prevent potential deadlock
5521de7dddd211e Ira Weiny 2022-10-23 260 * and retry the copy outside the mmap_lock.
5521de7dddd211e Ira Weiny 2022-10-23 261 */
5521de7dddd211e Ira Weiny 2022-10-23 262 pagefault_disable();
07e6d4095c75bcf ZhangPeng 2023-04-10 263 ret = copy_from_user(kaddr, (const void __user *) src_addr,
b6ebaedb4cb1a18 Andrea Arcangeli 2015-09-04 264 PAGE_SIZE);
5521de7dddd211e Ira Weiny 2022-10-23 265 pagefault_enable();
07e6d4095c75bcf ZhangPeng 2023-04-10 266 kunmap_local(kaddr);
b6ebaedb4cb1a18 Andrea Arcangeli 2015-09-04 267
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 268) if (!ret)
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 269) flush_dcache_folio(folio);
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 270)
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 @271) return ret;
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 272) }
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 273)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* [rppt:uffd/refactor/v0.2 1/11] mm/userfaultfd.c:271 mfill_copy_folio_locked() warn: maybe return -EFAULT instead of the bytes remaining?
@ 2026-01-19 6:05 ` Dan Carpenter
0 siblings, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2026-01-19 6:05 UTC (permalink / raw)
To: oe-kbuild, Mike Rapoport (Microsoft); +Cc: lkp, oe-kbuild-all, Mike Rapoport
Hi Mike,
FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.
tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git uffd/refactor/v0.2
head: 2db3a86a6de3247449e068d998305d26481c5522
commit: 46089d290ec3dea8bdbe9a706e3a8247f6c40490 [1/11] userfaultfd: introduce mfill_copy_folio_locked() helper
config: x86_64-randconfig-161-20260119 (https://download.01.org/0day-ci/archive/20260119/202601190828.nHc6Gmw1-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch version: v0.5.0-8985-g2614ff1a
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>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202601190828.nHc6Gmw1-lkp@intel.com/
smatch warnings:
mm/userfaultfd.c:271 mfill_copy_folio_locked() warn: maybe return -EFAULT instead of the bytes remaining?
vim +271 mm/userfaultfd.c
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 241) static int mfill_copy_folio_locked(struct folio *folio, unsigned long src_addr)
c1a4de99fada21e Andrea Arcangeli 2015-09-04 242 {
07e6d4095c75bcf ZhangPeng 2023-04-10 243 void *kaddr;
c1a4de99fada21e Andrea Arcangeli 2015-09-04 244 int ret;
c1a4de99fada21e Andrea Arcangeli 2015-09-04 245
07e6d4095c75bcf ZhangPeng 2023-04-10 246 kaddr = kmap_local_folio(folio, 0);
5521de7dddd211e Ira Weiny 2022-10-23 247 /*
5521de7dddd211e Ira Weiny 2022-10-23 248 * The read mmap_lock is held here. Despite the
5521de7dddd211e Ira Weiny 2022-10-23 249 * mmap_lock being read recursive a deadlock is still
5521de7dddd211e Ira Weiny 2022-10-23 250 * possible if a writer has taken a lock. For example:
5521de7dddd211e Ira Weiny 2022-10-23 251 *
5521de7dddd211e Ira Weiny 2022-10-23 252 * process A thread 1 takes read lock on own mmap_lock
5521de7dddd211e Ira Weiny 2022-10-23 253 * process A thread 2 calls mmap, blocks taking write lock
5521de7dddd211e Ira Weiny 2022-10-23 254 * process B thread 1 takes page fault, read lock on own mmap lock
5521de7dddd211e Ira Weiny 2022-10-23 255 * process B thread 2 calls mmap, blocks taking write lock
5521de7dddd211e Ira Weiny 2022-10-23 256 * process A thread 1 blocks taking read lock on process B
5521de7dddd211e Ira Weiny 2022-10-23 257 * process B thread 1 blocks taking read lock on process A
5521de7dddd211e Ira Weiny 2022-10-23 258 *
5521de7dddd211e Ira Weiny 2022-10-23 259 * Disable page faults to prevent potential deadlock
5521de7dddd211e Ira Weiny 2022-10-23 260 * and retry the copy outside the mmap_lock.
5521de7dddd211e Ira Weiny 2022-10-23 261 */
5521de7dddd211e Ira Weiny 2022-10-23 262 pagefault_disable();
07e6d4095c75bcf ZhangPeng 2023-04-10 263 ret = copy_from_user(kaddr, (const void __user *) src_addr,
b6ebaedb4cb1a18 Andrea Arcangeli 2015-09-04 264 PAGE_SIZE);
5521de7dddd211e Ira Weiny 2022-10-23 265 pagefault_enable();
07e6d4095c75bcf ZhangPeng 2023-04-10 266 kunmap_local(kaddr);
b6ebaedb4cb1a18 Andrea Arcangeli 2015-09-04 267
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 268) if (!ret)
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 269) flush_dcache_folio(folio);
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 270)
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 @271) return ret;
It doesn't affect runtime but I think this was intended to be:
return ret ? -EFAULT : 0;
46089d290ec3dea Mike Rapoport (Microsoft 2026-01-08 272) }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [rppt:uffd/refactor/v0.2 1/11] mm/userfaultfd.c:271 mfill_copy_folio_locked() warn: maybe return -EFAULT instead of the bytes remaining?
2026-01-19 6:05 ` Dan Carpenter
(?)
@ 2026-01-22 10:34 ` Mike Rapoport
-1 siblings, 0 replies; 3+ messages in thread
From: Mike Rapoport @ 2026-01-22 10:34 UTC (permalink / raw)
To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all
Hi Dan,
On Mon, Jan 19, 2026 at 09:05:58AM +0300, Dan Carpenter wrote:
> Hi Mike,
>
> FYI, the error/warning was bisected to this commit, please ignore it if it's irrelevant.
>
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/rppt/linux.git uffd/refactor/v0.2
> head: 2db3a86a6de3247449e068d998305d26481c5522
> commit: 46089d290ec3dea8bdbe9a706e3a8247f6c40490 [1/11] userfaultfd: introduce mfill_copy_folio_locked() helper
> config: x86_64-randconfig-161-20260119 (https://download.01.org/0day-ci/archive/20260119/202601190828.nHc6Gmw1-lkp@intel.com/config)
> compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
> smatch version: v0.5.0-8985-g2614ff1a
>
> 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>
> | Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> | Closes: https://lore.kernel.org/r/202601190828.nHc6Gmw1-lkp@intel.com/
>
> smatch warnings:
> mm/userfaultfd.c:271 mfill_copy_folio_locked() warn: maybe return -EFAULT instead of the bytes remaining?
Thanks, I'll update it.
--
Sincerely yours,
Mike.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-22 10:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-19 0:27 [rppt:uffd/refactor/v0.2 1/11] mm/userfaultfd.c:271 mfill_copy_folio_locked() warn: maybe return -EFAULT instead of the bytes remaining? kernel test robot
2026-01-19 6:05 ` Dan Carpenter
2026-01-22 10:34 ` Mike Rapoport
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.