From patchwork Mon Dec 19 10:37:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maninder Singh X-Patchwork-Id: 9480045 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3F28E60237 for ; Mon, 19 Dec 2016 10:45:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EED7283FD for ; Mon, 19 Dec 2016 10:45:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 214C82842C; Mon, 19 Dec 2016 10:45:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B26F5283FD for ; Mon, 19 Dec 2016 10:45:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cIvPd-00071E-NN; Mon, 19 Dec 2016 10:43:21 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cIvPY-0006v1-5e for linux-arm-kernel@lists.infradead.org; Mon, 19 Dec 2016 10:43:17 +0000 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OIF0280IHR9XV50@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Mon, 19 Dec 2016 19:42:52 +0900 (KST) X-AuditID: cbfee61b-f79d86d00000197e-bb-5857b9acd4bf Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 6A.50.06526.CA9B7585; Mon, 19 Dec 2016 19:42:52 +0900 (KST) Received: from localhost.localdomain ([107.108.92.210]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OIF005ZKHR8GEA0@mmp2.samsung.com>; Mon, 19 Dec 2016 19:42:52 +0900 (KST) From: Maninder Singh To: linux@armlinux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com Subject: [PATCH 1/1] mm: call force_sig_info before prints Date: Mon, 19 Dec 2016 16:07:12 +0530 Message-id: <1482143832-11158-1-git-send-email-maninder1.s@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprLIsWRmVeSWpSXmKPExsVy+t9jQd01O8MjDJrOKFq8eDWBxWLO+jVs FltPTWC0eL+sh9Fi9vRmJov7+5YzWdx8PofFYuWeH0wWmx5fY7W4vGsOm8WhqXsZLQ7Pb2Ox WHr9IpPFvTdbmSweLTnAZnGnaxaTxcuPJ1gcBD3WzFvD6HH52kVmj52z7rJ7nJjxm8Vj3slA j81L6j3e77vK5tG3ZRWjx5kFR9g9Pm+SC+CKcrPJSE1MSS1SSM1Lzk/JzEu3VQoNcdO1UFLI S8xNtVWK0PUNCVJSKEvMKQXyjAzQgINzgHuwkr5dglvGq5VnmQs2ilVMeX2IrYFxk1AXIyeH hICJRGP7HSYIW0ziwr31bCC2kMAsRonmCQJdjFxA9k9GiY0nX4Ml2AT0JFbt2sMCkhARaGWU 2HZxOiuIwyxwgkni4dLTQBkODmEBK4l/n6pATBYBVYmnXRUgvbwC7hIPvm1kg1gmJ3Hy2GTW CYzcCxgZVjFKpBYkFxQnpeca5aWW6xUn5haX5qXrJefnbmIER80z6R2Mh3e5H2IU4GBU4uGd wB0eIcSaWFZcmXuIUYKDWUmE120LUIg3JbGyKrUoP76oNCe1+BCjKdD+icxSosn5wIjOK4k3 NDE3MTc2sDC3tDQxUhLnbZz9LFxIID2xJDU7NbUgtQimj4mDU6qBkTPoZvLvKuPD4uzXuW78 /bLxUuzBKKNTbJIPLXpS7E1uCU/UWmz08YbBtR8ll00yf1ke+svHcT67dxOHQdLp4/v2bchh YfJLlsi1VHD/6aYmeq19H7uF4Ib9G+4VMPUbTOw44hNXvSkx4eS0ts9hIVX7rDZe5WQOvvvq Ple7JE+McW+j+oGpSizFGYmGWsxFxYkAsTyqCrACAAA= X-MTR: 20000000000000000@CPGS X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161219_024316_471971_440C5920 X-CRM114-Status: GOOD ( 12.21 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, jack@suse.cz, Maninder Singh , linux-kernel@vger.kernel.org, ajeet.y@samsung.com, shijie.huang@arm.com, james.morse@arm.com, sandeepa.s.prabhu@gmail.com, labbott@redhat.com, Amit Nagal , linux-arm-kernel@lists.infradead.org, pankaj.m@samsung.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP prints can delay queuing of signal, so better to print after force_sig_info. Let's say process generated SIGSEGV , and some other thread sends SIGKILL to crashing process and it gets queued before SIGSEGV becuase of little delay due to prints so in this case coredump might not generate. Signed-off-by: Maninder Singh Signed-off-by: Amit Nagal Reviewed-by: Ajeet Yadav --- arch/arm/mm/fault.c | 18 +++++++++--------- arch/arm64/mm/fault.c | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 3a2e678..f92f90b 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -163,6 +163,15 @@ void show_pte(struct mm_struct *mm, unsigned long addr) { struct siginfo si; + tsk->thread.address = addr; + tsk->thread.error_code = fsr; + tsk->thread.trap_no = 14; + si.si_signo = sig; + si.si_errno = 0; + si.si_code = code; + si.si_addr = (void __user *)addr; + force_sig_info(sig, &si, tsk); + #ifdef CONFIG_DEBUG_USER if (((user_debug & UDBG_SEGV) && (sig == SIGSEGV)) || ((user_debug & UDBG_BUS) && (sig == SIGBUS))) { @@ -172,15 +181,6 @@ void show_pte(struct mm_struct *mm, unsigned long addr) show_regs(regs); } #endif - - tsk->thread.address = addr; - tsk->thread.error_code = fsr; - tsk->thread.trap_no = 14; - si.si_signo = sig; - si.si_errno = 0; - si.si_code = code; - si.si_addr = (void __user *)addr; - force_sig_info(sig, &si, tsk); } void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs) diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c index a78a5c4..eb5d0e3 100644 --- a/arch/arm64/mm/fault.c +++ b/arch/arm64/mm/fault.c @@ -197,14 +197,6 @@ static void __do_user_fault(struct task_struct *tsk, unsigned long addr, { struct siginfo si; - if (unhandled_signal(tsk, sig) && show_unhandled_signals_ratelimited()) { - pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n", - tsk->comm, task_pid_nr(tsk), fault_name(esr), sig, - addr, esr); - show_pte(tsk->mm, addr); - show_regs(regs); - } - tsk->thread.fault_address = addr; tsk->thread.fault_code = esr; si.si_signo = sig; @@ -212,6 +204,14 @@ static void __do_user_fault(struct task_struct *tsk, unsigned long addr, si.si_code = code; si.si_addr = (void __user *)addr; force_sig_info(sig, &si, tsk); + + if (unhandled_signal(tsk, sig) && show_unhandled_signals_ratelimited()) { + pr_info("%s[%d]: unhandled %s (%d) at 0x%08lx, esr 0x%03x\n", + tsk->comm, task_pid_nr(tsk), fault_name(esr), sig, + addr, esr); + show_pte(tsk->mm, addr); + show_regs(regs); + } } static void do_bad_area(unsigned long addr, unsigned int esr, struct pt_regs *regs)