linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [REVIEW][PATCH 0/2] signal/arc: siginfo cleanups
@ 2018-09-24 14:47 Eric W. Biederman
  2018-09-24 14:49 ` [REVIEW][PATCH 1/2] signal/arc: Push siginfo generation into unhandled_exception Eric W. Biederman
  2018-09-24 14:49 ` [REVIEW][PATCH 2/2] signal/arc: Use force_sig_fault where appropriate Eric W. Biederman
  0 siblings, 2 replies; 5+ messages in thread
From: Eric W. Biederman @ 2018-09-24 14:47 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, linux-snps-arc, Vineet Gupta


I have been slowly cleaning up the architectues ever since I discovered
that the pattern of passing in struct siginfo is error prone, and
occassionally results in borken siginfo being sent to userspace.

What is happening on arc is pretty tame and I have compile tested
these changes, so I don't expect problems.

Still I would appreciate if people can look over the code and perhaps
test it and see if they can spot anything that has perhaps gone wrong.
appreciate it.

My intention is to merge this through my siginfo tree.  If you feel it
should go through your arch tree let me know.   All of the prerequisites
should have been merged several releases ago.

Eric W. Biederman (2):
      signal/arc: Push siginfo generation into unhandled_exception
      signal/arc: Use force_sig_fault where appropriate

 arch/arc/kernel/traps.c | 22 ++++++++--------------
 arch/arc/mm/fault.c     | 20 +++++---------------
 2 files changed, 13 insertions(+), 29 deletions(-)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [REVIEW][PATCH 1/2] signal/arc: Push siginfo generation into unhandled_exception
  2018-09-24 14:47 [REVIEW][PATCH 0/2] signal/arc: siginfo cleanups Eric W. Biederman
@ 2018-09-24 14:49 ` Eric W. Biederman
  2018-09-24 17:37   ` Vineet Gupta
  2018-09-24 14:49 ` [REVIEW][PATCH 2/2] signal/arc: Use force_sig_fault where appropriate Eric W. Biederman
  1 sibling, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2018-09-24 14:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, linux-snps-arc, Vineet Gupta, Eric W. Biederman

Pass signr, sicode, and address into unhandled_exception as explicit
parameters instead of members of struct siginfo.  Then in unhandled
exception generate and send the siginfo using force_sig_fault.

This keeps the code simpler and less error prone.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 arch/arc/kernel/traps.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/arch/arc/kernel/traps.c b/arch/arc/kernel/traps.c
index b123558bf0bb..a7fcbc0d3943 100644
--- a/arch/arc/kernel/traps.c
+++ b/arch/arc/kernel/traps.c
@@ -42,21 +42,22 @@ void die(const char *str, struct pt_regs *regs, unsigned long address)
  *  -for kernel, chk if due to copy_(to|from)_user, otherwise die()
  */
 static noinline int
-unhandled_exception(const char *str, struct pt_regs *regs, siginfo_t *info)
+unhandled_exception(const char *str, struct pt_regs *regs,
+		    int signo, int si_code, void __user *addr)
 {
 	if (user_mode(regs)) {
 		struct task_struct *tsk = current;
 
-		tsk->thread.fault_address = (__force unsigned int)info->si_addr;
+		tsk->thread.fault_address = (__force unsigned int)addr;
 
-		force_sig_info(info->si_signo, info, tsk);
+		force_sig_fault(signo, si_code, addr, tsk);
 
 	} else {
 		/* If not due to copy_(to|from)_user, we are doomed */
 		if (fixup_exception(regs))
 			return 0;
 
-		die(str, regs, (unsigned long)info->si_addr);
+		die(str, regs, (unsigned long)addr);
 	}
 
 	return 1;
@@ -64,16 +65,9 @@ unhandled_exception(const char *str, struct pt_regs *regs, siginfo_t *info)
 
 #define DO_ERROR_INFO(signr, str, name, sicode) \
 int name(unsigned long address, struct pt_regs *regs) \
-{						\
-	siginfo_t info;				\
-						\
-	clear_siginfo(&info);			\
-	info.si_signo = signr;			\
-	info.si_errno = 0;			\
-	info.si_code  = sicode;			\
-	info.si_addr = (void __user *)address;	\
-						\
-	return unhandled_exception(str, regs, &info);\
+{								\
+	return unhandled_exception(str, regs, signr, sicode,	\
+				   (void __user *)address);	\
 }
 
 /*
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [REVIEW][PATCH 2/2] signal/arc: Use force_sig_fault where appropriate
  2018-09-24 14:47 [REVIEW][PATCH 0/2] signal/arc: siginfo cleanups Eric W. Biederman
  2018-09-24 14:49 ` [REVIEW][PATCH 1/2] signal/arc: Push siginfo generation into unhandled_exception Eric W. Biederman
@ 2018-09-24 14:49 ` Eric W. Biederman
  2018-09-24 17:37   ` Vineet Gupta
  1 sibling, 1 reply; 5+ messages in thread
From: Eric W. Biederman @ 2018-09-24 14:49 UTC (permalink / raw)
  To: linux-kernel; +Cc: linux-arch, linux-snps-arc, Vineet Gupta, Eric W. Biederman

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
---
 arch/arc/mm/fault.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/arch/arc/mm/fault.c b/arch/arc/mm/fault.c
index db6913094be3..c9da6102eb4f 100644
--- a/arch/arc/mm/fault.c
+++ b/arch/arc/mm/fault.c
@@ -66,14 +66,12 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
 	struct vm_area_struct *vma = NULL;
 	struct task_struct *tsk = current;
 	struct mm_struct *mm = tsk->mm;
-	siginfo_t info;
+	int si_code;
 	int ret;
 	vm_fault_t fault;
 	int write = regs->ecr_cause & ECR_C_PROTV_STORE;  /* ST/EX */
 	unsigned int flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
 
-	clear_siginfo(&info);
-
 	/*
 	 * We fault-in kernel-space virtual memory on-demand. The
 	 * 'reference' page table is init_mm.pgd.
@@ -91,7 +89,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
 			return;
 	}
 
-	info.si_code = SEGV_MAPERR;
+	si_code = SEGV_MAPERR;
 
 	/*
 	 * If we're in an interrupt or have no user
@@ -119,7 +117,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
 	 * we can handle it..
 	 */
 good_area:
-	info.si_code = SEGV_ACCERR;
+	si_code = SEGV_ACCERR;
 
 	/* Handle protection violation, execute on heap or stack */
 
@@ -199,11 +197,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
 	/* User mode accesses just cause a SIGSEGV */
 	if (user_mode(regs)) {
 		tsk->thread.fault_address = address;
-		info.si_signo = SIGSEGV;
-		info.si_errno = 0;
-		/* info.si_code has been set above */
-		info.si_addr = (void __user *)address;
-		force_sig_info(SIGSEGV, &info, tsk);
+		force_sig_fault(SIGSEGV, si_code, (void __user *)address, tsk);
 		return;
 	}
 
@@ -238,9 +232,5 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)
 		goto no_context;
 
 	tsk->thread.fault_address = address;
-	info.si_signo = SIGBUS;
-	info.si_errno = 0;
-	info.si_code = BUS_ADRERR;
-	info.si_addr = (void __user *)address;
-	force_sig_info(SIGBUS, &info, tsk);
+	force_sig_fault(SIGBUS, BUS_ADRERR, (void __user *)address, tsk);
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [REVIEW][PATCH 1/2] signal/arc: Push siginfo generation into unhandled_exception
  2018-09-24 14:49 ` [REVIEW][PATCH 1/2] signal/arc: Push siginfo generation into unhandled_exception Eric W. Biederman
@ 2018-09-24 17:37   ` Vineet Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Vineet Gupta @ 2018-09-24 17:37 UTC (permalink / raw)
  To: Eric W. Biederman, linux-kernel; +Cc: linux-arch, linux-snps-arc, Vineet Gupta

On 09/24/2018 07:49 AM, Eric W. Biederman wrote:
> Pass signr, sicode, and address into unhandled_exception as explicit
> parameters instead of members of struct siginfo.  Then in unhandled
> exception generate and send the siginfo using force_sig_fault.
>
> This keeps the code simpler and less error prone.
>
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

LGTM.

Acked-by: Vineet Gupta <vgupta@synopsys.com>

Thx,
-Vineet

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [REVIEW][PATCH 2/2] signal/arc: Use force_sig_fault where appropriate
  2018-09-24 14:49 ` [REVIEW][PATCH 2/2] signal/arc: Use force_sig_fault where appropriate Eric W. Biederman
@ 2018-09-24 17:37   ` Vineet Gupta
  0 siblings, 0 replies; 5+ messages in thread
From: Vineet Gupta @ 2018-09-24 17:37 UTC (permalink / raw)
  To: Eric W. Biederman, linux-kernel; +Cc: linux-arch, linux-snps-arc, Vineet Gupta

On 09/24/2018 07:49 AM, Eric W. Biederman wrote:
> Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>

Acked-by: Vineet Gupta <vgupta@synopsys.com>

Thx,
-Vineet

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-09-24 17:37 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-24 14:47 [REVIEW][PATCH 0/2] signal/arc: siginfo cleanups Eric W. Biederman
2018-09-24 14:49 ` [REVIEW][PATCH 1/2] signal/arc: Push siginfo generation into unhandled_exception Eric W. Biederman
2018-09-24 17:37   ` Vineet Gupta
2018-09-24 14:49 ` [REVIEW][PATCH 2/2] signal/arc: Use force_sig_fault where appropriate Eric W. Biederman
2018-09-24 17:37   ` Vineet Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).