From: kernel test robot <lkp@intel.com>
To: jeffxu@chromium.org, akpm@linux-foundation.org,
keescook@chromium.org, torvalds@linux-foundation.org,
usama.anjum@collabora.com, corbet@lwn.net,
Liam.Howlett@oracle.com, lorenzo.stoakes@oracle.com
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev,
jeffxu@google.com, jorgelo@chromium.org, groeck@chromium.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-mm@kvack.org, jannh@google.com, sroettger@google.com,
pedro.falcato@gmail.com, linux-hardening@vger.kernel.org,
willy@infradead.org, gregkh@linuxfoundation.org,
deraadt@openbsd.org, surenb@google.com, merimus@google.com,
rdunlap@infradead.org, Jeff Xu <jeffxu@chromium.org>,
stable@vger.kernel.org
Subject: Re: [PATCH v1 1/2] mseal: Two fixes for madvise(MADV_DONTNEED) when sealed
Date: Sun, 20 Oct 2024 17:20:40 +0800 [thread overview]
Message-ID: <202410201724.kKCsANsw-lkp@intel.com> (raw)
In-Reply-To: <20241017005105.3047458-2-jeffxu@chromium.org>
Hi,
kernel test robot noticed the following build errors:
[auto build test ERROR on akpm-mm/mm-everything]
[also build test ERROR on linus/master v6.12-rc3 next-20241018]
[cannot apply to kees/for-next/pstore kees/for-next/kspp linux/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/jeffxu-chromium-org/mseal-Two-fixes-for-madvise-MADV_DONTNEED-when-sealed/20241017-085203
base: https://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm.git mm-everything
patch link: https://lore.kernel.org/r/20241017005105.3047458-2-jeffxu%40chromium.org
patch subject: [PATCH v1 1/2] mseal: Two fixes for madvise(MADV_DONTNEED) when sealed
config: i386-defconfig (https://download.01.org/0day-ci/archive/20241020/202410201724.kKCsANsw-lkp@intel.com/config)
compiler: clang version 18.1.8 (https://github.com/llvm/llvm-project 3b5b5c1ec4a3095ab096dd780e84d7ab81f3d7ff)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241020/202410201724.kKCsANsw-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/202410201724.kKCsANsw-lkp@intel.com/
All errors (new ones prefixed by >>):
>> mm/mprotect.c:825:16: error: use of undeclared identifier 'VM_WASWRITE'
825 | newflags |= VM_WASWRITE;
| ^
1 error generated.
vim +/VM_WASWRITE +825 mm/mprotect.c
705
706 /*
707 * pkey==-1 when doing a legacy mprotect()
708 */
709 static int do_mprotect_pkey(unsigned long start, size_t len,
710 unsigned long prot, int pkey)
711 {
712 unsigned long nstart, end, tmp, reqprot;
713 struct vm_area_struct *vma, *prev;
714 int error;
715 const int grows = prot & (PROT_GROWSDOWN|PROT_GROWSUP);
716 const bool rier = (current->personality & READ_IMPLIES_EXEC) &&
717 (prot & PROT_READ);
718 struct mmu_gather tlb;
719 struct vma_iterator vmi;
720
721 start = untagged_addr(start);
722
723 prot &= ~(PROT_GROWSDOWN|PROT_GROWSUP);
724 if (grows == (PROT_GROWSDOWN|PROT_GROWSUP)) /* can't be both */
725 return -EINVAL;
726
727 if (start & ~PAGE_MASK)
728 return -EINVAL;
729 if (!len)
730 return 0;
731 len = PAGE_ALIGN(len);
732 end = start + len;
733 if (end <= start)
734 return -ENOMEM;
735 if (!arch_validate_prot(prot, start))
736 return -EINVAL;
737
738 reqprot = prot;
739
740 if (mmap_write_lock_killable(current->mm))
741 return -EINTR;
742
743 /*
744 * If userspace did not allocate the pkey, do not let
745 * them use it here.
746 */
747 error = -EINVAL;
748 if ((pkey != -1) && !mm_pkey_is_allocated(current->mm, pkey))
749 goto out;
750
751 vma_iter_init(&vmi, current->mm, start);
752 vma = vma_find(&vmi, end);
753 error = -ENOMEM;
754 if (!vma)
755 goto out;
756
757 if (unlikely(grows & PROT_GROWSDOWN)) {
758 if (vma->vm_start >= end)
759 goto out;
760 start = vma->vm_start;
761 error = -EINVAL;
762 if (!(vma->vm_flags & VM_GROWSDOWN))
763 goto out;
764 } else {
765 if (vma->vm_start > start)
766 goto out;
767 if (unlikely(grows & PROT_GROWSUP)) {
768 end = vma->vm_end;
769 error = -EINVAL;
770 if (!(vma->vm_flags & VM_GROWSUP))
771 goto out;
772 }
773 }
774
775 prev = vma_prev(&vmi);
776 if (start > vma->vm_start)
777 prev = vma;
778
779 tlb_gather_mmu(&tlb, current->mm);
780 nstart = start;
781 tmp = vma->vm_start;
782 for_each_vma_range(vmi, vma, end) {
783 unsigned long mask_off_old_flags;
784 unsigned long newflags;
785 int new_vma_pkey;
786
787 if (vma->vm_start != tmp) {
788 error = -ENOMEM;
789 break;
790 }
791
792 /* Does the application expect PROT_READ to imply PROT_EXEC */
793 if (rier && (vma->vm_flags & VM_MAYEXEC))
794 prot |= PROT_EXEC;
795
796 /*
797 * Each mprotect() call explicitly passes r/w/x permissions.
798 * If a permission is not passed to mprotect(), it must be
799 * cleared from the VMA.
800 */
801 mask_off_old_flags = VM_ACCESS_FLAGS | VM_FLAGS_CLEAR;
802
803 new_vma_pkey = arch_override_mprotect_pkey(vma, prot, pkey);
804 newflags = calc_vm_prot_bits(prot, new_vma_pkey);
805 newflags |= (vma->vm_flags & ~mask_off_old_flags);
806
807 /* newflags >> 4 shift VM_MAY% in place of VM_% */
808 if ((newflags & ~(newflags >> 4)) & VM_ACCESS_FLAGS) {
809 error = -EACCES;
810 break;
811 }
812
813 if (map_deny_write_exec(vma, newflags)) {
814 error = -EACCES;
815 break;
816 }
817
818 /* Allow architectures to sanity-check the new flags */
819 if (!arch_validate_flags(newflags)) {
820 error = -EINVAL;
821 break;
822 }
823
824 if ((vma->vm_flags & VM_WRITE) && !(newflags & VM_WRITE))
> 825 newflags |= VM_WASWRITE;
826
827 error = security_file_mprotect(vma, reqprot, prot);
828 if (error)
829 break;
830
831 tmp = vma->vm_end;
832 if (tmp > end)
833 tmp = end;
834
835 if (vma->vm_ops && vma->vm_ops->mprotect) {
836 error = vma->vm_ops->mprotect(vma, nstart, tmp, newflags);
837 if (error)
838 break;
839 }
840
841 error = mprotect_fixup(&vmi, &tlb, vma, &prev, nstart, tmp, newflags);
842 if (error)
843 break;
844
845 tmp = vma_iter_end(&vmi);
846 nstart = tmp;
847 prot = reqprot;
848 }
849 tlb_finish_mmu(&tlb);
850
851 if (!error && tmp < end)
852 error = -ENOMEM;
853
854 out:
855 mmap_write_unlock(current->mm);
856 return error;
857 }
858
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next prev parent reply other threads:[~2024-10-20 9:21 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-17 0:51 [PATCH v1 0/2] mseal: fixing madvise for file-backed mapping and PROT_NONE jeffxu
2024-10-17 0:51 ` [PATCH v1 1/2] mseal: Two fixes for madvise(MADV_DONTNEED) when sealed jeffxu
2024-10-17 8:32 ` Lorenzo Stoakes
2024-10-17 19:37 ` Pedro Falcato
2024-10-17 20:34 ` Jeff Xu
2024-10-17 20:49 ` Pedro Falcato
2024-10-17 20:57 ` Jeff Xu
2024-10-22 15:55 ` Vlastimil Babka
2024-10-22 22:54 ` Theo de Raadt
2024-10-23 18:33 ` Jeff Xu
2024-10-20 9:20 ` kernel test robot
2024-10-20 9:20 ` kernel test robot [this message]
2024-10-17 0:51 ` [PATCH v1 2/2] selftest/mseal: Add tests for madvise fixes jeffxu
2024-10-17 8:35 ` Lorenzo Stoakes
2024-10-17 8:38 ` [PATCH v1 0/2] mseal: fixing madvise for file-backed mapping and PROT_NONE Lorenzo Stoakes
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=202410201724.kKCsANsw-lkp@intel.com \
--to=lkp@intel.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=corbet@lwn.net \
--cc=deraadt@openbsd.org \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=jannh@google.com \
--cc=jeffxu@chromium.org \
--cc=jeffxu@google.com \
--cc=jorgelo@chromium.org \
--cc=keescook@chromium.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=llvm@lists.linux.dev \
--cc=lorenzo.stoakes@oracle.com \
--cc=merimus@google.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=pedro.falcato@gmail.com \
--cc=rdunlap@infradead.org \
--cc=sroettger@google.com \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=torvalds@linux-foundation.org \
--cc=usama.anjum@collabora.com \
--cc=willy@infradead.org \
/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