Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3084944iob; Mon, 16 May 2022 12:44:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9jDoYlg/s5a0hJ3hyEw9+P7R6wFbE67PviJVzAfe3+HWXbGV2xE32XKdfh/66FLfrXxig X-Received: by 2002:a17:907:7242:b0:6f5:2ca3:f1cd with SMTP id ds2-20020a170907724200b006f52ca3f1cdmr17029124ejc.480.1652730262274; Mon, 16 May 2022 12:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652730262; cv=none; d=google.com; s=arc-20160816; b=eZDlQU+4pFgB8540FtvBUAgRK3inWMqz5IS1IQLeWaxYioeodapffY0+oTHEgZClEs QeuQM2JPykXy6s/3gDwjbPn1KftmNr8QEks6I3b/znVPk75fOBPWho1F68xcEFwkiLKJ b+zbYqkarRp7DuW2DT8ujhyx/+XiJCQqwQvU9Y0oeT7L08xgS+VVGp5Uv/oq/ZQVTaJc +2EXLcorHaGb4MWZ0f2mt1phIxcDRBxm9hyvrJStSCQ6PlE0jlZJj7NBZEIjBcCFOmyj LCz4RTgVwUdGJpIady6rEkKvY2OrJ/QOV0buLUCZQ3PxpBt4S23mJ5SBJKjjj/O/oVuc uKbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:content-disposition:mime-version :message-id:subject:cc:to:from:date:dkim-signature; bh=id00oVYTmyhqPqdSLuA7jfzPXEfe8AjRZdJymH4RAy0=; b=WWaW3gawATOs1XIsWcxuC/Y/xYU2r7tmrw4EmEmpq81jcDlAzFDHUCYEG8y/9+64qE DZA3Yg4WsI6rDvoaNJ7VPGWaKayqwuf5hShQom82x9haK9cqRZRcjjDWG0IZSuufAoZ9 7KBXkXWqFFDTYNaF2R31l+NG8zZwlZmUDI2w/SGI/S4lJAxoaRjTgpL7y2XYFIrHE2cd y4HZhVRpN87uGyS3+xCEY8LjkMaKMWymqiVQpGOy/3fB5GsQzP4iaP6RpsW8+UWs1XPB vt6p8A7jkkiQciDVjdpKbFmAW4V1G1V6CFCPLj2I7MF6XMTxriCdkkro5pSOEPW58rPv DsSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CU9kloDj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id tc28-20020a1709078d1c00b006f47e87800csi227757ejc.706.2022.05.16.12.43.56; Mon, 16 May 2022 12:44:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CU9kloDj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344736AbiEPSYV (ORCPT + 99 others); Mon, 16 May 2022 14:24:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344734AbiEPSYU (ORCPT ); Mon, 16 May 2022 14:24:20 -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 305043DA49 for ; Mon, 16 May 2022 11:24:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652725458; 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; bh=id00oVYTmyhqPqdSLuA7jfzPXEfe8AjRZdJymH4RAy0=; b=CU9kloDjTur+UsHLa/lQx06hotExcPeb56e4xyDxRirMK9czNbkgdKV/NSPFBET+pVKvq9 FCOvIWtyhr5j0swslJOT4yANX6hQnKHkMfEevJgQo+/T66TpamEDUkOTauCsm0d2UNL8Dh e/Y8mZ2B+4o3ytxLvl2PwR7pW4wJoic= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-425-1c6qYXoiM3aIcpzbJ6od5Q-1; Mon, 16 May 2022 14:24:14 -0400 X-MC-Unique: 1c6qYXoiM3aIcpzbJ6od5Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C9167382ECC8; Mon, 16 May 2022 18:24:13 +0000 (UTC) Received: from asgard.redhat.com (unknown [10.36.110.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 61FD7153B8AC; Mon, 16 May 2022 18:24:10 +0000 (UTC) Date: Mon, 16 May 2022 20:24:07 +0200 From: Eugene Syromiatnikov To: Jiri Olsa , Masami Hiramatsu , Steven Rostedt , Ingo Molnar , Alexei Starovoitov , Daniel Borkmann Cc: Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH bpf 0/4] Fix 32-bit arch and compat support for the kprobe_multi attach type Message-ID: <20220516182407.GA15250@asgard.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham 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 As suggested in [1], the kprobe_multi interface is to be fixed for 32-bit architectures and compat, rather then disabled. As it turned out, there are a couple of additional problems that are to be addressed: - the absence of size overflow checks, leading to possible out-of-bounds writes (addressed by the first patch); - the assumption that long has the same size as u64, which would make cookies arrays size calculation incorrect on 32-bit architectures (addressed by the second patch); - the addrs array passing API, that is incompatible with compat and has to be changed (addressed in the fourth patch): those are kernel addresses and not user ones (as was incorrectly stated in [2]); this change is only semantical for 64-bit user/kernelspace, so it shouldn't impact ABI there, at least. [1] https://lore.kernel.org/lkml/CAADnVQ+2gwhcMht4PuDnDOFKY68Wsq8QFz4Y69NBX_TLaSexQQ@mail.gmail.com/ [2] https://lore.kernel.org/lkml/20220510184155.GA8295@asgard.redhat.com/ Eugene Syromiatnikov (4): bpf_trace: check size for overflow in bpf_kprobe_multi_link_attach bpf_trace: support 32-bit kernels in bpf_kprobe_multi_link_attach bpf_trace: handle compat in kprobe_multi_resolve_syms bpf_trace: pass array of u64 values in kprobe_multi.addrs kernel/trace/bpf_trace.c | 63 ++++++++++++++++------ tools/lib/bpf/bpf.h | 2 +- tools/lib/bpf/libbpf.c | 8 +-- tools/lib/bpf/libbpf.h | 2 +- .../testing/selftests/bpf/prog_tests/bpf_cookie.c | 2 +- .../selftests/bpf/prog_tests/kprobe_multi_test.c | 2 +- 6 files changed, 54 insertions(+), 25 deletions(-) -- 2.1.4