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=-4.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,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 63D4DC433ED for ; Fri, 30 Apr 2021 20:02:24 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 D86936143D for ; Fri, 30 Apr 2021 20:02:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D86936143D 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Subject:MIME-Version:Message-ID:In-Reply-To:Date: References:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=evZdj6rF+mrs50EeQM1+pVSxSem7wNmvNHFfDhQsBa0=; b=IrSnTMXpPbGGKRWtvKlynjXG0 P3PaXiotci3xvabWns8U+aleYzMzxa3plYMqiGy20zE138lABM5JcBf6RGZsNrWk0abtyzzcGCfye 0qd6g/OOt/MqoLZ5QXOkBmVEVt8qzBNfSjKchLtA0cfy/pV9+RUGz6QTm82Eu6D81goRyE1qXoqaA hA39nv+5LR175DMs4k1kfz+MPQeobXfEgpC0Ul+6vvLe0K6qwHdXfl7ERvIcAYv83kYEsyFztqiwP NCZ5hy0HbdzyPobHtZNoOSMrCwhvRFrFKY6EWkjBaju2l6MN2wtN0PYjaQg9kYHzzdGdS2vs3sMBh pe0FzTiMA==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lcZHd-008Tea-0j; Fri, 30 Apr 2021 19:58:46 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lcZGt-008Tbo-1i for linux-arm-kernel@desiato.infradead.org; Fri, 30 Apr 2021 19:58:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Subject:Content-Type:MIME-Version: Message-ID:In-Reply-To:Date:References:Cc:To:From:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=htPJgIhSMiRwwlkDqxhsv8OkNcTCkw1qtlwXmjfIR4c=; b=vydaLxcqN+ooY277pZREgROCmN Z9IWJ1pwfMJh5zKcghOfQWNr+IdICq1Rt1BavIok4jutfvSkBH5pRWanS55s9DW20Psw9N1lj/pDO I4Y8D+uyDQWb8R24TwQME0i7VhNjiujppVADx1jh/9Rc4VxMoF2QZ+cx63cre3Np/7RNgTwJpEoCn b/zCEpNA/lkzkbHgQWDzSXK4/yP1Zo/cfz8LXOlZ1JOIkhFTFCBOHhTaS9oJ+rm6K0We6BPLhJcyq 0Zp+VXcMLLpPBEFNIWftEHD8nsM/m8khavIUYdf6WdhuNfyRyyAVboQdaci8s7Gk3Eixg797DJOaV U8j/ycOA==; Received: from out01.mta.xmission.com ([166.70.13.231]) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lcZGq-001dM4-0o for linux-arm-kernel@lists.infradead.org; Fri, 30 Apr 2021 19:57:53 +0000 Received: from in02.mta.xmission.com ([166.70.13.52]) by out01.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lcZGl-00CbjW-SR; Fri, 30 Apr 2021 13:57:47 -0600 Received: from ip68-227-160-95.om.om.cox.net ([68.227.160.95] helo=fess.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1lcZGk-006rml-TA; Fri, 30 Apr 2021 13:57:47 -0600 From: ebiederm@xmission.com (Eric W. Biederman) To: Liam Howlett Cc: Will Deacon , Catalin Marinas , Julien Grall , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , "linux-arm-kernel\@lists.infradead.org" , "linux-kernel\@vger.kernel.org" , "netdev\@vger.kernel.org" , "bpf\@vger.kernel.org" References: <20210420165001.3790670-1-Liam.Howlett@Oracle.com> <20210420165001.3790670-2-Liam.Howlett@Oracle.com> <20210422124849.GA1521@willie-the-truck> <20210422192349.ekpinkf3wxnmywe3@revolver> <20210423200126.otleormmjh22joj3@revolver> <20210430184757.mez7ujmyzm43g6z2@revolver> Date: Fri, 30 Apr 2021 14:57:43 -0500 In-Reply-To: <20210430184757.mez7ujmyzm43g6z2@revolver> (Liam Howlett's message of "Fri, 30 Apr 2021 18:48:08 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 X-XM-SPF: eid=1lcZGk-006rml-TA; ; ; mid=; ; ; hst=in02.mta.xmission.com; ; ; ip=68.227.160.95; ; ; frm=ebiederm@xmission.com; ; ; spf=neutral X-XM-AID: U2FsdGVkX193jyYvw9ExaIXEwhjbHkEscuNo2S9lCZ8= X-SA-Exim-Connect-IP: 68.227.160.95 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH 2/3] arm64: signal: sigreturn() and rt_sigreturn() sometime returns the wrong signals X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210430_125752_083948_D4FAABCE X-CRM114-Status: GOOD ( 17.34 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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 Liam Howlett writes: > This is way out of scope for what I'm doing. I'm trying to fix a call > to the wrong mm API. I was trying to clean up any obvious errors in > calling functions which were exposed by fixing that error. If you want > this fixed differently, then please go ahead and tackle the problems you > see. I was asked by the arm maintainers to describe what the code should be doing here. I hope I have done that. What is very interesting is that the code in __do_page_fault does not use find_vma_intersection it uses find_vma. Which suggests that find_vma_intersection may not be the proper mm api. The logic is: >From __do_page_fault: struct vm_area_struct *vma = find_vma(mm, addr); if (unlikely(!vma)) return VM_FAULT_BADMAP; /* * Ok, we have a good vm_area for this memory access, so we can handle * it. */ if (unlikely(vma->vm_start > addr)) { if (!(vma->vm_flags & VM_GROWSDOWN)) return VM_FAULT_BADMAP; if (expand_stack(vma, addr)) return VM_FAULT_BADMAP; } /* * Check that the permissions on the VMA allow for the fault which * occurred. */ if (!(vma->vm_flags & vm_flags)) return VM_FAULT_BADACCESS; >From do_page_fault: arm64_force_sig_fault(SIGSEGV, fault == VM_FAULT_BADACCESS ? SEGV_ACCERR : SEGV_MAPERR, far, inf->name); Hmm. If the expand_stack step is skipped. Does is the logic equivalent to find_vma_intersection? static inline struct vm_area_struct *find_vma_intersection( struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr) { struct vm_area_struct * vma = find_vma(mm,start_addr); if (vma && end_addr <= vma->vm_start) vma = NULL; return vma; } Yes. It does look that way. VM_FAULT_BADMAP is returned when a vma covering the specified address is not found. And VM_FAULT_BADACCESS is returned when there is a vma and there is a permission problem. There are also two SIGBUS cases that arm64_notify_segfault does not handle. So it appears changing arm64_notify_segfault to use find_vma_intersection instead of find_vma would be a correct but incomplete fix. I don't see a point in changing sigerturn or rt_sigreturn. Eric _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel