From patchwork Tue Jul 31 00:56:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivan Delalande X-Patchwork-Id: 10549737 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E82390E3 for ; Tue, 31 Jul 2018 00:56:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 392B22AA31 for ; Tue, 31 Jul 2018 00:56:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2B6832AA3B; Tue, 31 Jul 2018 00:56:18 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6A3B2AA31 for ; Tue, 31 Jul 2018 00:56:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731506AbeGaCdx (ORCPT ); Mon, 30 Jul 2018 22:33:53 -0400 Received: from mx.aristanetworks.com ([162.210.129.12]:52618 "EHLO prod-mx.aristanetworks.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727010AbeGaCdx (ORCPT ); Mon, 30 Jul 2018 22:33:53 -0400 Received: from prod-mx.aristanetworks.com (localhost [127.0.0.1]) by prod-mx.aristanetworks.com (Postfix) with ESMTP id 7C9041288; Mon, 30 Jul 2018 17:56:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=Arista-A; t=1532998575; bh=6onkBq6Ikvtnr7OaObXrWdNoJwf+AYgkJnkrXLuKW+U=; h=Date:From:To:Cc:Subject; b=we3PkLaOfssl/Vi5WiGWhsyVJMkj5GqztUtTqP3L0mgUal9nAESDspD0+eMe0O4uF mkxGhZ/Z83m4CDnWBQmW2ja0BOtB0+35DIpKTluq1jZebfm0ygbSIah0/owQKb0aK1 /c++nF8xlWFfpMeHp3va7EAYPoNExD5cFIa4xvcO/IeAtsgpWgqynt37IVaNlDk2Pw dwok5xJ562JwwIeH/GTMhlM42H6Wy/0ZdwUlQA1G2DmXppWj6M0uk+At0Fz+tOb1AZ 4RE/Jh5zVXDRlyhYbJH2yjFSxZERNXFxLQ/qBo7G2P4T4g1KJKyadJK1arD7yP2H65 MQZQbijGQWGTg== Received: from visor (unknown [172.20.208.17]) by prod-mx.aristanetworks.com (Postfix) with ESMTP id 7A5A81209; Mon, 30 Jul 2018 17:56:15 -0700 (PDT) Date: Mon, 30 Jul 2018 17:56:15 -0700 From: Ivan Delalande To: Al Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH RESEND] exec: don't force_sigsegv processes with a pending fatal signal Message-ID: <20180731005615.GA2911@visor> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP We were seeing unexplained segfaults in coreutils processes and other basic utilities that we tracked down to binfmt_elf failing to load segments for ld.so. Digging further, the actual problem seems to occur when a process gets sigkilled while it is still being loaded by the kernel. In our case when _do_page_fault goes for a retry it will return early as it first checks for fatal_signal_pending(), so load_elf_interp also returns with error and as a result search_binary_handler will force_sigsegv() which is pretty confusing as nothing actually failed here. Fixes: 19d860a140be ("handle suicide on late failure exits in execve() in search_binary_handler()") Reference: https://lkml.org/lkml/2013/2/14/5 Signed-off-by: Ivan Delalande --- fs/exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/exec.c b/fs/exec.c index bdd0eacefdf5..6e8007edbb2d 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1656,7 +1656,8 @@ int search_binary_handler(struct linux_binprm *bprm) if (retval < 0 && !bprm->mm) { /* we got to flush_old_exec() and failed after it */ read_unlock(&binfmt_lock); - force_sigsegv(SIGSEGV, current); + if (!fatal_signal_pending(current)) + force_sigsegv(SIGSEGV, current); return retval; } if (retval != -ENOEXEC || !bprm->file) {