* arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
@ 2024-10-26 15:30 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-10-26 15:30 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Heiko Carstens <hca@linux.ibm.com>
CC: Vasily Gorbik <gor@linux.ibm.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 850925a8133c73c4a2453c360b2c3beb3bab67c9
commit: 7c194d84a9ce662426b2ecb59da54bb80c6b1d91 s390/mm,fault: remove VM_FAULT_BADMAP and VM_FAULT_BADACCESS
date: 1 year ago
:::::: branch date: 17 hours ago
:::::: commit date: 1 year ago
config: s390-randconfig-r072-20241024 (https://download.01.org/0day-ci/archive/20241026/202410262304.gfSWpFtO-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.1.0
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/202410262304.gfSWpFtO-lkp@intel.com/
smatch warnings:
arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
vim +566 arch/s390/mm/fault.c
17a363dcd2f745 Heiko Carstens 2021-04-09 497
084ea4d611a3d0 Vasily Gorbik 2020-01-21 498 void do_secure_storage_access(struct pt_regs *regs)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 499 {
5be05c35e72f74 Heiko Carstens 2023-10-12 500 union teid teid = { .val = regs->int_parm_long };
9641613f48bbf8 Heiko Carstens 2023-10-12 501 unsigned long addr = get_fault_address(regs);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 502 struct vm_area_struct *vma;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 503 struct mm_struct *mm;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 504 struct page *page;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 505 struct gmap *gmap;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 506 int rc;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 507
85b18d7b5e7ffe Janosch Frank 2021-01-12 508 /*
3aad8c04429779 Heiko Carstens 2023-10-12 509 * Bit 61 indicates if the address is valid, if it is not the
3aad8c04429779 Heiko Carstens 2023-10-12 510 * kernel should be stopped or SIGSEGV should be sent to the
3aad8c04429779 Heiko Carstens 2023-10-12 511 * process. Bit 61 is not reliable without the misc UV feature,
3aad8c04429779 Heiko Carstens 2023-10-12 512 * therefore this needs to be checked too.
85b18d7b5e7ffe Janosch Frank 2021-01-12 513 */
5be05c35e72f74 Heiko Carstens 2023-10-12 514 if (uv_has_feature(BIT_UV_FEAT_MISC) && !teid.b61) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 515 /*
85b18d7b5e7ffe Janosch Frank 2021-01-12 516 * When this happens, userspace did something that it
85b18d7b5e7ffe Janosch Frank 2021-01-12 517 * was not supposed to do, e.g. branching into secure
85b18d7b5e7ffe Janosch Frank 2021-01-12 518 * memory. Trigger a segmentation fault.
85b18d7b5e7ffe Janosch Frank 2021-01-12 519 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 520 if (user_mode(regs)) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 521 send_sig(SIGSEGV, current, 0);
85b18d7b5e7ffe Janosch Frank 2021-01-12 522 return;
85b18d7b5e7ffe Janosch Frank 2021-01-12 523 }
85b18d7b5e7ffe Janosch Frank 2021-01-12 524 /*
3aad8c04429779 Heiko Carstens 2023-10-12 525 * The kernel should never run into this case and
3aad8c04429779 Heiko Carstens 2023-10-12 526 * there is no way out of this situation.
85b18d7b5e7ffe Janosch Frank 2021-01-12 527 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 528 panic("Unexpected PGM 0x3d with TEID bit 61=0");
85b18d7b5e7ffe Janosch Frank 2021-01-12 529 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 530 switch (get_fault_type(regs)) {
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 531 case GMAP_FAULT:
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 532 mm = current->mm;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 533 gmap = (struct gmap *)S390_lowcore.gmap;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 534 mmap_read_lock(mm);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 535 addr = __gmap_translate(gmap, addr);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 536 mmap_read_unlock(mm);
7c194d84a9ce66 Heiko Carstens 2023-10-12 537 if (IS_ERR_VALUE(addr))
7c194d84a9ce66 Heiko Carstens 2023-10-12 538 return handle_fault_error_nolock(regs, SEGV_MAPERR);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 539 fallthrough;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 540 case USER_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 541 mm = current->mm;
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 542 mmap_read_lock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 543 vma = find_vma(mm, addr);
7c194d84a9ce66 Heiko Carstens 2023-10-12 544 if (!vma)
7c194d84a9ce66 Heiko Carstens 2023-10-12 545 return handle_fault_error(regs, SEGV_MAPERR);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 546 page = follow_page(vma, addr, FOLL_WRITE | FOLL_GET);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 547 if (IS_ERR_OR_NULL(page)) {
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 548 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 549 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 550 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 551 if (arch_make_page_accessible(page))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 552 send_sig(SIGSEGV, current, 0);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 553 put_page(page);
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 554 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 555 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 556 case KERNEL_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 557 page = phys_to_page(addr);
cd1adf1b63a112 Linus Torvalds 2021-09-07 558 if (unlikely(!try_get_page(page)))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 559 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 560 rc = arch_make_page_accessible(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 561 put_page(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 562 if (rc)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 563 BUG();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 564 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 565 default:
ae626f686351d2 Heiko Carstens 2023-10-12 @566 unreachable();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 567 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 568 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 569 NOKPROBE_SYMBOL(do_secure_storage_access);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 570
:::::: The code at line 566 was first introduced by commit
:::::: ae626f686351d220d5eab746dc3a19e90bb1de9a s390/mm,fault: replace WARN_ON_ONCE() with unreachable()
:::::: TO: Heiko Carstens <hca@linux.ibm.com>
:::::: CC: Vasily Gorbik <gor@linux.ibm.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
@ 2024-10-25 7:35 Dan Carpenter
2024-10-25 10:05 ` Heiko Carstens
0 siblings, 1 reply; 7+ messages in thread
From: Dan Carpenter @ 2024-10-25 7:35 UTC (permalink / raw)
To: oe-kbuild, Heiko Carstens; +Cc: lkp, oe-kbuild-all, linux-kernel, Vasily Gorbik
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c2ee9f594da826bea183ed14f2cc029c719bf4da
commit: 7c194d84a9ce662426b2ecb59da54bb80c6b1d91 s390/mm,fault: remove VM_FAULT_BADMAP and VM_FAULT_BADACCESS
config: s390-randconfig-r072-20241024 (https://download.01.org/0day-ci/archive/20241025/202410250552.XsMLl1sx-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.1.0
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/202410250552.XsMLl1sx-lkp@intel.com/
smatch warnings:
arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
vim +566 arch/s390/mm/fault.c
084ea4d611a3d0 Vasily Gorbik 2020-01-21 498 void do_secure_storage_access(struct pt_regs *regs)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 499 {
5be05c35e72f74 Heiko Carstens 2023-10-12 500 union teid teid = { .val = regs->int_parm_long };
9641613f48bbf8 Heiko Carstens 2023-10-12 501 unsigned long addr = get_fault_address(regs);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 502 struct vm_area_struct *vma;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 503 struct mm_struct *mm;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 504 struct page *page;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 505 struct gmap *gmap;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 506 int rc;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 507
85b18d7b5e7ffe Janosch Frank 2021-01-12 508 /*
3aad8c04429779 Heiko Carstens 2023-10-12 509 * Bit 61 indicates if the address is valid, if it is not the
3aad8c04429779 Heiko Carstens 2023-10-12 510 * kernel should be stopped or SIGSEGV should be sent to the
3aad8c04429779 Heiko Carstens 2023-10-12 511 * process. Bit 61 is not reliable without the misc UV feature,
3aad8c04429779 Heiko Carstens 2023-10-12 512 * therefore this needs to be checked too.
85b18d7b5e7ffe Janosch Frank 2021-01-12 513 */
5be05c35e72f74 Heiko Carstens 2023-10-12 514 if (uv_has_feature(BIT_UV_FEAT_MISC) && !teid.b61) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 515 /*
85b18d7b5e7ffe Janosch Frank 2021-01-12 516 * When this happens, userspace did something that it
85b18d7b5e7ffe Janosch Frank 2021-01-12 517 * was not supposed to do, e.g. branching into secure
85b18d7b5e7ffe Janosch Frank 2021-01-12 518 * memory. Trigger a segmentation fault.
85b18d7b5e7ffe Janosch Frank 2021-01-12 519 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 520 if (user_mode(regs)) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 521 send_sig(SIGSEGV, current, 0);
85b18d7b5e7ffe Janosch Frank 2021-01-12 522 return;
85b18d7b5e7ffe Janosch Frank 2021-01-12 523 }
85b18d7b5e7ffe Janosch Frank 2021-01-12 524 /*
3aad8c04429779 Heiko Carstens 2023-10-12 525 * The kernel should never run into this case and
3aad8c04429779 Heiko Carstens 2023-10-12 526 * there is no way out of this situation.
85b18d7b5e7ffe Janosch Frank 2021-01-12 527 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 528 panic("Unexpected PGM 0x3d with TEID bit 61=0");
85b18d7b5e7ffe Janosch Frank 2021-01-12 529 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 530 switch (get_fault_type(regs)) {
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 531 case GMAP_FAULT:
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 532 mm = current->mm;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 533 gmap = (struct gmap *)S390_lowcore.gmap;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 534 mmap_read_lock(mm);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 535 addr = __gmap_translate(gmap, addr);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 536 mmap_read_unlock(mm);
7c194d84a9ce66 Heiko Carstens 2023-10-12 537 if (IS_ERR_VALUE(addr))
7c194d84a9ce66 Heiko Carstens 2023-10-12 538 return handle_fault_error_nolock(regs, SEGV_MAPERR);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 539 fallthrough;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 540 case USER_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 541 mm = current->mm;
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 542 mmap_read_lock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 543 vma = find_vma(mm, addr);
7c194d84a9ce66 Heiko Carstens 2023-10-12 544 if (!vma)
7c194d84a9ce66 Heiko Carstens 2023-10-12 545 return handle_fault_error(regs, SEGV_MAPERR);
mmap_read_unlock() before returning?
084ea4d611a3d0 Vasily Gorbik 2020-01-21 546 page = follow_page(vma, addr, FOLL_WRITE | FOLL_GET);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 547 if (IS_ERR_OR_NULL(page)) {
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 548 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 549 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 550 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 551 if (arch_make_page_accessible(page))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 552 send_sig(SIGSEGV, current, 0);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 553 put_page(page);
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 554 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 555 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 556 case KERNEL_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 557 page = phys_to_page(addr);
cd1adf1b63a112 Linus Torvalds 2021-09-07 558 if (unlikely(!try_get_page(page)))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 559 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 560 rc = arch_make_page_accessible(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 561 put_page(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 562 if (rc)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 563 BUG();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 564 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 565 default:
ae626f686351d2 Heiko Carstens 2023-10-12 @566 unreachable();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 567 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 568 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
2024-10-25 7:35 Dan Carpenter
@ 2024-10-25 10:05 ` Heiko Carstens
0 siblings, 0 replies; 7+ messages in thread
From: Heiko Carstens @ 2024-10-25 10:05 UTC (permalink / raw)
To: Dan Carpenter; +Cc: oe-kbuild, lkp, oe-kbuild-all, linux-kernel, Vasily Gorbik
On Fri, Oct 25, 2024 at 10:35:47AM +0300, Dan Carpenter wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
> head: c2ee9f594da826bea183ed14f2cc029c719bf4da
> commit: 7c194d84a9ce662426b2ecb59da54bb80c6b1d91 s390/mm,fault: remove VM_FAULT_BADMAP and VM_FAULT_BADACCESS
> config: s390-randconfig-r072-20241024 (https://download.01.org/0day-ci/archive/20241025/202410250552.XsMLl1sx-lkp@intel.com/config)
> compiler: s390-linux-gcc (GCC) 14.1.0
>
> 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/202410250552.XsMLl1sx-lkp@intel.com/
>
> smatch warnings:
> arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
...
> 084ea4d611a3d0 Vasily Gorbik 2020-01-21 540 case USER_FAULT:
> 084ea4d611a3d0 Vasily Gorbik 2020-01-21 541 mm = current->mm;
> d8ed45c5dcd455 Michel Lespinasse 2020-06-08 542 mmap_read_lock(mm);
> 084ea4d611a3d0 Vasily Gorbik 2020-01-21 543 vma = find_vma(mm, addr);
> 7c194d84a9ce66 Heiko Carstens 2023-10-12 544 if (!vma)
> 7c194d84a9ce66 Heiko Carstens 2023-10-12 545 return handle_fault_error(regs, SEGV_MAPERR);
>
> mmap_read_unlock() before returning?
This is a false positive: handle_fault_error() contains an unconditional
mmap_read_unlock() call. I would wish the __acquires() and __releases()
annotations would work better (or maybe I just can't figure out to use them
properly.
In any case: do_secure_storage_access() will very likely go away with the next
merge window and its functionality will be implemented differently.
^ permalink raw reply [flat|nested] 7+ messages in thread
* arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
@ 2024-10-24 21:57 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-10-24 21:57 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Heiko Carstens <hca@linux.ibm.com>
CC: Vasily Gorbik <gor@linux.ibm.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: c2ee9f594da826bea183ed14f2cc029c719bf4da
commit: 7c194d84a9ce662426b2ecb59da54bb80c6b1d91 s390/mm,fault: remove VM_FAULT_BADMAP and VM_FAULT_BADACCESS
date: 1 year ago
:::::: branch date: 3 days ago
:::::: commit date: 1 year ago
config: s390-randconfig-r072-20241024 (https://download.01.org/0day-ci/archive/20241025/202410250552.XsMLl1sx-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.1.0
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/202410250552.XsMLl1sx-lkp@intel.com/
smatch warnings:
arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
vim +566 arch/s390/mm/fault.c
17a363dcd2f745 Heiko Carstens 2021-04-09 497
084ea4d611a3d0 Vasily Gorbik 2020-01-21 498 void do_secure_storage_access(struct pt_regs *regs)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 499 {
5be05c35e72f74 Heiko Carstens 2023-10-12 500 union teid teid = { .val = regs->int_parm_long };
9641613f48bbf8 Heiko Carstens 2023-10-12 501 unsigned long addr = get_fault_address(regs);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 502 struct vm_area_struct *vma;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 503 struct mm_struct *mm;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 504 struct page *page;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 505 struct gmap *gmap;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 506 int rc;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 507
85b18d7b5e7ffe Janosch Frank 2021-01-12 508 /*
3aad8c04429779 Heiko Carstens 2023-10-12 509 * Bit 61 indicates if the address is valid, if it is not the
3aad8c04429779 Heiko Carstens 2023-10-12 510 * kernel should be stopped or SIGSEGV should be sent to the
3aad8c04429779 Heiko Carstens 2023-10-12 511 * process. Bit 61 is not reliable without the misc UV feature,
3aad8c04429779 Heiko Carstens 2023-10-12 512 * therefore this needs to be checked too.
85b18d7b5e7ffe Janosch Frank 2021-01-12 513 */
5be05c35e72f74 Heiko Carstens 2023-10-12 514 if (uv_has_feature(BIT_UV_FEAT_MISC) && !teid.b61) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 515 /*
85b18d7b5e7ffe Janosch Frank 2021-01-12 516 * When this happens, userspace did something that it
85b18d7b5e7ffe Janosch Frank 2021-01-12 517 * was not supposed to do, e.g. branching into secure
85b18d7b5e7ffe Janosch Frank 2021-01-12 518 * memory. Trigger a segmentation fault.
85b18d7b5e7ffe Janosch Frank 2021-01-12 519 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 520 if (user_mode(regs)) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 521 send_sig(SIGSEGV, current, 0);
85b18d7b5e7ffe Janosch Frank 2021-01-12 522 return;
85b18d7b5e7ffe Janosch Frank 2021-01-12 523 }
85b18d7b5e7ffe Janosch Frank 2021-01-12 524 /*
3aad8c04429779 Heiko Carstens 2023-10-12 525 * The kernel should never run into this case and
3aad8c04429779 Heiko Carstens 2023-10-12 526 * there is no way out of this situation.
85b18d7b5e7ffe Janosch Frank 2021-01-12 527 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 528 panic("Unexpected PGM 0x3d with TEID bit 61=0");
85b18d7b5e7ffe Janosch Frank 2021-01-12 529 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 530 switch (get_fault_type(regs)) {
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 531 case GMAP_FAULT:
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 532 mm = current->mm;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 533 gmap = (struct gmap *)S390_lowcore.gmap;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 534 mmap_read_lock(mm);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 535 addr = __gmap_translate(gmap, addr);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 536 mmap_read_unlock(mm);
7c194d84a9ce66 Heiko Carstens 2023-10-12 537 if (IS_ERR_VALUE(addr))
7c194d84a9ce66 Heiko Carstens 2023-10-12 538 return handle_fault_error_nolock(regs, SEGV_MAPERR);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 539 fallthrough;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 540 case USER_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 541 mm = current->mm;
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 542 mmap_read_lock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 543 vma = find_vma(mm, addr);
7c194d84a9ce66 Heiko Carstens 2023-10-12 544 if (!vma)
7c194d84a9ce66 Heiko Carstens 2023-10-12 545 return handle_fault_error(regs, SEGV_MAPERR);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 546 page = follow_page(vma, addr, FOLL_WRITE | FOLL_GET);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 547 if (IS_ERR_OR_NULL(page)) {
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 548 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 549 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 550 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 551 if (arch_make_page_accessible(page))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 552 send_sig(SIGSEGV, current, 0);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 553 put_page(page);
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 554 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 555 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 556 case KERNEL_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 557 page = phys_to_page(addr);
cd1adf1b63a112 Linus Torvalds 2021-09-07 558 if (unlikely(!try_get_page(page)))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 559 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 560 rc = arch_make_page_accessible(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 561 put_page(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 562 if (rc)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 563 BUG();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 564 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 565 default:
ae626f686351d2 Heiko Carstens 2023-10-12 @566 unreachable();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 567 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 568 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 569 NOKPROBE_SYMBOL(do_secure_storage_access);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 570
:::::: The code at line 566 was first introduced by commit
:::::: ae626f686351d220d5eab746dc3a19e90bb1de9a s390/mm,fault: replace WARN_ON_ONCE() with unreachable()
:::::: TO: Heiko Carstens <hca@linux.ibm.com>
:::::: CC: Vasily Gorbik <gor@linux.ibm.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
@ 2024-09-24 6:41 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-09-24 6:41 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Heiko Carstens <hca@linux.ibm.com>
CC: Vasily Gorbik <gor@linux.ibm.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: abf2050f51fdca0fd146388f83cddd95a57a008d
commit: 7c194d84a9ce662426b2ecb59da54bb80c6b1d91 s390/mm,fault: remove VM_FAULT_BADMAP and VM_FAULT_BADACCESS
date: 11 months ago
:::::: branch date: 8 hours ago
:::::: commit date: 11 months ago
config: s390-randconfig-r071-20240922 (https://download.01.org/0day-ci/archive/20240924/202409241449.CmMqcFbJ-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.1.0
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/202409241449.CmMqcFbJ-lkp@intel.com/
smatch warnings:
arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
vim +566 arch/s390/mm/fault.c
17a363dcd2f745 Heiko Carstens 2021-04-09 497
084ea4d611a3d0 Vasily Gorbik 2020-01-21 498 void do_secure_storage_access(struct pt_regs *regs)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 499 {
5be05c35e72f74 Heiko Carstens 2023-10-12 500 union teid teid = { .val = regs->int_parm_long };
9641613f48bbf8 Heiko Carstens 2023-10-12 501 unsigned long addr = get_fault_address(regs);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 502 struct vm_area_struct *vma;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 503 struct mm_struct *mm;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 504 struct page *page;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 505 struct gmap *gmap;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 506 int rc;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 507
85b18d7b5e7ffe Janosch Frank 2021-01-12 508 /*
3aad8c04429779 Heiko Carstens 2023-10-12 509 * Bit 61 indicates if the address is valid, if it is not the
3aad8c04429779 Heiko Carstens 2023-10-12 510 * kernel should be stopped or SIGSEGV should be sent to the
3aad8c04429779 Heiko Carstens 2023-10-12 511 * process. Bit 61 is not reliable without the misc UV feature,
3aad8c04429779 Heiko Carstens 2023-10-12 512 * therefore this needs to be checked too.
85b18d7b5e7ffe Janosch Frank 2021-01-12 513 */
5be05c35e72f74 Heiko Carstens 2023-10-12 514 if (uv_has_feature(BIT_UV_FEAT_MISC) && !teid.b61) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 515 /*
85b18d7b5e7ffe Janosch Frank 2021-01-12 516 * When this happens, userspace did something that it
85b18d7b5e7ffe Janosch Frank 2021-01-12 517 * was not supposed to do, e.g. branching into secure
85b18d7b5e7ffe Janosch Frank 2021-01-12 518 * memory. Trigger a segmentation fault.
85b18d7b5e7ffe Janosch Frank 2021-01-12 519 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 520 if (user_mode(regs)) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 521 send_sig(SIGSEGV, current, 0);
85b18d7b5e7ffe Janosch Frank 2021-01-12 522 return;
85b18d7b5e7ffe Janosch Frank 2021-01-12 523 }
85b18d7b5e7ffe Janosch Frank 2021-01-12 524 /*
3aad8c04429779 Heiko Carstens 2023-10-12 525 * The kernel should never run into this case and
3aad8c04429779 Heiko Carstens 2023-10-12 526 * there is no way out of this situation.
85b18d7b5e7ffe Janosch Frank 2021-01-12 527 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 528 panic("Unexpected PGM 0x3d with TEID bit 61=0");
85b18d7b5e7ffe Janosch Frank 2021-01-12 529 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 530 switch (get_fault_type(regs)) {
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 531 case GMAP_FAULT:
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 532 mm = current->mm;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 533 gmap = (struct gmap *)S390_lowcore.gmap;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 534 mmap_read_lock(mm);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 535 addr = __gmap_translate(gmap, addr);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 536 mmap_read_unlock(mm);
7c194d84a9ce66 Heiko Carstens 2023-10-12 537 if (IS_ERR_VALUE(addr))
7c194d84a9ce66 Heiko Carstens 2023-10-12 538 return handle_fault_error_nolock(regs, SEGV_MAPERR);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 539 fallthrough;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 540 case USER_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 541 mm = current->mm;
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 542 mmap_read_lock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 543 vma = find_vma(mm, addr);
7c194d84a9ce66 Heiko Carstens 2023-10-12 544 if (!vma)
7c194d84a9ce66 Heiko Carstens 2023-10-12 545 return handle_fault_error(regs, SEGV_MAPERR);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 546 page = follow_page(vma, addr, FOLL_WRITE | FOLL_GET);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 547 if (IS_ERR_OR_NULL(page)) {
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 548 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 549 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 550 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 551 if (arch_make_page_accessible(page))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 552 send_sig(SIGSEGV, current, 0);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 553 put_page(page);
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 554 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 555 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 556 case KERNEL_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 557 page = phys_to_page(addr);
cd1adf1b63a112 Linus Torvalds 2021-09-07 558 if (unlikely(!try_get_page(page)))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 559 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 560 rc = arch_make_page_accessible(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 561 put_page(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 562 if (rc)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 563 BUG();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 564 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 565 default:
ae626f686351d2 Heiko Carstens 2023-10-12 @566 unreachable();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 567 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 568 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 569 NOKPROBE_SYMBOL(do_secure_storage_access);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 570
:::::: The code at line 566 was first introduced by commit
:::::: ae626f686351d220d5eab746dc3a19e90bb1de9a s390/mm,fault: replace WARN_ON_ONCE() with unreachable()
:::::: TO: Heiko Carstens <hca@linux.ibm.com>
:::::: CC: Vasily Gorbik <gor@linux.ibm.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
@ 2024-09-23 12:22 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-09-23 12:22 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Heiko Carstens <hca@linux.ibm.com>
CC: Vasily Gorbik <gor@linux.ibm.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: de5cb0dcb74c294ec527eddfe5094acfdb21ff21
commit: 7c194d84a9ce662426b2ecb59da54bb80c6b1d91 s390/mm,fault: remove VM_FAULT_BADMAP and VM_FAULT_BADACCESS
date: 11 months ago
:::::: branch date: 18 hours ago
:::::: commit date: 11 months ago
config: s390-randconfig-r071-20240922 (https://download.01.org/0day-ci/archive/20240923/202409232033.d1FlFrD1-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.1.0
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/202409232033.d1FlFrD1-lkp@intel.com/
smatch warnings:
arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
vim +566 arch/s390/mm/fault.c
17a363dcd2f745 Heiko Carstens 2021-04-09 497
084ea4d611a3d0 Vasily Gorbik 2020-01-21 498 void do_secure_storage_access(struct pt_regs *regs)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 499 {
5be05c35e72f74 Heiko Carstens 2023-10-12 500 union teid teid = { .val = regs->int_parm_long };
9641613f48bbf8 Heiko Carstens 2023-10-12 501 unsigned long addr = get_fault_address(regs);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 502 struct vm_area_struct *vma;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 503 struct mm_struct *mm;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 504 struct page *page;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 505 struct gmap *gmap;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 506 int rc;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 507
85b18d7b5e7ffe Janosch Frank 2021-01-12 508 /*
3aad8c04429779 Heiko Carstens 2023-10-12 509 * Bit 61 indicates if the address is valid, if it is not the
3aad8c04429779 Heiko Carstens 2023-10-12 510 * kernel should be stopped or SIGSEGV should be sent to the
3aad8c04429779 Heiko Carstens 2023-10-12 511 * process. Bit 61 is not reliable without the misc UV feature,
3aad8c04429779 Heiko Carstens 2023-10-12 512 * therefore this needs to be checked too.
85b18d7b5e7ffe Janosch Frank 2021-01-12 513 */
5be05c35e72f74 Heiko Carstens 2023-10-12 514 if (uv_has_feature(BIT_UV_FEAT_MISC) && !teid.b61) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 515 /*
85b18d7b5e7ffe Janosch Frank 2021-01-12 516 * When this happens, userspace did something that it
85b18d7b5e7ffe Janosch Frank 2021-01-12 517 * was not supposed to do, e.g. branching into secure
85b18d7b5e7ffe Janosch Frank 2021-01-12 518 * memory. Trigger a segmentation fault.
85b18d7b5e7ffe Janosch Frank 2021-01-12 519 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 520 if (user_mode(regs)) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 521 send_sig(SIGSEGV, current, 0);
85b18d7b5e7ffe Janosch Frank 2021-01-12 522 return;
85b18d7b5e7ffe Janosch Frank 2021-01-12 523 }
85b18d7b5e7ffe Janosch Frank 2021-01-12 524 /*
3aad8c04429779 Heiko Carstens 2023-10-12 525 * The kernel should never run into this case and
3aad8c04429779 Heiko Carstens 2023-10-12 526 * there is no way out of this situation.
85b18d7b5e7ffe Janosch Frank 2021-01-12 527 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 528 panic("Unexpected PGM 0x3d with TEID bit 61=0");
85b18d7b5e7ffe Janosch Frank 2021-01-12 529 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 530 switch (get_fault_type(regs)) {
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 531 case GMAP_FAULT:
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 532 mm = current->mm;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 533 gmap = (struct gmap *)S390_lowcore.gmap;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 534 mmap_read_lock(mm);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 535 addr = __gmap_translate(gmap, addr);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 536 mmap_read_unlock(mm);
7c194d84a9ce66 Heiko Carstens 2023-10-12 537 if (IS_ERR_VALUE(addr))
7c194d84a9ce66 Heiko Carstens 2023-10-12 538 return handle_fault_error_nolock(regs, SEGV_MAPERR);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 539 fallthrough;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 540 case USER_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 541 mm = current->mm;
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 542 mmap_read_lock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 543 vma = find_vma(mm, addr);
7c194d84a9ce66 Heiko Carstens 2023-10-12 544 if (!vma)
7c194d84a9ce66 Heiko Carstens 2023-10-12 545 return handle_fault_error(regs, SEGV_MAPERR);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 546 page = follow_page(vma, addr, FOLL_WRITE | FOLL_GET);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 547 if (IS_ERR_OR_NULL(page)) {
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 548 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 549 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 550 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 551 if (arch_make_page_accessible(page))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 552 send_sig(SIGSEGV, current, 0);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 553 put_page(page);
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 554 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 555 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 556 case KERNEL_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 557 page = phys_to_page(addr);
cd1adf1b63a112 Linus Torvalds 2021-09-07 558 if (unlikely(!try_get_page(page)))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 559 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 560 rc = arch_make_page_accessible(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 561 put_page(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 562 if (rc)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 563 BUG();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 564 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 565 default:
ae626f686351d2 Heiko Carstens 2023-10-12 @566 unreachable();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 567 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 568 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 569 NOKPROBE_SYMBOL(do_secure_storage_access);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 570
:::::: The code at line 566 was first introduced by commit
:::::: ae626f686351d220d5eab746dc3a19e90bb1de9a s390/mm,fault: replace WARN_ON_ONCE() with unreachable()
:::::: TO: Heiko Carstens <hca@linux.ibm.com>
:::::: CC: Vasily Gorbik <gor@linux.ibm.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread* arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
@ 2024-09-22 22:01 kernel test robot
0 siblings, 0 replies; 7+ messages in thread
From: kernel test robot @ 2024-09-22 22:01 UTC (permalink / raw)
To: oe-kbuild; +Cc: lkp, Dan Carpenter
BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Heiko Carstens <hca@linux.ibm.com>
CC: Vasily Gorbik <gor@linux.ibm.com>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: de5cb0dcb74c294ec527eddfe5094acfdb21ff21
commit: 7c194d84a9ce662426b2ecb59da54bb80c6b1d91 s390/mm,fault: remove VM_FAULT_BADMAP and VM_FAULT_BADACCESS
date: 11 months ago
:::::: branch date: 4 hours ago
:::::: commit date: 11 months ago
config: s390-randconfig-r071-20240922 (https://download.01.org/0day-ci/archive/20240923/202409230503.HMpRcK5s-lkp@intel.com/config)
compiler: s390-linux-gcc (GCC) 14.1.0
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/202409230503.HMpRcK5s-lkp@intel.com/
smatch warnings:
arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock'.
vim +566 arch/s390/mm/fault.c
17a363dcd2f745 Heiko Carstens 2021-04-09 497
084ea4d611a3d0 Vasily Gorbik 2020-01-21 498 void do_secure_storage_access(struct pt_regs *regs)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 499 {
5be05c35e72f74 Heiko Carstens 2023-10-12 500 union teid teid = { .val = regs->int_parm_long };
9641613f48bbf8 Heiko Carstens 2023-10-12 501 unsigned long addr = get_fault_address(regs);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 502 struct vm_area_struct *vma;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 503 struct mm_struct *mm;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 504 struct page *page;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 505 struct gmap *gmap;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 506 int rc;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 507
85b18d7b5e7ffe Janosch Frank 2021-01-12 508 /*
3aad8c04429779 Heiko Carstens 2023-10-12 509 * Bit 61 indicates if the address is valid, if it is not the
3aad8c04429779 Heiko Carstens 2023-10-12 510 * kernel should be stopped or SIGSEGV should be sent to the
3aad8c04429779 Heiko Carstens 2023-10-12 511 * process. Bit 61 is not reliable without the misc UV feature,
3aad8c04429779 Heiko Carstens 2023-10-12 512 * therefore this needs to be checked too.
85b18d7b5e7ffe Janosch Frank 2021-01-12 513 */
5be05c35e72f74 Heiko Carstens 2023-10-12 514 if (uv_has_feature(BIT_UV_FEAT_MISC) && !teid.b61) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 515 /*
85b18d7b5e7ffe Janosch Frank 2021-01-12 516 * When this happens, userspace did something that it
85b18d7b5e7ffe Janosch Frank 2021-01-12 517 * was not supposed to do, e.g. branching into secure
85b18d7b5e7ffe Janosch Frank 2021-01-12 518 * memory. Trigger a segmentation fault.
85b18d7b5e7ffe Janosch Frank 2021-01-12 519 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 520 if (user_mode(regs)) {
85b18d7b5e7ffe Janosch Frank 2021-01-12 521 send_sig(SIGSEGV, current, 0);
85b18d7b5e7ffe Janosch Frank 2021-01-12 522 return;
85b18d7b5e7ffe Janosch Frank 2021-01-12 523 }
85b18d7b5e7ffe Janosch Frank 2021-01-12 524 /*
3aad8c04429779 Heiko Carstens 2023-10-12 525 * The kernel should never run into this case and
3aad8c04429779 Heiko Carstens 2023-10-12 526 * there is no way out of this situation.
85b18d7b5e7ffe Janosch Frank 2021-01-12 527 */
85b18d7b5e7ffe Janosch Frank 2021-01-12 528 panic("Unexpected PGM 0x3d with TEID bit 61=0");
85b18d7b5e7ffe Janosch Frank 2021-01-12 529 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 530 switch (get_fault_type(regs)) {
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 531 case GMAP_FAULT:
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 532 mm = current->mm;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 533 gmap = (struct gmap *)S390_lowcore.gmap;
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 534 mmap_read_lock(mm);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 535 addr = __gmap_translate(gmap, addr);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 536 mmap_read_unlock(mm);
7c194d84a9ce66 Heiko Carstens 2023-10-12 537 if (IS_ERR_VALUE(addr))
7c194d84a9ce66 Heiko Carstens 2023-10-12 538 return handle_fault_error_nolock(regs, SEGV_MAPERR);
b108f7f0a29b24 Claudio Imbrenda 2022-06-28 539 fallthrough;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 540 case USER_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 541 mm = current->mm;
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 542 mmap_read_lock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 543 vma = find_vma(mm, addr);
7c194d84a9ce66 Heiko Carstens 2023-10-12 544 if (!vma)
7c194d84a9ce66 Heiko Carstens 2023-10-12 545 return handle_fault_error(regs, SEGV_MAPERR);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 546 page = follow_page(vma, addr, FOLL_WRITE | FOLL_GET);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 547 if (IS_ERR_OR_NULL(page)) {
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 548 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 549 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 550 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 551 if (arch_make_page_accessible(page))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 552 send_sig(SIGSEGV, current, 0);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 553 put_page(page);
d8ed45c5dcd455 Michel Lespinasse 2020-06-08 554 mmap_read_unlock(mm);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 555 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 556 case KERNEL_FAULT:
084ea4d611a3d0 Vasily Gorbik 2020-01-21 557 page = phys_to_page(addr);
cd1adf1b63a112 Linus Torvalds 2021-09-07 558 if (unlikely(!try_get_page(page)))
084ea4d611a3d0 Vasily Gorbik 2020-01-21 559 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 560 rc = arch_make_page_accessible(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 561 put_page(page);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 562 if (rc)
084ea4d611a3d0 Vasily Gorbik 2020-01-21 563 BUG();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 564 break;
084ea4d611a3d0 Vasily Gorbik 2020-01-21 565 default:
ae626f686351d2 Heiko Carstens 2023-10-12 @566 unreachable();
084ea4d611a3d0 Vasily Gorbik 2020-01-21 567 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 568 }
084ea4d611a3d0 Vasily Gorbik 2020-01-21 569 NOKPROBE_SYMBOL(do_secure_storage_access);
084ea4d611a3d0 Vasily Gorbik 2020-01-21 570
:::::: The code at line 566 was first introduced by commit
:::::: ae626f686351d220d5eab746dc3a19e90bb1de9a s390/mm,fault: replace WARN_ON_ONCE() with unreachable()
:::::: TO: Heiko Carstens <hca@linux.ibm.com>
:::::: CC: Vasily Gorbik <gor@linux.ibm.com>
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2024-10-26 15:31 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-26 15:30 arch/s390/mm/fault.c:566 do_secure_storage_access() warn: inconsistent returns '&mm->mmap_lock' kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2024-10-25 7:35 Dan Carpenter
2024-10-25 10:05 ` Heiko Carstens
2024-10-24 21:57 kernel test robot
2024-09-24 6:41 kernel test robot
2024-09-23 12:22 kernel test robot
2024-09-22 22:01 kernel test robot
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.