mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
Align ro_after_init using MAXPAGESIZE instead of COMMONPAGESIZE. COMMONPAGESIZE may be smaller than the actual page size supported by the target ABI. This can leave ro_after_init sharing an OS page with adjacent sections, causing mprotect() to change permissions on data outside ro_after_init. Use MAXPAGESIZE so the section boundaries are aligned to the maximum page size required by the target linker/ABI. This is particularly important on architectures such as ppc64le and aarch64, where the runtime page size can differ from COMMONPAGESIZE. Before: .data 0x...1b80000 ro_after_init 0x...1c70000 .bss 0x...1c72000 After: ro_after_init starts and ends on MAXPAGESIZE boundaries, ensuring mprotect() only affects pages belonging to ro_after_init. Co-authored-by: ChatGPT GPT-5.6 Luna <noreply@openai.com>
32 lines
1.1 KiB
Plaintext
32 lines
1.1 KiB
Plaintext
/*
|
|
Copyright (c) 2026, MariaDB plc, MariaDB Foundation
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; version 2 of the License.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
|
|
|
|
/*
|
|
Give the "ro_after_init" section a page-aligned span of its own, so that the
|
|
variables placed there (with READ_ONLY_SYSVAR tag) can be mprotect()-ed
|
|
once server initialization is complete, without affecting neighbouring data.
|
|
*/
|
|
SECTIONS
|
|
{
|
|
ro_after_init ALIGN(CONSTANT(MAXPAGESIZE)) :
|
|
{
|
|
ro_after_init_start = .;
|
|
*(ro_after_init)
|
|
. = ALIGN(CONSTANT(MAXPAGESIZE));
|
|
ro_after_init_end = .;
|
|
}
|
|
} INSERT AFTER .data;
|