Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp3458256iob; Mon, 16 May 2022 23:52:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfQcWZv+3IxGEtfhdR1/Zz1ZRCmHBrJpCnNRd4tvl8fD6p6uNdZhOgjLJY0RiiwkATLOaI X-Received: by 2002:a17:906:b7d6:b0:6fe:40aa:f8bc with SMTP id fy22-20020a170906b7d600b006fe40aaf8bcmr6807401ejb.132.1652770367375; Mon, 16 May 2022 23:52:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652770367; cv=none; d=google.com; s=arc-20160816; b=ccZnQGzziu+nm8DgeEeCSYlXS0GUcLTZkjD67+/0h6ZD75WSpz5zqHbp1KZ+Mp7vZX HsO1NiEyQlUSNVq/KKYPMFF8Lw0CCGJWiLbT04CFfJf8alf7Fus2cr/ZjNBD7FqGiDWx ABGuDJtdzSPLPCUqQZa5gzwcpREJNAphfdAyUEArJPAKK+lN3sDem2aeIqc10HScBzoc GNZohWxQeP74bfYRptLqNuW3ppOku2HHBuas6MFOmbkLdueYse7cbzdmte1Zi5KyX98Z aOoM4ruAkUSsrT9X6a4+KL9wstFLtN7GRyQAIIaEKjm3mdtlvk/zyYx5mnt8Y9Bx9mSq GhWw== 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=Nz8asN6yWWCLmMHvopeB9mZXCmt2tzqKgjjNKN8q4OZvcBGaxC0HfgjiuRdvB4iYko LZM3MoeHx2jOLpPD7S9lG9gjQnvNfLV/O8JOURjkA0fe5D4zzgWlJjvkSxgsXLT66Q77 JRQY/X618V0cjMEaLD+/sp55uolZgPSg2exKjIgK3QQ47VtskXBzk71nNg2qBIqSuAuF m6u/ZODPZRYtfDRqok42/n0Jh1Wy0iTQQsq8MbDaqjUI9vO5n+dDOOuRqGvZzMoysWFV veoMTsU+QTolo82cr+I99oUycaRP9XSVF4ZFj7AU5dm+Q6jx2skYpg3+B4fu1D2N5JIo iLuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XGKI4KMC; 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 oy9-20020a170907104900b006f51c67b74dsi1670945ejb.851.2022.05.16.23.52.21; Mon, 16 May 2022 23:52:47 -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=XGKI4KMC; 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 S1344755AbiEPS1X (ORCPT + 99 others); Mon, 16 May 2022 14:27:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344752AbiEPS1T (ORCPT ); Mon, 16 May 2022 14:27:19 -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 43F5C3DA7C for ; Mon, 16 May 2022 11:27:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652725636; 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=XGKI4KMCU82ymnvnqyw2x4IfJLKH2WsmkGtdQQTmYiW8LpqhX2XO9pZ4DMIhzR1UB6bPOt SBRtauWabedmbHyBTjPtnU3c8sjfJdRcq3cyKxUqltK1y+D2JSzrhzHd6VqR+lnR/1LSjm bb+FWqbYO107w0a6zqspTDHVBm8if2A= 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-29-hkLDBe64NLOiL3uXQ0xXTA-1; Mon, 16 May 2022 14:27:12 -0400 X-MC-Unique: hkLDBe64NLOiL3uXQ0xXTA-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 6B4561DC245E; Mon, 16 May 2022 18:27:04 +0000 (UTC) Received: from asgard.redhat.com (unknown [10.36.110.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 02FC4155F652; Mon, 16 May 2022 18:26:59 +0000 (UTC) Date: Mon, 16 May 2022 20:26:57 +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, Shuah Khan , 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: <20220516182657.GA28596@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=unavailable 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