Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4173634ybb; Tue, 7 Apr 2020 02:11:54 -0700 (PDT) X-Google-Smtp-Source: APiQypJas9l57TO2dFbFlsWHWL+ykSgQ0wuq5LgVoa4KTtuLkpGsdSALsx5RNi7it8O36jfsMJsS X-Received: by 2002:aca:4cc9:: with SMTP id z192mr921945oia.134.1586250714182; Tue, 07 Apr 2020 02:11:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586250714; cv=none; d=google.com; s=arc-20160816; b=SwOT/hEFBtPixKehT1zpB6m7bXBaw0LYshMIHjPbCSno9gm/hOSBAq35TltrTXN6Fo brxgIjhYLx2W+VwdcdNCz6+Td4fni0zevu4BgYZW5vu+l5kdrbmFKiOlXTRd79Jui8Wr mNDIlGygDkBylbV9eBPSFnTeqAKU7bd0rEGPpEbWtjjvZXEw2KtdPog5wXJwLWxdWPoi ficZL2e6dPzQYgXrhBYXLiEf0CrwiSRWGdiI5XcrLBDr4O5y/g65iHVBAgy41mX09f1t DSNgIMbJtSHCcljHOwNv2mNiEWqdGHkc0x8JGBL6is6Vsa3ZUZaG/uHNW6slZgSeWfqs EzLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ex64JD+AtzRAieGJUs7MiuEIXCOQnaFWxBhWyK8/smo=; b=wGM4woD/geYwvLQDBMvSELRsY6lMkhGek453dQjKw/lbIja78yVcOpn2aPZ9Flq6/G LHPa1baYOVoW6D3Nn5gcWiHHlD01tTzpVMDsbaeDc2pjPRD32kgSt6bQxp0d4pm0tO/r 4dLiSfn4PYnFoeUP24dv1+bZCpB3KvBITXln/hVQQbOVo3ZgBvOq1XFNWIrG8m7/0dRC Y08W5gT9Xu+KyBV4nk9P2HawuMk27uT9IMKLR7hz4IOgeRTR2i5hZPid002PMixLKIKF CxFXr9195gvGdZQgfmYximGlZp1XqJjMwWsyZ851/n2CQ+W3mxShIRNUoa+QiIx9fEx5 pGOA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d1si948217oth.18.2020.04.07.02.11.41; Tue, 07 Apr 2020 02:11:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727687AbgDGJJ7 (ORCPT + 99 others); Tue, 7 Apr 2020 05:09:59 -0400 Received: from www62.your-server.de ([213.133.104.62]:46680 "EHLO www62.your-server.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725817AbgDGJJ7 (ORCPT ); Tue, 7 Apr 2020 05:09:59 -0400 Received: from sslproxy06.your-server.de ([78.46.172.3]) by www62.your-server.de with esmtpsa (TLSv1.2:DHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89_1) (envelope-from ) id 1jLkEy-00032R-Aa; Tue, 07 Apr 2020 11:09:52 +0200 Received: from [178.195.186.98] (helo=pc-9.home) by sslproxy06.your-server.de with esmtpsa (TLSv1.3:TLS_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jLkEx-000KHk-Um; Tue, 07 Apr 2020 11:09:52 +0200 Subject: Re: [PATCH v2 1/4] powerpc/64s: implement probe_kernel_read/write without touching AMR To: Nicholas Piggin , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Cc: Alexei Starovoitov , linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Masami Hiramatsu , Linus Torvalds , x86@kernel.org References: <20200403093529.43587-1-npiggin@gmail.com> <558b6131-60b4-98b7-dc40-25d8dacea05a@c-s.fr> <1585911072.njtr9qmios.astroid@bobo.none> <1586230235.0xvc3pjkcj.astroid@bobo.none> From: Daniel Borkmann Message-ID: Date: Tue, 7 Apr 2020 11:09:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 In-Reply-To: <1586230235.0xvc3pjkcj.astroid@bobo.none> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Authenticated-Sender: daniel@iogearbox.net X-Virus-Scanned: Clear (ClamAV 0.102.2/25774/Mon Apr 6 14:53:25 2020) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hey Nicholas, On 4/7/20 6:01 AM, Nicholas Piggin wrote: > Nicholas Piggin's on April 3, 2020 9:05 pm: >> Christophe Leroy's on April 3, 2020 8:31 pm: >>> Le 03/04/2020 à 11:35, Nicholas Piggin a écrit : >>>> There is no need to allow user accesses when probing kernel addresses. >>> >>> I just discovered the following commit >>> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=75a1a607bb7e6d918be3aca11ec2214a275392f4 >>> >>> This commit adds probe_kernel_read_strict() and probe_kernel_write_strict(). >>> >>> When reading the commit log, I understand that probe_kernel_read() may >>> be used to access some user memory. Which will not work anymore with >>> your patch. >> >> Hmm, I looked at _strict but obviously not hard enough. Good catch. >> >> I don't think probe_kernel_read() should ever access user memory, >> the comment certainly says it doesn't, but that patch sort of implies >> that they do. >> >> I think it's wrong. The non-_strict maybe could return userspace data to >> you if you did pass a user address? I don't see why that shouldn't just >> be disallowed always though. >> >> And if the _strict version is required to be safe, then it seems like a >> bug or security issue to just allow everyone that doesn't explicitly >> override it to use the default implementation. >> >> Also, the way the weak linkage is done in that patch, means parisc and >> um archs that were previously overriding probe_kernel_read() now get >> the default probe_kernel_read_strict(), which would be wrong for them. > > The changelog in commit 75a1a607bb7 makes it a bit clearer. If the > non-_strict variant is used on non-kernel addresses, then it might not > return -EFAULT or it might cause a kernel warning. The _strict variant > is supposed to be usable with any address and it will return -EFAULT if > it was not a valid and mapped kernel address. > > The non-_strict variant can not portably access user memory because it > uses KERNEL_DS, and its documentation says its only for kernel pointers. > So powerpc should be fine to run that under KUAP AFAIKS. > > I don't know why the _strict behaviour is not just made default, but > the implementation of it does seem to be broken on the archs that > override the non-_strict variant. Yeah, we should make it default and only add a "opt out" for the old legacy cases; there was also same discussion started over here just recently [0]. Thanks, Daniel [0] https://lore.kernel.org/lkml/20200403133533.GA3424@infradead.org/T/