Commit a11f2d5b authored by Maciej W. Rozycki's avatar Maciej W. Rozycki Committed by Kleber Sacilotto de Souza

binfmt_elf: Respect error return from `regset->active'

BugLink: https://bugs.launchpad.net/bugs/1798587

[ Upstream commit 2f819db5 ]

The regset API documented in <linux/regset.h> defines -ENODEV as the
result of the `->active' handler to be used where the feature requested
is not available on the hardware found.  However code handling core file
note generation in `fill_thread_core_info' interpretes any non-zero
result from the `->active' handler as the regset requested being active.
Consequently processing continues (and hopefully gracefully fails later
on) rather than being abandoned right away for the regset requested.

Fix the problem then by making the code proceed only if a positive
result is returned from the `->active' handler.
Signed-off-by: default avatarMaciej W. Rozycki <macro@mips.com>
Signed-off-by: default avatarPaul Burton <paul.burton@mips.com>
Fixes: 4206d3aa ("elf core dump: notes user_regset")
Patchwork: https://patchwork.linux-mips.org/patch/19332/
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: James Hogan <jhogan@kernel.org>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent a26323fa
...@@ -1707,7 +1707,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t, ...@@ -1707,7 +1707,7 @@ static int fill_thread_core_info(struct elf_thread_core_info *t,
const struct user_regset *regset = &view->regsets[i]; const struct user_regset *regset = &view->regsets[i];
do_thread_regset_writeback(t->task, regset); do_thread_regset_writeback(t->task, regset);
if (regset->core_note_type && regset->get && if (regset->core_note_type && regset->get &&
(!regset->active || regset->active(t->task, regset))) { (!regset->active || regset->active(t->task, regset) > 0)) {
int ret; int ret;
size_t size = regset->n * regset->size; size_t size = regset->n * regset->size;
void *data = kmalloc(size, GFP_KERNEL); void *data = kmalloc(size, GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment