Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp444853iob; Wed, 18 May 2022 05:47:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJybtbcAEc9LCOaFV004PtKunt40jnk8IIiElSwbEa3wiDKVqE0YaetsD9AKlk+KxApnIE X-Received: by 2002:a63:2f47:0:b0:3c6:a5fc:8f8d with SMTP id v68-20020a632f47000000b003c6a5fc8f8dmr23898009pgv.327.1652878021523; Wed, 18 May 2022 05:47:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652878021; cv=none; d=google.com; s=arc-20160816; b=krV9D6WEoMCtynlKSigU+K4CdfscqPXogoUOmU2C9HwkAw6kvw/VDmjVuLP1EhfqUG 5KQD4EshWI+OrE+wP6kZt/q3fFKAe+35I/mHnZvLd8dQj1u3owCHBC3U34clWUDfTxVm rsF5WLjvWE9WvQ21ZszL4qNe2LimX5BwbmV+XHrpTCYQPokTjE3adV8hWelx0f8/R/m5 4Nx8bO1ZnkJ0Dt1aSGt2/7aWnhYBHwZcPgTS1XuYTrq3YVmsqegwrPB7N/p3FeMCBcsP ZYX5WuCBqoukUximDo2zxaKOSxgxXOuBi3hR9xVNzYQmHYEuJJ0NYMPwNzLushLshmrx t3aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=2LCFQ3BaiAODg52eVM1mGg1zRamZE6jNoZ6Ptxb2fNI=; b=jGv2CgOajok9n6gWlcn4tZ+HYNQpD1w0dc72uGthhNENv1jg8dgVBauXZsS5ItaQ7/ pi1zapxOdJQ3e4xj3SswkhmydtdWSC2o5N4BESG7UjsZK7hM30CHPtyHhTeOHWuJG+k5 fgg9anNdXeq6CyEfK5EBdY6GkVDkVef416S4Ldnw+kpTHYwuPwN5K+EOA0GAc2TnIBU8 VlGc3AALIaJv9VnzGRL5ECFxXHQJpMZqSe0GwYyw/Jdfo0SU34Yit/s4rlXFeeCc80Z0 kVTxEKnWLzRPyKmNLoqAD2dL+AYb9Z/xeufbZSCUm4Hn9KPJSrHr3GccAbbpyAp99dFM +R+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=InxmeWFn; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n10-20020a638f0a000000b003f5dc34d3a9si2347272pgd.799.2022.05.18.05.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 May 2022 05:47:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=InxmeWFn; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4E088174939; Wed, 18 May 2022 05:40:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238185AbiERMiI (ORCPT + 99 others); Wed, 18 May 2022 08:38:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237074AbiERMew (ORCPT ); Wed, 18 May 2022 08:34:52 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B0E2519CB70 for ; Wed, 18 May 2022 05:30:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652877035; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=2LCFQ3BaiAODg52eVM1mGg1zRamZE6jNoZ6Ptxb2fNI=; b=InxmeWFn/13zeF7RpWsPz2G0icYldRDFBCV3nICqaigL4K5YUsQGVEtpZ0fcorfrbQ7jg4 a5cIMwRdqsXYTb3An/arbzuutkUZ//q0hQtNym3I8ubRcLo7Jtf6pm6HH+yvJJZ6M+q/S7 TBI+xDBf3Rx1AoZECmw1oWXDYIqjrCU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-627-YxyU2fNjOvaFcC_5G4hFKw-1; Wed, 18 May 2022 08:30:32 -0400 X-MC-Unique: YxyU2fNjOvaFcC_5G4hFKw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 235FD86B8A2; Wed, 18 May 2022 12:30:31 +0000 (UTC) Received: from asgard.redhat.com (unknown [10.36.110.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5779C7C2A; Wed, 18 May 2022 12:30:25 +0000 (UTC) Date: Wed, 18 May 2022 14:30:22 +0200 From: Eugene Syromiatnikov To: Jiri Olsa Cc: Yonghong Song , Masami Hiramatsu , Steven Rostedt , Ingo Molnar , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan , linux-kselftest@vger.kernel.org Subject: Re: [PATCH bpf-next v3 4/4] bpf_trace: pass array of u64 values in kprobe_multi.addrs Message-ID: <20220518123022.GA5425@asgard.redhat.com> References: <6ef675aeeea442fa8fc168cd1cb4e4e474f65a3f.1652772731.git.esyr@redhat.com> <20220517123050.GA25149@asgard.redhat.com> <7c5e64f2-f2cf-61b7-9231-fc267bf0f2d8@fb.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 18, 2022 at 01:24:56PM +0200, Jiri Olsa wrote: > On Tue, May 17, 2022 at 02:34:55PM -0700, Yonghong Song wrote: > > On 5/17/22 1:03 PM, Jiri Olsa wrote: > > > On Tue, May 17, 2022 at 02:30:50PM +0200, Eugene Syromiatnikov wrote: > > > > On Tue, May 17, 2022 at 11:12:34AM +0200, Jiri Olsa wrote: > > > > > On Tue, May 17, 2022 at 09:36:47AM +0200, Eugene Syromiatnikov wrote: > > > > > > With the interface as defined, it is impossible to pass 64-bit kernel > > > > > > addresses from a 32-bit userspace process in BPF_LINK_TYPE_KPROBE_MULTI, > > > > > > which severly limits the useability of the interface, change the ABI > > > > > > to accept an array of u64 values instead of (kernel? user?) longs. > > > > > > Interestingly, the rest of the libbpf infrastructure uses 64-bit values > > > > > > for kallsyms addresses already, so this patch also eliminates > > > > > > the sym_addr cast in tools/lib/bpf/libbpf.c:resolve_kprobe_multi_cb(). > > > > > > > > > > so the problem is when we have 32bit user sace on 64bit kernel right? > > > > > > > > > > I think we should keep addrs as longs in uapi and have kernel to figure out > > > > > if it needs to read u32 or u64, like you did for symbols in previous patch > > > > > > > > No, it's not possible here, as addrs are kernel addrs and not user space > > > > addrs, so user space has to explicitly pass 64-bit addresses on 64-bit > > > > kernels (or have a notion whether it is running on a 64-bit > > > > or 32-bit kernel, and form the passed array accordingly, which is against > > > > the idea of compat layer that tries to abstract it out). > > > > > > hum :-\ I'll need to check on compat layer.. there must > > > be some other code doing this already somewhere, right? > > so the 32bit application running on 64bit kernel using libbpf won't > work at the moment, right? because it sees: > > bpf_kprobe_multi_opts::addrs as its 'unsigned long' > > which is 4 bytes and it needs to put there 64bits kernel addresses > > if we force the libbpf interface to use u64, then we should be fine Yes, that's correct. > > I am not familiar with all these compatibility thing. But if we > > have 64-bit pointer for **syms, maybe we could also have > > 64-bit pointer for *syms for consistency? > > right, perhaps we could have one function to read both syms and addrs arrays The distinction here it that syms are user space pointers (so they are naturally 32-bit for 32-bit applications) and addrs are kernel-space pointers (so they may be 64-bit even when the application is 32-bit). Nothing prevents from changing the interface so that syms is an array of 64-bit values treated as user space pointers, of course. > > > > > we'll need to fix also bpf_kprobe_multi_cookie_swap because it assumes > > > > > 64bit user space pointers > > if we have both addresses and cookies 64 then this should be ok > > > > > > > > > > > would be gret if we could have selftest for this > > let's add selftest for this Sure, I'll try to write one.