From 0b4b01c915e4783c3efca28a0a93576c40f0cfe1 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 14 Oct 2022 04:38:39 +0000 Subject: [PATCH] put the malloc_readonly struct into the "openbsd.mutable" section, so that the kernel and ld.so will know not to mark it immutable. malloc handles the read/write transitions by itself. --- lib/libc/stdlib/malloc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/libc/stdlib/malloc.c b/lib/libc/stdlib/malloc.c index b12c89aca03..a0ee04f821e 100644 --- a/lib/libc/stdlib/malloc.c +++ b/lib/libc/stdlib/malloc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: malloc.c,v 1.274 2022/06/30 17:15:48 guenther Exp $ */ +/* $OpenBSD: malloc.c,v 1.275 2022/10/14 04:38:39 deraadt Exp $ */ /* * Copyright (c) 2008, 2010, 2011, 2016 Otto Moerbeek * Copyright (c) 2012 Matthew Dempsky @@ -228,7 +228,8 @@ struct malloc_readonly { static union { struct malloc_readonly mopts; u_char _pad[MALLOC_PAGESIZE]; -} malloc_readonly __attribute__((aligned(MALLOC_PAGESIZE))); +} malloc_readonly __attribute__((aligned(MALLOC_PAGESIZE))) + __attribute__((section(".openbsd.mutable"))); #define mopts malloc_readonly.mopts char *malloc_options; /* compile-time options */ -- 2.20.1