Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1445957yba; Sun, 5 May 2019 06:34:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwkwWIDvcKzCdUyW8KAv/fzJvca3Rt/gJNFLJXXr9F1v3sT5BzpAyREYYcznGiHPl1qpwzc X-Received: by 2002:a17:902:5a81:: with SMTP id r1mr24514055pli.147.1557063294649; Sun, 05 May 2019 06:34:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557063294; cv=none; d=google.com; s=arc-20160816; b=EsfhonS1e4F18H9ufCP99K8KHSZv2hrp5g8JD9ZyQD0b1c8M0kZ/v9W43hC6kZKhpq 54wtv7cV8/adLtNY98G3OS8CZJJdNeD19gUV8pHmnVrOGOymnNJr6nw8hJ0DaAyqtw8w B0Bsl/hCqrSp+y2b/L4U5EHJ/gXmqHZDpcHqb1Pn7fNMJh56UwiKaQBomob+pzNjnmlI fWdgY1g5tQDda7uQtYS2OqBaIPQrVU4sTvDY4ljsgkKgBQe9mvwcej+GlKnszizMPUti +Wm1eZVJDQWMY6TzO91AIUl6/Gw7mbWR/jh37fLMclDi2eEH0Y6obfDkuTbVW/d4kA9w mNMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=8vh9GzL6Z3TESI/K8Xe7IDmt4lW4rJ2TS6d8Gg9f4ec=; b=X1aL2ty6ONj0UBnphZZ0CMGzudzjSKgubrXOk9nCogxM78MERC2beCGsjvmmETk4Zm Qig/NWtX9MhOzYYlPJxqfh7gzC9+oGmgsdSdvWrHCKp5ctS3DeuGTEHgDC0PyAA5mqpn MMtojqDWfjafSx0+lu4qqKJfXi0/FdvmnxZUgsNC5EbiUgXvyn2Pgcb3fpqIY9Jxlnvl eCl73yUXLMtJ0wASyr1xVZ81QSKHYzm/uU/uusDL58uHQM9jLo7bgv9osigSSgN/ZKom 01d9RF0pcuEf66xJpPQzTjzRB/+n2RpsKqd7ozoLxW13EuBAhp+tk3h1GKvvaqYwPFdO 41sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=M+OUTlMv; 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 h3si11019778pgg.83.2019.05.05.06.34.38; Sun, 05 May 2019 06:34: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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=M+OUTlMv; 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 S1727802AbfEENdq (ORCPT + 99 others); Sun, 5 May 2019 09:33:46 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:44197 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725873AbfEENdq (ORCPT ); Sun, 5 May 2019 09:33:46 -0400 Received: by mail-qt1-f195.google.com with SMTP id f24so1465468qtk.11 for ; Sun, 05 May 2019 06:33:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=8vh9GzL6Z3TESI/K8Xe7IDmt4lW4rJ2TS6d8Gg9f4ec=; b=M+OUTlMvvZ88jH6CNuww2buF0wxPz/6/FyF26etHaJ7ads1jgfn2rS5KA/IggKuCiu d5PlVyD6rNhxPiGnCzrrAbPGJkW2aSWXx8nKyGn3XiIe97TXbZnZWcH2GqnTn7P1eY4s Hhs3bavkmsu1/D4xik3PSsJGHYede+vjcqdQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=8vh9GzL6Z3TESI/K8Xe7IDmt4lW4rJ2TS6d8Gg9f4ec=; b=hb5Lr7jm0gCSi97+KUCcpxz5HB0jhgrwXqRXLpO9lRjdiUwm5yyjsAp1QO2fkFXe4p U8tSHBVcLmZoqH2rAH+DLlVbJu9hRyRXcIckQbBR82ahtr40QGcZXaSfG4y7vOy2onzq gVU7qHp1pDWvFnEHez7BL2KHj5yz6Sckb0IIvgalGTKcNc8cawbBSFRx6/iWg4CXM+Db YouXLokWdMJ+FnCvzJEtfAx+dUezr/1kdo9sN/nk7BRPnf1xw0Cbi/ihyuUJ3A6lnHVC tc1RslSbOhsuYwqNCjbuXaxOBG7m9e47E1Hxm9o0SkW9Zt5fpTruN1EK0ukX5KJWOEV6 sMDA== X-Gm-Message-State: APjAAAWuyqB5YDy0IwKgllg0xlIOx4NHW8dZVBRsxUSXnZKBgOF/Y1B5 uAubfuhie9lP1qqI9+rp8bMWFA== X-Received: by 2002:ac8:6b11:: with SMTP id w17mr4479401qts.285.1557063225078; Sun, 05 May 2019 06:33:45 -0700 (PDT) Received: from localhost (c-73-216-90-110.hsd1.va.comcast.net. [73.216.90.110]) by smtp.gmail.com with ESMTPSA id o55sm6298213qtj.14.2019.05.05.06.33.43 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sun, 05 May 2019 06:33:44 -0700 (PDT) Date: Sun, 5 May 2019 13:33:42 +0000 From: Joel Fernandes To: Alexei Starovoitov Cc: LKML , Michal Gregorczyk , Adrian Ratiu , Mohammad Husain , Qais Yousef , Srinivas Ramana , duyuchao , Manjo Raja Rao , Karim Yaghmour , Tamir Carmeli , Yonghong Song , Alexei Starovoitov , Brendan Gregg , Masami Hiramatsu , Peter Ziljstra , Steven Rostedt , Kees Cook , Android Kernel Team , Daniel Borkmann , Ingo Molnar , Network Development Subject: Re: [PATCH RFC] bpf: Add support for reading user pointers Message-ID: <20190505133342.GC3076@localhost> References: <20190502204958.7868-1-joel@joelfernandes.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, May 05, 2019 at 12:19:42AM -0700, Alexei Starovoitov wrote: > On Thu, May 2, 2019 at 1:50 PM Joel Fernandes (Google) > wrote: > > > > The eBPF based opensnoop tool fails to read the file path string passed > > to the do_sys_open function. This is because it is a pointer to > > userspace address and causes an -EFAULT when read with > > probe_kernel_read. This is not an issue when running the tool on x86 but > > is an issue on arm64. This patch adds a new bpf function call based > > which calls the recently proposed probe_user_read function [1]. > > Using this function call from opensnoop fixes the issue on arm64. > > > > [1] https://lore.kernel.org/patchwork/patch/1051588/ > ... > > +BPF_CALL_3(bpf_probe_read_user, void *, dst, u32, size, const void *, unsafe_ptr) > > +{ > > + int ret; > > + > > + ret = probe_user_read(dst, unsafe_ptr, size); > > + if (unlikely(ret < 0)) > > + memset(dst, 0, size); > > + > > + return ret; > > +} > > probe_user_read() doesn't exist in bpf-next > therefore this patch has to wait for the next merge window. > At the same time we would need to introduce > bpf_probe_read_kernel() and introduce a load time warning > for existing bpf_probe_read(), so we can deprecate it eventually. Ok I will update it accordingly. Agreed. thanks, - Joel