linux-stable/kernel
Robin Murphy 204dfb6305 dma-direct: don't over-decrypt memory
[ Upstream commit 4a37f3dd9a ]

The original x86 sev_alloc() only called set_memory_decrypted() on
memory returned by alloc_pages_node(), so the page order calculation
fell out of that logic. However, the common dma-direct code has several
potential allocators, not all of which are guaranteed to round up the
underlying allocation to a power-of-two size, so carrying over that
calculation for the encryption/decryption size was a mistake. Fix it by
rounding to a *number* of pages, rather than an order.

Until recently there was an even worse interaction with DMA_DIRECT_REMAP
where we could have ended up decrypting part of the next adjacent
vmalloc area, only averted by no architecture actually supporting both
configs at once. Don't ask how I found that one out...

Fixes: c10f07aa27 ("dma/direct: Handle force decryption for DMA coherent buffers in common code")
Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Acked-by: David Rientjes <rientjes@google.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-06-09 10:25:58 +02:00
..
bpf bpf: Check PTR_TO_MEM | MEM_RDONLY in check_helper_mem_access 2022-06-06 08:47:57 +02:00
cgroup cgroup/cpuset: Remove cpus_allowed/mems_allowed setup in cpuset_init_smp() 2022-05-18 10:28:22 +02:00
configs configs/debug: restore DEBUG_INFO=y for overriding 2022-03-17 11:02:13 -07:00
debug lockdown: also lock down previous kgdb use 2022-05-25 09:59:10 +02:00
dma dma-direct: don't over-decrypt memory 2022-06-09 10:25:58 +02:00
entry
events signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:25:41 +02:00
futex Merge branch 'signal-for-v5.17' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace 2022-01-17 05:49:30 +02:00
gcov
irq genirq: Remove WARN_ON_ONCE() in generic_handle_domain_irq() 2022-05-18 10:28:20 +02:00
kcsan KCSAN updates for v5.17 2022-01-11 09:51:26 -08:00
livepatch livepatch: Fix build failure on 32 bits processors 2022-04-08 13:58:03 +02:00
locking locking/lockdep: Iterate lock_classes directly when reading lockdep files 2022-04-08 13:58:39 +02:00
power PM: EM: Decrement policy counter 2022-06-09 10:25:49 +02:00
printk printk: wake waiters for safe and NMI contexts 2022-06-09 10:25:42 +02:00
rcu rcu: Make TASKS_RUDE_RCU select IRQ_WORK 2022-06-09 10:25:19 +02:00
sched sched/psi: report zeroes for CPU full at the system level 2022-06-09 10:25:41 +02:00
time timekeeping: Add raw clock fallback for random_get_entropy() 2022-05-30 09:27:13 +02:00
trace tracing: Have type enum modifications copy the strings 2022-04-08 13:58:59 +02:00
.gitignore
acct.c
async.c Revert "module, async: async_synchronize_full() on module init iff async is used" 2022-02-03 11:20:34 -08:00
audit.c audit: improve audit queue handling when "audit=1" on cmdline 2022-01-25 13:22:51 -05:00
audit.h audit: log AUDIT_TIME_* records only from rules 2022-04-08 13:57:35 +02:00
audit_fsnotify.c
audit_tree.c
audit_watch.c
auditfilter.c audit/stable-5.17 PR 20220110 2022-01-11 13:08:21 -08:00
auditsc.c audit,io_uring,io-wq: call __audit_uring_exit for dummy contexts 2022-05-25 09:59:02 +02:00
backtracetest.c
bounds.c
capability.c
cfi.c
compat.c
configs.c
context_tracking.c
cpu.c random: clear fast pool, crng, and batches in cpuhp bring up 2022-05-30 09:27:08 +02:00
cpu_pm.c
crash_core.c
crash_dump.c
cred.c ucounts: Base set_cred_ucounts changes on the real user 2022-02-17 09:11:02 -06:00
delayacct.c delayacct: track delays from memory compact 2022-01-20 08:52:55 +02:00
dma.c
exec_domain.c
exit.c
extable.c
fail_function.c
fork.c kthread: Don't allocate kthread_struct for init and umh 2022-06-09 10:25:16 +02:00
freezer.c
gen_kheaders.sh
groups.c
hung_task.c hung_task: move hung_task sysctl interface to hung_task.c 2022-01-22 08:33:34 +02:00
iomem.c
irq_work.c irq_work: use kasan_record_aux_stack_noalloc() record callstack 2022-04-27 14:41:10 +02:00
jump_label.c
kallsyms.c Livepatching changes for 5.17 2022-01-16 10:08:13 +02:00
kcmp.c
Kconfig.freezer
Kconfig.hz
Kconfig.locks
Kconfig.preempt
kcov.c
kexec.c
kexec_core.c
kexec_elf.c
kexec_file.c
kexec_internal.h
kheaders.c
kmod.c
kprobes.c kprobe: move sysctl_kprobes_optimization to kprobes.c 2022-01-22 08:33:36 +02:00
ksysfs.c
kthread.c Merge branch 'akpm' (patches from Andrew) 2022-01-20 10:41:01 +02:00
latencytop.c
Makefile static_call: Don't make __static_call_return0 static 2022-04-13 19:27:43 +02:00
module-internal.h module: add in-kernel support for decompressing 2022-01-11 18:45:02 -08:00
module.c Revert "module, async: async_synchronize_full() on module init iff async is used" 2022-02-03 11:20:34 -08:00
module_decompress.c module: fix building with sysfs disabled 2022-02-16 12:51:32 -08:00
module_signature.c
module_signing.c
notifier.c
nsproxy.c
padata.c
panic.c panic: remove oops_id 2022-01-20 08:52:55 +02:00
params.c
pid.c
pid_namespace.c
profile.c
ptrace.c ptrace: Reimplement PTRACE_KILL by always sending SIGKILL 2022-06-09 10:25:16 +02:00
range.c
reboot.c
regset.c
relay.c
resource.c kernel/resource: fix kfree() of bootmem memory again 2022-04-08 13:58:23 +02:00
resource_kunit.c
rseq.c rseq: Remove broken uapi field layout on 32-bit little endian 2022-04-08 13:57:39 +02:00
scftorture.c scftorture: Fix distribution of short handler delays 2022-06-09 10:25:39 +02:00
scs.c
seccomp.c seccomp: Invalidate seccomp mode to catch death failures 2022-02-10 19:09:12 -08:00
signal.c signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-06-09 10:25:41 +02:00
smp.c smp: Fix offline cpu check in flush_smp_call_function_queue() 2022-04-20 09:36:27 +02:00
smpboot.c
smpboot.h
softirq.c
stackleak.c gcc-plugins/stackleak: Use noinstr in favor of notrace 2022-02-03 17:02:21 -08:00
stacktrace.c
static_call.c static_call: Don't make __static_call_return0 static 2022-04-13 19:27:43 +02:00
static_call_inline.c static_call: Don't make __static_call_return0 static 2022-04-13 19:27:43 +02:00
stop_machine.c
sys.c mm: refactor vm_area_struct::anon_vma_name usage code 2022-03-05 11:08:32 -08:00
sys_ni.c mm/mempolicy: wire up syscall set_mempolicy_home_node 2022-01-15 16:30:30 +02:00
sysctl-test.c
sysctl.c x86/speculation: Include unprivileged eBPF status in Spectre v2 mitigation reporting 2022-02-21 10:21:47 +01:00
task_work.c
taskstats.c
torture.c
tracepoint.c
tsacct.c
ucount.c ucounts: Handle wrapping in is_ucounts_overlimit 2022-02-17 09:11:57 -06:00
uid16.c
uid16.h
umh.c kthread: Don't allocate kthread_struct for init and umh 2022-06-09 10:25:16 +02:00
up.c
user-return-notifier.c
user.c
user_namespace.c ucounts: Fix systemd LimitNPROC with private users regression 2022-02-25 10:40:14 -06:00
usermode_driver.c
utsname.c
utsname_sysctl.c
watch_queue.c watch_queue: Free the page array when watch_queue is dismantled 2022-04-08 13:58:56 +02:00
watchdog.c watchdog: move watchdog sysctl interface to watchdog.c 2022-01-22 08:33:34 +02:00
watchdog_hld.c
workqueue.c
workqueue_internal.h