Linux MIPS Architecture development
 help / color / mirror / Atom feed
From: James Hogan <james.hogan@mips.com>
To: "Maciej W. Rozycki" <macro@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	Djordje Todorovic <djordje.todorovic@rt-rk.com>,
	<linux-mips@linux-mips.org>, <linux-kernel@vger.kernel.org>,
	<stable@vger.kernel.org>
Subject: Re: [PATCH] MIPS: Fix an n32 core file generation regset support regression
Date: Thu, 9 Nov 2017 15:45:17 +0000	[thread overview]
Message-ID: <20171109154517.GY15260@jhogan-linux> (raw)
In-Reply-To: <alpine.DEB.2.00.1710272036270.3886@tp.orcam.me.uk>

[-- Attachment #1: Type: text/plain, Size: 3007 bytes --]

On Tue, Nov 07, 2017 at 07:09:20PM +0000, Maciej W. Rozycki wrote:
> Fix a commit 7aeb753b5353 ("MIPS: Implement task_user_regset_view.") 
> regression, then activated by commit 6a9c001b7ec3 ("MIPS: Switch ELF 
> core dumper to use regsets.)", that caused n32 processes to dump o32 
> core files by failing to set the EF_MIPS_ABI2 flag in the ELF core file 
> header's `e_flags' member:
> 
> $ file tls-core
> tls-core: ELF 32-bit MSB executable, MIPS, N32 MIPS64 rel2 version 1 (SYSV), [...]
> $ ./tls-core
> Aborted (core dumped)
> $ file core
> core: ELF 32-bit MSB core file MIPS, MIPS-I version 1 (SYSV), SVR4-style
> $ 
> 
> Previously the flag was set as the result of a:
> 
> #define ELF_CORE_EFLAGS EF_MIPS_ABI2
> 
> statement placed in arch/mips/kernel/binfmt_elfn32.c, however in the 
> regset case, i.e. when CORE_DUMP_USE_REGSET is set, ELF_CORE_EFLAGS is 
> no longer used by `fill_note_info' in fs/binfmt_elf.c, and instead the 
> `->e_flags' member of the regset view chosen is.  We have the views 
> defined in arch/mips/kernel/ptrace.c, however only an o32 and an n64 
> one, and the latter is used for n32 as well.  Consequently an o32 core 
> file is incorrectly dumped from n32 processes (the ELF32 vs ELF64 class 
> is chosen elsewhere, and the 32-bit one is correctly selected for n32).
> 
> Correct the issue then by defining an n32 regset view and using it as 
> appropriate.  Issue discovered in GDB testing.
> 
> Cc: stable@vger.kernel.org # 3.13+
> Fixes: 7aeb753b5353 ("MIPS: Implement task_user_regset_view.")
> Signed-off-by: Maciej W. Rozycki <macro@mips.com>

Thanks, queued for 4.15.

Cheers
James

> ---
>  arch/mips/kernel/ptrace.c |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> linux-mips-regset-view-n32-e-flags-abi2-init.diff
> Index: linux-sfr/arch/mips/kernel/ptrace.c
> ===================================================================
> --- linux-sfr.orig/arch/mips/kernel/ptrace.c	2017-10-27 04:55:34.000000000 +0100
> +++ linux-sfr/arch/mips/kernel/ptrace.c	2017-10-27 20:07:14.933716000 +0100
> @@ -618,6 +618,19 @@ static const struct user_regset_view use
>  	.n		= ARRAY_SIZE(mips64_regsets),
>  };
>  
> +#ifdef CONFIG_MIPS32_N32
> +
> +static const struct user_regset_view user_mipsn32_view = {
> +	.name		= "mipsn32",
> +	.e_flags	= EF_MIPS_ABI2,
> +	.e_machine	= ELF_ARCH,
> +	.ei_osabi	= ELF_OSABI,
> +	.regsets	= mips64_regsets,
> +	.n		= ARRAY_SIZE(mips64_regsets),
> +};
> +
> +#endif /* CONFIG_MIPS32_N32 */
> +
>  #endif /* CONFIG_64BIT */
>  
>  const struct user_regset_view *task_user_regset_view(struct task_struct *task)
> @@ -629,6 +642,10 @@ const struct user_regset_view *task_user
>  	if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
>  		return &user_mips_view;
>  #endif
> +#ifdef CONFIG_MIPS32_N32
> +	if (test_tsk_thread_flag(task, TIF_32BIT_ADDR))
> +		return &user_mipsn32_view;
> +#endif
>  	return &user_mips64_view;
>  #endif
>  }

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: James Hogan <james.hogan@mips.com>
To: "Maciej W. Rozycki" <macro@mips.com>
Cc: Ralf Baechle <ralf@linux-mips.org>,
	Djordje Todorovic <djordje.todorovic@rt-rk.com>,
	linux-mips@linux-mips.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH] MIPS: Fix an n32 core file generation regset support regression
Date: Thu, 9 Nov 2017 15:45:17 +0000	[thread overview]
Message-ID: <20171109154517.GY15260@jhogan-linux> (raw)
Message-ID: <20171109154517._Lp5uIo59zc2ZAEAPYN0ga4MkIaIcyGEsZFTuCcYgzM@z> (raw)
In-Reply-To: <alpine.DEB.2.00.1710272036270.3886@tp.orcam.me.uk>

[-- Attachment #1: Type: text/plain, Size: 3007 bytes --]

On Tue, Nov 07, 2017 at 07:09:20PM +0000, Maciej W. Rozycki wrote:
> Fix a commit 7aeb753b5353 ("MIPS: Implement task_user_regset_view.") 
> regression, then activated by commit 6a9c001b7ec3 ("MIPS: Switch ELF 
> core dumper to use regsets.)", that caused n32 processes to dump o32 
> core files by failing to set the EF_MIPS_ABI2 flag in the ELF core file 
> header's `e_flags' member:
> 
> $ file tls-core
> tls-core: ELF 32-bit MSB executable, MIPS, N32 MIPS64 rel2 version 1 (SYSV), [...]
> $ ./tls-core
> Aborted (core dumped)
> $ file core
> core: ELF 32-bit MSB core file MIPS, MIPS-I version 1 (SYSV), SVR4-style
> $ 
> 
> Previously the flag was set as the result of a:
> 
> #define ELF_CORE_EFLAGS EF_MIPS_ABI2
> 
> statement placed in arch/mips/kernel/binfmt_elfn32.c, however in the 
> regset case, i.e. when CORE_DUMP_USE_REGSET is set, ELF_CORE_EFLAGS is 
> no longer used by `fill_note_info' in fs/binfmt_elf.c, and instead the 
> `->e_flags' member of the regset view chosen is.  We have the views 
> defined in arch/mips/kernel/ptrace.c, however only an o32 and an n64 
> one, and the latter is used for n32 as well.  Consequently an o32 core 
> file is incorrectly dumped from n32 processes (the ELF32 vs ELF64 class 
> is chosen elsewhere, and the 32-bit one is correctly selected for n32).
> 
> Correct the issue then by defining an n32 regset view and using it as 
> appropriate.  Issue discovered in GDB testing.
> 
> Cc: stable@vger.kernel.org # 3.13+
> Fixes: 7aeb753b5353 ("MIPS: Implement task_user_regset_view.")
> Signed-off-by: Maciej W. Rozycki <macro@mips.com>

Thanks, queued for 4.15.

Cheers
James

> ---
>  arch/mips/kernel/ptrace.c |   17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> linux-mips-regset-view-n32-e-flags-abi2-init.diff
> Index: linux-sfr/arch/mips/kernel/ptrace.c
> ===================================================================
> --- linux-sfr.orig/arch/mips/kernel/ptrace.c	2017-10-27 04:55:34.000000000 +0100
> +++ linux-sfr/arch/mips/kernel/ptrace.c	2017-10-27 20:07:14.933716000 +0100
> @@ -618,6 +618,19 @@ static const struct user_regset_view use
>  	.n		= ARRAY_SIZE(mips64_regsets),
>  };
>  
> +#ifdef CONFIG_MIPS32_N32
> +
> +static const struct user_regset_view user_mipsn32_view = {
> +	.name		= "mipsn32",
> +	.e_flags	= EF_MIPS_ABI2,
> +	.e_machine	= ELF_ARCH,
> +	.ei_osabi	= ELF_OSABI,
> +	.regsets	= mips64_regsets,
> +	.n		= ARRAY_SIZE(mips64_regsets),
> +};
> +
> +#endif /* CONFIG_MIPS32_N32 */
> +
>  #endif /* CONFIG_64BIT */
>  
>  const struct user_regset_view *task_user_regset_view(struct task_struct *task)
> @@ -629,6 +642,10 @@ const struct user_regset_view *task_user
>  	if (test_tsk_thread_flag(task, TIF_32BIT_REGS))
>  		return &user_mips_view;
>  #endif
> +#ifdef CONFIG_MIPS32_N32
> +	if (test_tsk_thread_flag(task, TIF_32BIT_ADDR))
> +		return &user_mipsn32_view;
> +#endif
>  	return &user_mips64_view;
>  #endif
>  }

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  parent reply	other threads:[~2017-11-09 15:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-07 19:09 [PATCH] MIPS: Fix an n32 core file generation regset support regression Maciej W. Rozycki
2017-11-07 19:09 ` Maciej W. Rozycki
2017-11-09 15:45 ` James Hogan [this message]
2017-11-09 15:45   ` James Hogan

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=20171109154517.GY15260@jhogan-linux \
    --to=james.hogan@mips.com \
    --cc=djordje.todorovic@rt-rk.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@linux-mips.org \
    --cc=macro@mips.com \
    --cc=ralf@linux-mips.org \
    --cc=stable@vger.kernel.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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox