lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <0C4B9C1A-97DE-4798-8256-158369AF42A4@gmail.com>
Date: Tue, 16 Apr 2024 12:36:08 +0300
From: Nadav Amit <nadav.amit@...il.com>
To: Mike Rapoport <rppt@...nel.org>
Cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
 Andrew Morton <akpm@...ux-foundation.org>,
 Andy Lutomirski <luto@...nel.org>,
 Arnd Bergmann <arnd@...db.de>,
 Catalin Marinas <catalin.marinas@....com>,
 Christoph Hellwig <hch@...radead.org>,
 Helge Deller <deller@....de>,
 Lorenzo Stoakes <lstoakes@...il.com>,
 Luis Chamberlain <mcgrof@...nel.org>,
 Mark Rutland <mark.rutland@....com>,
 Masami Hiramatsu <mhiramat@...nel.org>,
 Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
 Michael Ellerman <mpe@...erman.id.au>,
 Palmer Dabbelt <palmer@...belt.com>,
 Peter Zijlstra <peterz@...radead.org>,
 Russell King <linux@...linux.org.uk>,
 Song Liu <song@...nel.org>,
 Steven Rostedt <rostedt@...dmis.org>,
 Thomas Gleixner <tglx@...utronix.de>,
 Uladzislau Rezki <urezki@...il.com>,
 Will Deacon <will@...nel.org>,
 bpf@...r.kernel.org,
 linux-arch@...r.kernel.org,
 linux-arm-kernel@...ts.infradead.org,
 "open list:MEMORY MANAGEMENT" <linux-mm@...ck.org>,
 linux-modules@...r.kernel.org,
 linux-parisc@...r.kernel.org,
 linux-riscv@...ts.infradead.org,
 linux-trace-kernel@...r.kernel.org,
 linuxppc-dev@...ts.ozlabs.org,
 the arch/x86 maintainers <x86@...nel.org>
Subject: Re: [RFC PATCH 3/7] module: prepare to handle ROX allocations for
 text



> On 11 Apr 2024, at 19:05, Mike Rapoport <rppt@...nel.org> wrote:
> 
> @@ -2440,7 +2479,24 @@ static int post_relocation(struct module *mod, const struct load_info *info)
> 	add_kallsyms(mod, info);
> 
> 	/* Arch-specific module finalizing. */
> -	return module_finalize(info->hdr, info->sechdrs, mod);
> +	ret = module_finalize(info->hdr, info->sechdrs, mod);
> +	if (ret)
> +		return ret;
> +
> +	for_each_mod_mem_type(type) {
> +		struct module_memory *mem = &mod->mem[type];
> +
> +		if (mem->is_rox) {
> +			if (!execmem_update_copy(mem->base, mem->rw_copy,
> +						 mem->size))
> +				return -ENOMEM;
> +
> +			vfree(mem->rw_copy);
> +			mem->rw_copy = NULL;
> +		}
> +	}
> +
> +	return 0;
> }

I might be missing something, but it seems a bit racy.

IIUC, module_finalize() calls alternatives_smp_module_add(). At this
point, since you don’t hold the text_mutex, some might do text_poke(),
e.g., by enabling/disabling static-key, and the update would be
overwritten. No?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ