From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78465C2D0A3 for ; Tue, 10 Nov 2020 01:56:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 09269206B2 for ; Tue, 10 Nov 2020 01:56:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="v5mDWeta" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 09269206B2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=xmission.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:Message-ID:In-Reply-To:Date: References:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=I57FYKkng2NGJqqiVa4lN21MMz0ysnAd1qzCpVu4XUs=; b=v5mDWetaiSbvTjxLm/88zDIjz yIWGJVVLUXSPDcmALom9z1fhsPHEle6cbqp59pU7OXchbGAkDXvT8Himbs1jDgPaaNwzs0Ck5/KUX 2jkL8OQoLdLqEbIJW0w1B2C7ySgqc5T79FjLnRostYKEzCG12etm/bi/70CD013xA0Rab4v66ZFV4 usT6M/4glux8p0Xe6pvBwz7jCTpyhQL9PnnX+ygXD9E1h+0AlNxDMBNgs149R0vJGWrn9TrJeBqz+ qWJaqrBMjcH47XC9XuxdEvEoMwWu0D7V4CfWXdhbfZjJK+vvIIJBwp8O09eRPM4jdTszYZLEZKRJ9 8HfnV9IXw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcIsb-0001yO-2A; Tue, 10 Nov 2020 01:55:29 +0000 Received: from out02.mta.xmission.com ([166.70.13.232]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcIsX-0001wV-FZ for linux-arm-kernel@lists.infradead.org; Tue, 10 Nov 2020 01:55:26 +0000 Received: from in01.mta.xmission.com ([166.70.13.51]) by out02.mta.xmission.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1kcIrz-00Ge4e-9r; Mon, 09 Nov 2020 18:54:51 -0700 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=x220.xmission.com) by in01.mta.xmission.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.87) (envelope-from ) id 1kcIry-0003Fo-Ds; Mon, 09 Nov 2020 18:54:51 -0700 From: ebiederm@xmission.com (Eric W. Biederman) To: Peter Collingbourne References: <0eb601a5d1906fadd7099149eb605181911cfc04.1604523707.git.pcc@google.com> Date: Mon, 09 Nov 2020 19:54:41 -0600 In-Reply-To: <0eb601a5d1906fadd7099149eb605181911cfc04.1604523707.git.pcc@google.com> (Peter Collingbourne's message of "Wed, 4 Nov 2020 13:18:10 -0800") Message-ID: <878sbavuvy.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1kcIry-0003Fo-Ds; ; ; mid=<878sbavuvy.fsf@x220.int.ebiederm.org>; ; ; hst=in01.mta.xmission.com; ; ; ip=68.227.160.95; ; ; frm=ebiederm@xmission.com; ; ; spf=neutral X-XM-AID: U2FsdGVkX18QKp48VgGmpVZnr/9O10wTf/d0kgEIB6o= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH v14 7/8] signal: define the field siginfo.si_faultflags X-SA-Exim-Version: 4.2.1 (built Thu, 05 May 2016 13:38:54 -0600) X-SA-Exim-Scanned: Yes (on in01.mta.xmission.com) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201109_205525_567449_7C3419E6 X-CRM114-Status: GOOD ( 18.33 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sukadev Bhattiprolu , Michael Ellerman , Catalin Marinas , Helge Deller , Kevin Brodsky , Haren Myneni , Oleg Nesterov , linux-api@vger.kernel.org, "James E.J. Bottomley" , Kostya Serebryany , Linux ARM , Andrey Konovalov , David Spickett , Vincenzo Frascino , Will Deacon , Dave Martin , Evgenii Stepanov , Richard Henderson Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Peter you are patching buggy code for your siginfo extension can you please ignore vas-fault.c. The code in vas-fault.c should be fixed separately. Futher it uses clear_siginfo so you should get well defined behavior even if your new field is not initialized. I have copied the powerpc folks so hopefully this buggy code can be fixed. > diff --git a/arch/powerpc/platforms/powernv/vas-fault.c b/arch/powerpc/platforms/powernv/vas-fault.c > index 3d21fce254b7..877e7d5fb4a2 100644 > --- a/arch/powerpc/platforms/powernv/vas-fault.c > +++ b/arch/powerpc/platforms/powernv/vas-fault.c > @@ -154,6 +154,7 @@ static void update_csb(struct vas_window *window, > info.si_errno = EFAULT; > info.si_code = SEGV_MAPERR; > info.si_addr = csb_addr; > + info.si_faultflags = 0; Powerpc folks. This code was introduced in c96c4436aba4 ("powerpc/vas: Update CSB and notify process for fault CRBs") and is badly buggy. Let me count the bugs: a) Using kill_pid_info. That performs a permission check that does not make sense from a kernel thread. b) Manually filling in struct siginfo. Everyone gets it wrong and the powerpc code is no exception setting si_errno when that is something Linux as a rule does not do. Technically we have send_sig_fault to handle sending a fault from a non-sychrnous context but I am not convinced it make sense in this case. c) Sending an asynchronous SIGSEGV with the si_code set to SEGV_MAPERR. How can userspace detect it is an asynchronous signal? What can userspace do if it detects an asynchronous signal? If userspace is so buggered as to give your kernel thread a bogus address I suspect uncerimonious sending SIGKILL is probably the best you can do. There are some additional questionable things in that code like taking a task_struct reference simply to be able to test tsk->flags but no locks are held to ensure that tsk->flags are meaningful. Nor are any tests performed to see if the task being tested still uses the designated mm. I suspect exec could have been called. In which case the code needs to check the mm, or at least play with exec_id to ensure you are not improperly signaling a process after exec. None of this is to say that update_csb is fundmentally bad or hard to correct just that it has some significant defects in it's implementation right now that need to be corrected. I am hoping a detailed accounting and pointing out those defects will allow the bug to be fixed. Thank you, Eric _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel