[PATCH] arm64: mm: Fix "rodata=on" when CONFIG_RODATA_FULL_DEFAULT_ENABLED=y

Ard Biesheuvel ardb at kernel.org
Tue Nov 21 07:24:39 PST 2023


On Tue, 21 Nov 2023 at 10:03, Will Deacon <will at kernel.org> wrote:
>
> On Fri, Nov 17, 2023 at 10:09:04AM -0500, Ard Biesheuvel wrote:
> > On Fri, 17 Nov 2023 at 08:14, Will Deacon <will at kernel.org> wrote:
> > >
> > > When CONFIG_RODATA_FULL_DEFAULT_ENABLED=y, passing "rodata=on" on the
> > > kernel command-line (rather than "rodata=full") should turn off the
> > > "full" behaviour, leaving writable linear aliases of read-only kernel
> > > memory. Unfortunately, the option has no effect in this situation and
> > > the only way to disable the "rodata=full" behaviour is to disable rodata
> > > protection entirely by passing "rodata=off".
> > >
> > > Fix this by parsing the "on" and "off" options in the arch code,
> > > additionally enforcing that 'rodata_full' cannot be set without also
> > > setting 'rodata_enabled', allowing us to simplify a couple of checks
> > > in the process.
> > >
> >
> > I think this got broken when this code was refactored to use the
> > generic parsing, which uses strtobool() and so it will match
> > rodata=0/1, yes, no etc, and only 'full' is handled as a special case.
>
> strtobool() is such a hack! I don't think the core code uses it anymore
> though: set_debug_rodata() uses good ol' strcmp() since 2e8cff0a0eee
> ("arm64: fix rodata=full").
>
> > Not sure whether this matters, and I'd much prefer supporting only
> > 'on', 'off' and 'full' because we'll need to parse rodata= early too
> > (for my big head.S / LPA2 refactor).
>
> I think that matches the current behaviour (minus the bug I'm fixing here)
> and even the documentation in kernel-parameters.txt only talks about those
> three values.
>

OK I didn't realize this was the current behavior already.

Reviewed-by: Ard Biesheuvel <ardb at kernel.org>



More information about the linux-arm-kernel mailing list