Received: by 2002:ac0:8845:0:0:0:0:0 with SMTP id g63csp570971img; Thu, 28 Feb 2019 04:30:22 -0800 (PST) X-Google-Smtp-Source: AHgI3IbyiNVddCYQ7HYGBaylYhaDQvW3EtNPUGMst8sPhv12JilCcHR2jpttT//hIszv5GODFBbb X-Received: by 2002:a63:1a25:: with SMTP id a37mr8485993pga.428.1551357021983; Thu, 28 Feb 2019 04:30:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551357021; cv=none; d=google.com; s=arc-20160816; b=hBcGLRkYPDzoZXHSrFxok+mOYCBHc5HYYl/u3w8m5OyzSKKaCx8S8DczN8e25YtN/K DmS3wwthKW7QBL3iSQ3SCVH/18cM+hhl5WTO2ykxo67Aai5m7bfNmqCxsIvpZwkiUPGt rPKtVRhbV2bEcdqX364gvPyImiVFphPfv8GI6UCw5POVScx3EKhN+iSyMW0fYdoooAY8 kVrFuWGfFQnhUW/RZOYyk0RHz4ZlfsnwPDyGKLwDsYbwNzAnSF0PIFEN/YMMI1vFGC5Q 9VhBnvFCEfbvNGqa5EfE37XC64d8RpVBd37Il5Nv3xP3GHQWsRX+ipVZt4itezOhEJfA lPmQ== 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:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=hgujtaPN0dwyDORzHmjl1KmXI6KHwUC0ogh+HWOFCOk=; b=GhrTXkhR5XgRSYPsemN2vwgmMocFjJn+emqBYOVowGus7ZXLtYK7DL8HmHqlF8Sl4z /TcJuQIUYylRzFuB6xHzlYWedniNr8vZAXGKlOQk7dfzDQC+rnhdtNu0G4hYLcdWJhhp MDKCv6uFlXyO65PesJO6Mx4N0qpMZe5aM/QCYZq1H8HzIAzvXVnvbwEeSZev7U7mQ54I ChBZ8oyYWHgTmNp+/gSsgeb3udKSPtiOIjr+LjdcoiwwhzuAeUicPe+TUNvXvA75Oq19 aTUTT/tl9jlHAx6kmabtrVjcLlAPDHrsDVSFtBpZ2IzU3u36MEDDKdmUOBWSa2j9losh ux2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="omgd/yZw"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x3si18348250pll.376.2019.02.28.04.30.06; Thu, 28 Feb 2019 04:30:21 -0800 (PST) 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=@kernel.org header.s=default header.b="omgd/yZw"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731609AbfB1M3T (ORCPT + 99 others); Thu, 28 Feb 2019 07:29:19 -0500 Received: from mail.kernel.org ([198.145.29.99]:35110 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730960AbfB1M3S (ORCPT ); Thu, 28 Feb 2019 07:29:18 -0500 Received: from devbox (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 581EA2083D; Thu, 28 Feb 2019 12:29:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551356957; bh=pNtoIm19/RbLA530zaYV92DVB139pC7B3avkF0tQ5PI=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=omgd/yZw4ojeqpb7pfcFA91qgLNCXdlJselo4cKLcltpHI98GV7a0T7uHggPLa8WA tepmvVe/uMhQ7Ro4odpHy5ahACxo867l86bYRTiVnqHP8Ty8VgAcRUnbUvBwH2kiZT MuXa1i+GYgtRKwzwksjLc6nwFE1AaJaJAJTs/bqQ= Date: Thu, 28 Feb 2019 21:29:13 +0900 From: Masami Hiramatsu To: Joel Fernandes Cc: Alexei Starovoitov , Linus Torvalds , Masami Hiramatsu , Steven Rostedt , Andy Lutomirski , will.deacon@arm.com, Linux List Kernel Mailing , Ingo Molnar , Andrew Morton , stable , Changbin Du , Jann Horn , Kees Cook , Andy Lutomirski , daniel@iogearbox.net, netdev@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH 1/2 v2] kprobe: Do not use uaccess functions to access kernel memory that can fault Message-Id: <20190228212913.20079490b3df88d285664a56@kernel.org> In-Reply-To: <20190226152447.GA99670@google.com> References: <20190219111802.1d6dbaa3@gandalf.local.home> <20190219140330.5dd9e876@gandalf.local.home> <20190220171019.5e81a4946b56982f324f7c45@kernel.org> <20190220094926.0ab575b3@gandalf.local.home> <20190222172745.2c7205d62003c0a858e33278@kernel.org> <20190222173509.88489b7c5d1bf0e2ec2382ee@kernel.org> <20190222192703.epvgxghwybte7gxs@ast-mbp.dhcp.thefacebook.com> <20190226152447.GA99670@google.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Feb 2019 10:24:47 -0500 Joel Fernandes wrote: > On Fri, Feb 22, 2019 at 11:27:05AM -0800, Alexei Starovoitov wrote: > > On Fri, Feb 22, 2019 at 09:43:14AM -0800, Linus Torvalds wrote: > > > > > > Then we should still probably fix up "__probe_kernel_read()" to not > > > allow user accesses. The easiest way to do that is actually likely to > > > use the "unsafe_get_user()" functions *without* doing a > > > uaccess_begin(), which will mean that modern CPU's will simply fault > > > on a kernel access to user space. > > > > On bpf side the bpf_probe_read() helper just calls probe_kernel_read() > > and users pass both user and kernel addresses into it and expect > > that the helper will actually try to read from that address. > > Slightly related and FWIW, BCC's eBPF-based opensnoop tool [1] installs a > kprobe on do_sys_open to monitor calls to the open syscall globally. > > do_sys_open() has prototype: > > long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode); > > This causes a "blank" filename to be displayed by opensnoop when I run it on > my Pixel 3 (arm64), possibly because this is a user pointer. However, it > works fine on x86-64. > > So it seems to me that on arm64, reading user pointers directly still doesn't > work even if there is a distinction between user/kernel addresses. In that > case reading the user pointer using user accessors (possibly using > bpf_probe_user_read helper) should be needed to fix this issue (as Yonghong > also privately discussed with me). OK, it sounds like the same issue. Please add a bpf_user_read() and use it for __user pointer. Thank you, -- Masami Hiramatsu