Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp865758pxb; Thu, 5 Nov 2020 15:26:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnJ4o4Imwx0pItuKdZEfUnva4kTvO2cM2v22tr8Q6/KgPgXAel2dEdhZsmhEPDvl8WHyq2 X-Received: by 2002:a50:c058:: with SMTP id u24mr5273844edd.28.1604618763953; Thu, 05 Nov 2020 15:26:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604618763; cv=none; d=google.com; s=arc-20160816; b=VjQiExFbO+fb+tiJgqSqFVTlQ4l8JWd+xkb7CzDg4Cc0z1COkgN39MQlLmwvkadXbM e5wKBUWihhPJJgF5Q4uvzo964kQdgg5M0dtsEqtOHNXOBxX5oi0ELRZQSeexGuUXM/1f OCTkir9HolbpYsI8tAdXZ7kkpS6Bag/4R/7jluJ1T3aBlZ8ptL+kROP5rgds0RXnuGgx 7wrM+iXR5ezWkkTv80GOnon715q7SU8fDT3ZY9VlwqkSbHF99XcftErZmKYCz9784Nf5 QLcOcaoxzqvW18P+RFxVmDxQeH78uLhv9yE0sl3p+zPrgl8sFYKv24FX2vQnJxWEr6wI tKuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:message-id:date:subject:cc:to:from :content-transfer-encoding:mime-version:dkim-signature :dkim-signature; bh=duLADp0L3t3dhlQghBrp1HNXQG5rMH4wSnK4U3OyB4g=; b=Wo2aDaVrAwlmZyPFkQk/TbDD2gBZHffkBe+7mgYAp8JlEpwcDWrxPWpNAMUrr/ambT NMy4r+j53DyP/1INdw1RA/lCuS2S+AwHMwX5aXT61kpbEEzxDabyrAhHJYhPatK2pXTD p4u82mkRkUuqDK2ZGKOG7ItHbCIoRB/eSNKy5uQGhG4QqFl1LBscTKon2GRuMU9Ru6ZL 9VXguVwHk+pxyjpl5ZNSpIzO1nMqX4rWffxzniF3XtzXCbyU8xsHm4lsRfTAzBntPaQi e8n+D+YEK6uG8g1Q4k59Q5UKpjqg5EYrLPiJ8fu7Hf8q846CZJaIxnd36qBiouroLJIU b+/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm1 header.b="QQ1R/Xwz"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ndEotHKT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 89si2172019edy.301.2020.11.05.15.25.41; Thu, 05 Nov 2020 15:26:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@dxuuu.xyz header.s=fm1 header.b="QQ1R/Xwz"; dkim=pass header.i=@messagingengine.com header.s=fm1 header.b=ndEotHKT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732409AbgKEXXU (ORCPT + 99 others); Thu, 5 Nov 2020 18:23:20 -0500 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:54149 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729162AbgKEXXU (ORCPT ); Thu, 5 Nov 2020 18:23:20 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id DB9535C0184; Thu, 5 Nov 2020 18:23:18 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Thu, 05 Nov 2020 18:23:18 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dxuuu.xyz; h= mime-version:content-transfer-encoding:content-type:from:to:cc :subject:date:message-id:in-reply-to; s=fm1; bh=duLADp0L3t3dhlQg hBrp1HNXQG5rMH4wSnK4U3OyB4g=; b=QQ1R/XwzQqz9hAAuvTmI5vXA5rBueQNr QB5dskuIAlch9HBUjzUmZW30cIM44/z19jZzXT9iaJotK8e/s8D7vwQiIfPKx1QB dx6Ybu/q3/zDMM9OFGuJ4XJLfrXzfnRL7jwIfOZ37g4DZ8IfJCkzJB3Xt3DQs3Iq SCrIBxC1wid4hdKkmXqd6XxYi/0WsZ4S7aGyM/QT9NZnGqrCVXUwamOeYiy8RTjg z33phN80Ympi7EzChLWa0l3/IvqaIXRVaxrowyHxsa1rQ1pwiDd3So/Dj13g/0gG dbuJsGXYPHhHNx20L28M3BKRC67xaeAxknrpGgFWIcBRpIchP3j3oQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=duLADp0L3t3dhlQghBrp1HNXQG5rMH4wSnK4U3OyB4g=; b=ndEotHKT txmyrnVFRLQAfdPUSMO2Jv/u399aoxZdELvhTUR4T8ciUpKzB+j7/BSXeMv0R/iA MamGFz41Y/s6DMXfvovgvtxut11JVlO9S1Bv3WNLbkf3PjlSSlh+ViHopZLH4kcu /qu0xqSdh93WnDRzZj1sBG80q28Zh48+RdmOWq0j1asoLRsD8HP+ZxEnzlDCZ7ON eSFfnu0LRqeBMdk/oZWa9OKgtSIvgEC/PxupgWPrUuGmfeQQ1zBUnkTDg9pIbYCg Tt8ZvBdiUdMwYrYBjp7t02L1cxBpZjFSBBhC7WKT1Fx5F9M6VfsK8Tn6uB2/jzYl dLGIwiZo5v37mQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddtkedguddtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpegggfgthffvufffkfgjsehtqhertddttdej necuhfhrohhmpedfffgrnhhivghlucgiuhdfuceougiguhesugiguhhuuhdrgiihiieqne cuggftrfgrthhtvghrnhepueefieduveffuddtheethfeiveegtddukeffleelledutdef gfdtffduhfeuffejnecukfhppeeiledrudekuddruddthedrieegnecuvehluhhsthgvrh fuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepugiguhesugiguhhuuhdrgiih ii X-ME-Proxy: Received: from localhost (c-69-181-105-64.hsd1.ca.comcast.net [69.181.105.64]) by mail.messagingengine.com (Postfix) with ESMTPA id DB4DA328038B; Thu, 5 Nov 2020 18:23:17 -0500 (EST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 From: "Daniel Xu" To: "Andrii Nakryiko" Cc: "bpf" , "open list" , "Alexei Starovoitov" , "Daniel Borkmann" , "Kernel Team" Subject: Re: [PATCH bpf v2 2/2] selftest/bpf: Test bpf_probe_read_user_str() strips trailing bytes after NUL Date: Thu, 05 Nov 2020 15:22:34 -0800 Message-Id: In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu Nov 5, 2020 at 1:32 PM PST, Andrii Nakryiko wrote: > On Wed, Nov 4, 2020 at 8:51 PM Daniel Xu wrote: [...] > > diff --git a/tools/testing/selftests/bpf/progs/test_probe_read_user_str= .c b/tools/testing/selftests/bpf/progs/test_probe_read_user_str.c > > new file mode 100644 > > index 000000000000..41c3e296566e > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/progs/test_probe_read_user_str.c > > @@ -0,0 +1,34 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > + > > +#include > > +#include > > +#include > > + > > +#include > > + > > +struct sys_enter_write_args { > > + unsigned long long pad; > > + int syscall_nr; > > + int pad1; /* 4 byte hole */ > > I have a hunch that this explicit padding might break on big-endian > architectures?.. > > Can you instead include "vmlinux.h" in this file and use struct > trace_event_raw_sys_enter? you'll just need ctx->args[2] to get that > buffer pointer. > > Alternatively, and it's probably simpler overall would be to just > provide user-space pointer through global variable: > > void *user_ptr; > > > bpf_probe_read_user_str(buf, ..., user_ptr); > > From user-space: > > skel->bss->user_ptr =3D &my_userspace_buf; > > Full control. You can trigger tracepoint with just an usleep(1), for > instance. Yeah, that sounds better. I'll send a v4 with passing a ptr. Thanks, Daniel [...]