From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EC3FE1CAAD for ; Sat, 11 May 2024 21:49:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715464156; cv=none; b=t4KHTRNByMPv0oMZU8d50NS+SIJisR11WJYBQZI5OUma/1XkIgV1DACVh4h8M2F/Xv9sevJ3ZAe/uoihAFvyAcz6MYbRIpgAKNZUGbY+bQircFkoobMjWz23K47cbEvdjYyOEdpBLGplLoqI/2F7T/HdcL0O/O6arU80h+WUA74= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715464156; c=relaxed/simple; bh=4y28shCKA6c0cta2kdMjr4CPeRVzLLhOMPYoszlFzP0=; h=Date:To:From:Subject:Message-Id; b=CLynvcMGEMXqnkCqQwTdebWSpUrMty6yM/r7dGz2CJoby09lTAbZ/i5Dugxx9qrX73Adc72BTxRQTxtiXmDRyOMl4/K+5T8/nTQc8N9d9hfBOuqPO/175VmdbyaxAHLplwn4f8m4NsFBtpj0TiTyvbqtfxHSlSImHx4lDfkSSXE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b=KTzc2qtT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.b="KTzc2qtT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79A5AC32781; Sat, 11 May 2024 21:49:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1715464155; bh=4y28shCKA6c0cta2kdMjr4CPeRVzLLhOMPYoszlFzP0=; h=Date:To:From:Subject:From; b=KTzc2qtTVeDpNp/VG0gw3S6KXVjSkXgj4f41JzilNH5Y+vNNxVlujEcL1IZ1sMS2D t4T1+PNKftN7DjrQ24nBuHOndlP1QsEnOzUyaP5zgsoBXQsJWrWUJdLpFcrw7V4BP4 KhcOcEFvPphvuKfM4C8qdLPQLDcsqgNVbVlidWkc= Date: Sat, 11 May 2024 14:49:14 -0700 To: mm-commits@vger.kernel.org,willy@infradead.org,usama.anjum@collabora.com,torvalds@linux-foundation.org,surenb@google.com,sroettger@google.com,shuah@kernel.org,pedro.falcato@gmail.com,Liam.Howlett@oracle.com,keescook@chromium.org,jorgelo@chromium.org,jeffxu@google.com,javier.carrasco.cruz@gmail.com,jannh@google.com,groeck@chromium.org,gregkh@linuxfoundation.org,dave.hansen@intel.com,corbet@lwn.net,amer.shanawany@gmail.com,jeffxu@chromium.org,akpm@linux-foundation.org From: Andrew Morton Subject: [folded-merged] mseal-add-mseal-syscall-fix.patch removed from -mm tree Message-Id: <20240511214915.79A5AC32781@smtp.kernel.org> Precedence: bulk X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: The quilt patch titled Subject: mseal: add branch prediction hint has been removed from the -mm tree. Its filename was mseal-add-mseal-syscall-fix.patch This patch was dropped because it was folded into mseal-add-mseal-syscall.patch ------------------------------------------------------ From: Jeff Xu Subject: mseal: add branch prediction hint Date: Tue, 23 Apr 2024 19:28:25 +0000 It is unlikely that application calls mm syscall, such as mprotect, on already sealed mappings, adding branch prediction hint. Link: https://lkml.kernel.org/r/20240423192825.1273679-2-jeffxu@chromium.org Signed-off-by: Jeff Xu Suggested-by: Pedro Falcato Cc: Amer Al Shanawany Cc: Dave Hansen Cc: Greg Kroah-Hartman Cc: Guenter Roeck Cc: Jann Horn Cc: Javier Carrasco Cc: Jeff Xu Cc: Jonathan Corbet Cc: Jorge Lucangeli Obes Cc: Kees Cook Cc: Liam R. Howlett Cc: Linus Torvalds Cc: Matthew Wilcox (Oracle) Cc: Muhammad Usama Anjum Cc: Shuah Khan Cc: Stephen Röttger Cc: Suren Baghdasaryan Signed-off-by: Andrew Morton --- mm/madvise.c | 2 +- mm/mmap.c | 4 ++-- mm/mprotect.c | 2 +- mm/mremap.c | 4 ++-- mm/mseal.c | 6 +++--- 5 files changed, 9 insertions(+), 9 deletions(-) --- a/mm/madvise.c~mseal-add-mseal-syscall-fix +++ a/mm/madvise.c @@ -1449,7 +1449,7 @@ int do_madvise(struct mm_struct *mm, uns * Check if the address range is sealed for do_madvise(). * can_modify_mm_madv assumes we have acquired the lock on MM. */ - if (!can_modify_mm_madv(mm, start, end, behavior)) { + if (unlikely(!can_modify_mm_madv(mm, start, end, behavior))) { error = -EPERM; goto out; } --- a/mm/mmap.c~mseal-add-mseal-syscall-fix +++ a/mm/mmap.c @@ -2740,7 +2740,7 @@ int do_vmi_munmap(struct vma_iterator *v * Prevent unmapping a sealed VMA. * can_modify_mm assumes we have acquired the lock on MM. */ - if (!can_modify_mm(mm, start, end)) + if (unlikely(!can_modify_mm(mm, start, end))) return -EPERM; /* arch_unmap() might do unmaps itself. */ @@ -3163,7 +3163,7 @@ int do_vma_munmap(struct vma_iterator *v * Prevent unmapping a sealed VMA. * can_modify_mm assumes we have acquired the lock on MM. */ - if (!can_modify_mm(mm, start, end)) + if (unlikely(!can_modify_mm(mm, start, end))) return -EPERM; arch_unmap(mm, start, end); --- a/mm/mprotect.c~mseal-add-mseal-syscall-fix +++ a/mm/mprotect.c @@ -749,7 +749,7 @@ static int do_mprotect_pkey(unsigned lon * checking if memory is sealed. * can_modify_mm assumes we have acquired the lock on MM. */ - if (!can_modify_mm(current->mm, start, end)) { + if (unlikely(!can_modify_mm(current->mm, start, end))) { error = -EPERM; goto out; } --- a/mm/mremap.c~mseal-add-mseal-syscall-fix +++ a/mm/mremap.c @@ -912,7 +912,7 @@ static unsigned long mremap_to(unsigned * * can_modify_mm assumes we have acquired the lock on MM. */ - if (!can_modify_mm(mm, addr, addr + old_len)) + if (unlikely(!can_modify_mm(mm, addr, addr + old_len))) return -EPERM; if (flags & MREMAP_FIXED) { @@ -1087,7 +1087,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, a * Place can_modify_mm here so we can keep the logic related to * shrink/expand together. */ - if (!can_modify_mm(mm, addr, addr + old_len)) { + if (unlikely(!can_modify_mm(mm, addr, addr + old_len))) { ret = -EPERM; goto out; } --- a/mm/mseal.c~mseal-add-mseal-syscall-fix +++ a/mm/mseal.c @@ -32,7 +32,7 @@ static inline void set_vma_sealed(struct */ static bool can_modify_vma(struct vm_area_struct *vma) { - if (vma_is_sealed(vma)) + if (unlikely(vma_is_sealed(vma))) return false; return true; @@ -75,7 +75,7 @@ bool can_modify_mm(struct mm_struct *mm, /* going through each vma to check. */ for_each_vma_range(vmi, vma, end) { - if (!can_modify_vma(vma)) + if (unlikely(!can_modify_vma(vma))) return false; } @@ -100,7 +100,7 @@ bool can_modify_mm_madv(struct mm_struct /* going through each vma to check. */ for_each_vma_range(vmi, vma, end) - if (is_ro_anon(vma) && !can_modify_vma(vma)) + if (unlikely(is_ro_anon(vma) && !can_modify_vma(vma))) return false; /* Allow by default. */ _ Patches currently in -mm which might be from jeffxu@chromium.org are mseal-wire-up-mseal-syscall.patch mseal-add-mseal-syscall.patch selftest-mm-mseal-memory-sealing.patch mseal-add-documentation.patch selftest-mm-mseal-read-only-elf-memory-segment.patch selftest-mm-mseal-read-only-elf-memory-segment-fix.patch selftest-mm-mseal-read-only-elf-memory-segment-fix-3.patch selftest-mm-mseal-read-only-elf-memory-segment-fix-4.patch