From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org, Muchun Song <songmuchun@bytedance.com>,
Axel Rasmussen <axelrasmussen@google.com>,
David Rientjes <rientjes@google.com>,
Fam Zheng <fam.zheng@bytedance.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Lars Persson <lars.persson@axis.com>,
Mike Kravetz <mike.kravetz@oracle.com>,
Peter Xu <peterx@redhat.com>,
Xiongchun Duan <duanxiongchun@bytedance.com>,
Zi Yan <ziy@nvidia.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: [PATCH 5.4 18/18] mm: userfaultfd: fix missing cache flush in mcopy_atomic_pte() and __mcopy_atomic()
Date: Fri, 13 May 2022 16:23:44 +0200 [thread overview]
Message-ID: <20220513142229.682741906@linuxfoundation.org> (raw)
In-Reply-To: <20220513142229.153291230@linuxfoundation.org>
From: Muchun Song <songmuchun@bytedance.com>
commit 7c25a0b89a487878b0691e6524fb5a8827322194 upstream.
userfaultfd calls mcopy_atomic_pte() and __mcopy_atomic() which do not
do any cache flushing for the target page. Then the target page will be
mapped to the user space with a different address (user address), which
might have an alias issue with the kernel address used to copy the data
from the user to. Fix this by insert flush_dcache_page() after
copy_from_user() succeeds.
Link: https://lkml.kernel.org/r/20220210123058.79206-7-songmuchun@bytedance.com
Fixes: b6ebaedb4cb1 ("userfaultfd: avoid mmap_sem read recursion in mcopy_atomic")
Fixes: c1a4de99fada ("userfaultfd: mcopy_atomic|mfill_zeropage: UFFDIO_COPY|UFFDIO_ZEROPAGE preparation")
Signed-off-by: Muchun Song <songmuchun@bytedance.com>
Cc: Axel Rasmussen <axelrasmussen@google.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Fam Zheng <fam.zheng@bytedance.com>
Cc: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Cc: Lars Persson <lars.persson@axis.com>
Cc: Mike Kravetz <mike.kravetz@oracle.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Xiongchun Duan <duanxiongchun@bytedance.com>
Cc: Zi Yan <ziy@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
mm/userfaultfd.c | 3 +++
1 file changed, 3 insertions(+)
--- a/mm/userfaultfd.c
+++ b/mm/userfaultfd.c
@@ -53,6 +53,8 @@ static int mcopy_atomic_pte(struct mm_st
/* don't free the page */
goto out;
}
+
+ flush_dcache_page(page);
} else {
page = *pagep;
*pagep = NULL;
@@ -572,6 +574,7 @@ retry:
err = -EFAULT;
goto out;
}
+ flush_dcache_page(page);
goto retry;
} else
BUG_ON(page);
next prev parent reply other threads:[~2022-05-13 14:27 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-13 14:23 [PATCH 5.4 00/18] 5.4.194-rc1 review Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 01/18] MIPS: Use address-of operator on section symbols Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 02/18] block: drbd: drbd_nl: Make conversion to enum drbd_ret_code explicit Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 03/18] drm/amd/display/dc/gpio/gpio_service: Pass around correct dce_{version, environment} types Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 04/18] drm/i915: Cast remain to unsigned long in eb_relocate_vma Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 05/18] nfp: bpf: silence bitwise vs. logical OR warning Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 06/18] can: grcan: grcan_probe(): fix broken system id check for errata workaround needs Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 07/18] can: grcan: only use the NAPI poll budget for RX Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 08/18] arm: remove CONFIG_ARCH_HAS_HOLES_MEMORYMODEL Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 09/18] KVM: x86/pmu: Refactoring find_arch_event() to pmc_perf_hw_id() Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 10/18] x86/asm: Allow to pass macros to __ASM_FORM() Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 11/18] x86: xen: kvm: Gather the definition of emulate prefixes Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 12/18] x86: xen: insn: Decode Xen and KVM emulate-prefix signature Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 13/18] x86: kprobes: Prohibit probing on instruction which has emulate prefix Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 14/18] KVM: x86/svm: Account for family 17h event renumberings in amd_pmc_perf_hw_id Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 15/18] Bluetooth: Fix the creation of hdev->name Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 16/18] mm: fix missing cache flush for all tail pages of compound page Greg Kroah-Hartman
2022-05-13 14:23 ` [PATCH 5.4 17/18] mm: hugetlb: fix missing cache flush in copy_huge_page_from_user() Greg Kroah-Hartman
2022-05-13 14:23 ` Greg Kroah-Hartman [this message]
2022-05-13 16:40 ` [PATCH 5.4 00/18] 5.4.194-rc1 review Jon Hunter
2022-05-13 20:39 ` Shuah Khan
2022-05-14 2:44 ` Florian Fainelli
2022-05-14 11:46 ` Naresh Kamboju
2022-05-14 14:27 ` Sudip Mukherjee
2022-05-14 14:56 ` Guenter Roeck
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=20220513142229.682741906@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=akpm@linux-foundation.org \
--cc=axelrasmussen@google.com \
--cc=duanxiongchun@bytedance.com \
--cc=fam.zheng@bytedance.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=lars.persson@axis.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mike.kravetz@oracle.com \
--cc=peterx@redhat.com \
--cc=rientjes@google.com \
--cc=songmuchun@bytedance.com \
--cc=stable@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=ziy@nvidia.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