Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3979491ybb; Mon, 6 Apr 2020 21:03:35 -0700 (PDT) X-Google-Smtp-Source: APiQypLqwj503RLLHayHb/4kfA0CjZEdm0hfeItUAMPtfFK/ENUjEhUC1A4z5WYqs9i1UKhI98lD X-Received: by 2002:a9d:2004:: with SMTP id n4mr59509ota.74.1586232215616; Mon, 06 Apr 2020 21:03:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586232215; cv=none; d=google.com; s=arc-20160816; b=huRHfQfp9KGH2VqLoHLoDdsO9gavAmCWvH7HYOHbqJVsRaQuAf41q/RlJWx3UG9Tf+ y4sYQuVp9FQtQ+9Opi3HTyETQyUz8Kol3+6Nl4DzwpNbcLtbJN5jetltu7eid8l8XM5C f1LeQL82ltIC26dW58Qpr+jZoFm642/2G8rwvoJbJUrtQFCHO9UIArXVqkgMMbJDrfBp s0G2z+s5JHxAo1O41r1PfPQuSoJW3Vdmk4SAdtjG8xvmTJ4BTcSN7Tb45cPqaSht1vBd tuUFrFpqJ9iA+hX1Ap3jqqaxMI1oCcdOCMjNqHWco/HmHQVpGA1zO4f2jtZDvVA/aQ0+ rZuQ== 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:message-id :user-agent:mime-version:in-reply-to:references:cc:to:subject:from :date:dkim-signature; bh=VsWwfSynrS4eDpYd0Gko9iMPncgHMSVWwRU0vtKq6/k=; b=x5+kJ2MBKAq1LnkvaP1bc9Wn9BVz5VrlG41Fs9cxDDBsl8xUCwCNYezBfO7+CmAx7g 9a4fZVvqeBN2y9auBxOijc4y8XOks8Xu7XMqNO0s+Ny+UmNr9r19ajWT2vB1/q9KwTGZ /v+foxI1JgQUbsvgeipgvnDPzZPeMrjcjVLbdluHcgW/n7+zRrC0uot3R8v9iyEFhMyZ MAqaCLjvMIbjLAuTOYJuJuQ+9eP7PEbZZkOqGbpIcThCZX6ZItwwXWetwJ/yCEtEGjsd 8DJZ/Mz9I3bFHrA6moDk63AkGKy1QMViVi7pgOT6vQNMvrrbdUFmkWBz08Oek/jOdzQM q1aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L6i0zW3W; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si682025otf.248.2020.04.06.21.03.24; Mon, 06 Apr 2020 21:03:35 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=L6i0zW3W; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726399AbgDGECs (ORCPT + 99 others); Tue, 7 Apr 2020 00:02:48 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:40909 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725446AbgDGECs (ORCPT ); Tue, 7 Apr 2020 00:02:48 -0400 Received: by mail-pf1-f196.google.com with SMTP id c20so189271pfi.7; Mon, 06 Apr 2020 21:02:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :user-agent:message-id:content-transfer-encoding; bh=VsWwfSynrS4eDpYd0Gko9iMPncgHMSVWwRU0vtKq6/k=; b=L6i0zW3W5a85p7YXJdl+LTgGSw4psSAI2oViDk6KiPH5ubKBWlqlU1ihTd2inAlul6 TAS7UweJ4U2ETiUxFPYrDxWVNG64V+1MKkOH6D1cGvA8OgYl+n00AGK13Oprb3wDRxP1 OZZnTnQCAID0wbZtG7sRBEVIT6NaUunqGzKYosxjidvbe+OTJI2NUcDR5VqIGIcHvWLy ItHI0ib384o24MNKwPmzGbAUy4xO1CNsirbXhDmzmkvdjiQdQovot1M/QZLu+r+RvYmr fMiXuHJVHl8CubzTDkNEeSlRFwFaqA0vd8/zd58Kw+y0D49+eS2KHYvF8gNS30E+eO6r kipg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:user-agent:message-id:content-transfer-encoding; bh=VsWwfSynrS4eDpYd0Gko9iMPncgHMSVWwRU0vtKq6/k=; b=oWCRYCk8oIMtdxKctoCzTK94Oi7ljLg0x+JGp4ufa+CJMCPcxJUaVmK3iUiWZjT05Y VOceB8a5PQstuyZgDBdohfnB75xrjHIDGa2d5dZHEqBFfly3JipsvKxAjTQUIECVOm73 n25rohfstmdCQYj6J7+azX2S/l7TK5ELcEWS47yZtn3smMM6fo8JXNL/ns1SwSKN084U VTGmckWErvQwOAgyWPIOlwBACk/mgXIp3lt1IcGsYZq6r3/ajPlP2jcohgeUIi3wbi3c GUCrSsLbYtidPBPyisxG65wldpLeAt6tWQHQxCWZYqGKI8QLWhO/MacTTiD8CqYF8VIO cs1A== X-Gm-Message-State: AGi0Pua3nOJ3bKZfNoqC+UJILZJWr6Ugh2uaHEV/qLtdpEfw2B9apfLZ EYXMAgR64SFzJRW0eSvQGyqpJfxU X-Received: by 2002:a65:53cf:: with SMTP id z15mr86720pgr.367.1586232167036; Mon, 06 Apr 2020 21:02:47 -0700 (PDT) Received: from localhost (60-241-117-97.tpgi.com.au. [60.241.117.97]) by smtp.gmail.com with ESMTPSA id f9sm11282241pgj.2.2020.04.06.21.02.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 21:02:46 -0700 (PDT) Date: Tue, 07 Apr 2020 14:01:18 +1000 From: Nicholas Piggin Subject: Re: [PATCH v2 1/4] powerpc/64s: implement probe_kernel_read/write without touching AMR To: Christophe Leroy , linuxppc-dev@lists.ozlabs.org Cc: Alexei Starovoitov , Daniel Borkmann , 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> In-Reply-To: <1585911072.njtr9qmios.astroid@bobo.none> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1586230235.0xvc3pjkcj.astroid@bobo.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nicholas Piggin's on April 3, 2020 9:05 pm: > Christophe Leroy's on April 3, 2020 8:31 pm: >>=20 >>=20 >> Le 03/04/2020 =C3=A0 11:35, Nicholas Piggin a =C3=A9crit=C2=A0: >>> There is no need to allow user accesses when probing kernel addresses. >>=20 >> I just discovered the following commit=20 >> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commi= t/?id=3D75a1a607bb7e6d918be3aca11ec2214a275392f4 >>=20 >> This commit adds probe_kernel_read_strict() and probe_kernel_write_stric= t(). >>=20 >> When reading the commit log, I understand that probe_kernel_read() may=20 >> be used to access some user memory. Which will not work anymore with=20 >> your patch. >=20 > Hmm, I looked at _strict but obviously not hard enough. Good catch. >=20 > 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. >=20 > I think it's wrong. The non-_strict maybe could return userspace data to=20 > you if you did pass a user address? I don't see why that shouldn't just=20 > be disallowed always though. >=20 > 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. >=20 > 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=20 return -EFAULT or it might cause a kernel warning. The _strict variant=20 is supposed to be usable with any address and it will return -EFAULT if=20 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. Thanks, Nick =