From: Damien Le Moal <dlemoal@kernel.org> To: Stefan O'Rear <sorear@fastmail.com>, linux-mm@kvack.org, linux-riscv@lists.infradead.org Cc: Eric Biederman <ebiederm@xmission.com>, Kees Cook <keescook@chromium.org>, Damien Le Moal <damien.lemoal@wdc.com>, Greg Ungerer <gerg@linux-m68k.org>, Waldemar Brodkorb <wbx@openadk.org> Subject: Re: [PATCH] binfmt_flat: Fix corruption when not offsetting data start Date: Tue, 26 Mar 2024 14:53:49 +0900 [thread overview] Message-ID: <4acb96b2-949d-4f08-99c6-08bb30ead928@kernel.org> (raw) In-Reply-To: <20240326032037.2478816-1-sorear@fastmail.com> On 3/26/24 12:20, Stefan O'Rear wrote: > Commit 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") > introduced a RISC-V specific variant of the FLAT format which does not > allocate any space for the (obsolescent) array of shared library > pointers. However, it did not disable the code which initializes the > array, resulting in the corruption of sizeof(long) bytes before the DATA > segment, generally the end of the TEXT segment. > > Use CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET to guard initialization the s/initialization the/the initialization of the > shared library pointer region so that it will only be initialized if > space is reserved for it. > > Fixes: 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") > Signed-off-by: Stefan O'Rear <sorear@fastmail.com> > Tested-by: Waldemar Brodkorb <wbx@openadk.org> It feels like CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET is not a very good name... Maybe something like CONFIG_BINFMT_FLAT_NO_SHARED_LIBRARY would be better. But renaming can be done in a followup patch. Reviewed-by: Damien Le Moal <dlemoal > --- > fs/binfmt_flat.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c > index c26545d71d39..70c2b68988f4 100644 > --- a/fs/binfmt_flat.c > +++ b/fs/binfmt_flat.c > @@ -879,6 +879,7 @@ static int load_flat_binary(struct linux_binprm *bprm) > if (res < 0) > return res; > > +#ifndef CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET > /* Update data segment pointers for all libraries */ > for (i = 0; i < MAX_SHARED_LIBS; i++) { > if (!libinfo.lib_list[i].loaded) > @@ -893,6 +894,7 @@ static int load_flat_binary(struct linux_binprm *bprm) > return -EFAULT; > } > } > +#endif > > set_binfmt(&flat_format); > -- Damien Le Moal Western Digital Research _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv
WARNING: multiple messages have this Message-ID (diff)
From: Damien Le Moal <dlemoal@kernel.org> To: Stefan O'Rear <sorear@fastmail.com>, linux-mm@kvack.org, linux-riscv@lists.infradead.org Cc: Eric Biederman <ebiederm@xmission.com>, Kees Cook <keescook@chromium.org>, Damien Le Moal <damien.lemoal@wdc.com>, Greg Ungerer <gerg@linux-m68k.org>, Waldemar Brodkorb <wbx@openadk.org> Subject: Re: [PATCH] binfmt_flat: Fix corruption when not offsetting data start Date: Tue, 26 Mar 2024 14:53:49 +0900 [thread overview] Message-ID: <4acb96b2-949d-4f08-99c6-08bb30ead928@kernel.org> (raw) In-Reply-To: <20240326032037.2478816-1-sorear@fastmail.com> On 3/26/24 12:20, Stefan O'Rear wrote: > Commit 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") > introduced a RISC-V specific variant of the FLAT format which does not > allocate any space for the (obsolescent) array of shared library > pointers. However, it did not disable the code which initializes the > array, resulting in the corruption of sizeof(long) bytes before the DATA > segment, generally the end of the TEXT segment. > > Use CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET to guard initialization the s/initialization the/the initialization of the > shared library pointer region so that it will only be initialized if > space is reserved for it. > > Fixes: 04d82a6d0881 ("binfmt_flat: allow not offsetting data start") > Signed-off-by: Stefan O'Rear <sorear@fastmail.com> > Tested-by: Waldemar Brodkorb <wbx@openadk.org> It feels like CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET is not a very good name... Maybe something like CONFIG_BINFMT_FLAT_NO_SHARED_LIBRARY would be better. But renaming can be done in a followup patch. Reviewed-by: Damien Le Moal <dlemoal > --- > fs/binfmt_flat.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c > index c26545d71d39..70c2b68988f4 100644 > --- a/fs/binfmt_flat.c > +++ b/fs/binfmt_flat.c > @@ -879,6 +879,7 @@ static int load_flat_binary(struct linux_binprm *bprm) > if (res < 0) > return res; > > +#ifndef CONFIG_BINFMT_FLAT_NO_DATA_START_OFFSET > /* Update data segment pointers for all libraries */ > for (i = 0; i < MAX_SHARED_LIBS; i++) { > if (!libinfo.lib_list[i].loaded) > @@ -893,6 +894,7 @@ static int load_flat_binary(struct linux_binprm *bprm) > return -EFAULT; > } > } > +#endif > > set_binfmt(&flat_format); > -- Damien Le Moal Western Digital Research
next prev parent reply other threads:[~2024-03-26 5:54 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-03-26 3:20 [PATCH] binfmt_flat: Fix corruption when not offsetting data start Stefan O'Rear 2024-03-26 3:20 ` Stefan O'Rear 2024-03-26 5:53 ` Damien Le Moal [this message] 2024-03-26 5:53 ` Damien Le Moal 2024-04-04 7:40 ` Greg Ungerer 2024-04-04 7:40 ` Greg Ungerer 2024-04-24 20:44 ` Alexandre Ghiti 2024-04-24 20:44 ` Alexandre Ghiti
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=4acb96b2-949d-4f08-99c6-08bb30ead928@kernel.org \ --to=dlemoal@kernel.org \ --cc=damien.lemoal@wdc.com \ --cc=ebiederm@xmission.com \ --cc=gerg@linux-m68k.org \ --cc=keescook@chromium.org \ --cc=linux-mm@kvack.org \ --cc=linux-riscv@lists.infradead.org \ --cc=sorear@fastmail.com \ --cc=wbx@openadk.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.