Thread (35 messages) 35 messages, 4 authors, 2021-03-19

Re: [PATCH v2 01/17] add support for Clang CFI

From: Peter Zijlstra <peterz@infradead.org>
Date: 2021-03-18 22:31:16
Also in: bpf, linux-arm-kernel, linux-hardening, linux-kbuild, linux-pci, lkml

On Thu, Mar 18, 2021 at 10:10:55AM -0700, Sami Tolvanen wrote:
quoted hunk ↗ jump to hunk
+static void update_shadow(struct module *mod, unsigned long base_addr,
+		update_shadow_fn fn)
+{
+	struct cfi_shadow *prev;
+	struct cfi_shadow *next;
+	unsigned long min_addr, max_addr;
+
+	next = vmalloc(SHADOW_SIZE);
+
+	mutex_lock(&shadow_update_lock);
+	prev = rcu_dereference_protected(cfi_shadow,
+					 mutex_is_locked(&shadow_update_lock));
+
+	if (next) {
+		next->base = base_addr >> PAGE_SHIFT;
+		prepare_next_shadow(prev, next);
+
+		min_addr = (unsigned long)mod->core_layout.base;
+		max_addr = min_addr + mod->core_layout.text_size;
+		fn(next, mod, min_addr & PAGE_MASK, max_addr & PAGE_MASK);
+
+		set_memory_ro((unsigned long)next, SHADOW_PAGES);
+	}
+
+	rcu_assign_pointer(cfi_shadow, next);
+	mutex_unlock(&shadow_update_lock);
+	synchronize_rcu_expedited();
expedited is BAD(tm), why is it required and why doesn't it have a
comment?
quoted hunk ↗ jump to hunk
+
+	if (prev) {
+		set_memory_rw((unsigned long)prev, SHADOW_PAGES);
+		vfree(prev);
+	}
+}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help