Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp30816578rwd; Thu, 6 Jul 2023 11:06:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlFiD1UodyP+4DIDZSh9dq8MHenpPcmrNzyJqw1lKbcCieTqC38Eb2P120byQ9tTttcqNImN X-Received: by 2002:a05:6830:186:b0:6b8:886d:852 with SMTP id q6-20020a056830018600b006b8886d0852mr2945307ota.26.1688666786371; Thu, 06 Jul 2023 11:06:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688666786; cv=none; d=google.com; s=arc-20160816; b=uoRMqooJKb2DCouUgEXDLENp2gZ+opstoWPNupuY4MtONQI4EWEGctvr4LqTkr2G7U SZEfM35L5+LiJp02X8jZRzyku5TU1/YsWzXtB+DRrhm0lx7wqg+X/2HtoF5Kyv6s8P7b Xtx2KB+jqDXRMKxfMl9pz/c7/Vp0vR722v8Ejnr96eK9svLBmUCXaTpeYoAvHzMieiML QVQEUPV73LMa7xprZtzpmXxfy7LbWGloQUGfvVum7bps9yZ2ID+lJ59EnPiAVl8I0W0L xnsZcjS/n4Tfu/xDsxs3eoE4S7f+cEb7QdaPHDBs1KhzvFqXOLBmLTWGSxzNyg3Rn29E o9/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:from:subject :message-id:references:mime-version:in-reply-to:date:dkim-signature; bh=iYwswXlV1/1qc1QMb8XdbUm0VHdqMuEGHLDmXeCI7tw=; fh=Gg5/Wq8VvlNmV99x9ouds1YI1sn5fMOkifq6Jlbuhrk=; b=bsIhrpTw1d8IzFU44XEX767uo3y9U4aFBmwnaitGwB2IrQl4j4q4IZFAi3P3SDNPJf oTLZTR0WldTPTH4JjyyQZj3gUDW+0mr/PyYjnrOHOhuijQNPVApnjZ6pK9rirKUoiN6m 41La8ItPsLDO/gEPKcgv7ceq3l/XFkLgX4xnPvyzfV7XHM9e/nUahOdQU176DFxOjdVp WUjUatJDZKATG2UdkN/IDW8cgd8cTiS9zd8aGVT1k17jd6xJrxjbSu6yqWSG6X1/nkjH dryLuIv7/j3xOFV2w/bMI6C4qV6Y/vWW/P07/BW1AjlFD9y1LWk69j78foTS5ApfwWWg 6HJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=JADhELCX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i194-20020a636dcb000000b0054fdcafcc67si1909641pgc.604.2023.07.06.11.06.07; Thu, 06 Jul 2023 11:06:26 -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=@google.com header.s=20221208 header.b=JADhELCX; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232508AbjGFRqc (ORCPT + 99 others); Thu, 6 Jul 2023 13:46:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231213AbjGFRqa (ORCPT ); Thu, 6 Jul 2023 13:46:30 -0400 Received: from mail-pl1-x649.google.com (mail-pl1-x649.google.com [IPv6:2607:f8b0:4864:20::649]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3CD11732 for ; Thu, 6 Jul 2023 10:46:29 -0700 (PDT) Received: by mail-pl1-x649.google.com with SMTP id d9443c01a7336-1b890ca6718so10535695ad.0 for ; Thu, 06 Jul 2023 10:46:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1688665589; x=1691257589; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:from:to:cc:subject:date:message-id :reply-to; bh=iYwswXlV1/1qc1QMb8XdbUm0VHdqMuEGHLDmXeCI7tw=; b=JADhELCXVgoD7i7cWTwhQRh73F5YhFYDBv94oM/8VxQQoeG0PhxyPIPeAt5smzYLDQ 2VFXs6FDTv58B0PombJgnTJb6SyHVgNKljVNLKJw3EBZa3IM+rDpks3+Z8C/xYtcpoxb LbU/vFpSAvnQ+5Dl4V1lvy11cPRh6gO9C/KaYNRuo5YkMRA5ChZ+B6QR3eNwDAJNHhEv 28/VzsSQuyF3hQ7p9xa/+eE3S/Swa0foXq4eOKi4DtfGVPSsoyFlkW+OKOkQEV9Hjwha r2lQN4ScFg+aAQmNbKsoXLuiVXMfbKyZj9wiemASlejBWpa5SFm0+xS1wTFJAhLizRvw VrwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688665589; x=1691257589; h=content-transfer-encoding:cc:to:from:subject:message-id:references :mime-version:in-reply-to:date:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to; bh=iYwswXlV1/1qc1QMb8XdbUm0VHdqMuEGHLDmXeCI7tw=; b=fRxiTjI+UbhA00pxx6b5AXz2uyn5YJ/QacvAQTBMXroBADfhoMEKRajUyPlnozNtEU YWnPbKKlAMcWX1HU3HwEPcQ0P2WWHwm0xYztkNavb1p+v5KqexdjxGctSaXIdxIBPP6M zPVQl9J72F8Y++GQf2Y1YlRzx43wdMSYtX/zyTGJKUW90fpaQg+pA6UCl3J82X1V/qQe iL0pOZ/chl4ph47e8iu0UN6CARB/y1qd3se9aGzf/6Z9FaL8gBmHmi5GCQjcF8CrneCk 6ZapCBZqe/lkuEP5WLg96v7ovY/hDnhx0PEqh2NYTlvvov9CV0IVf3IDgjh5HRA6cIVY EMcQ== X-Gm-Message-State: ABy/qLYFNPtjOG3HZo8CEL0pz5KBKSSI2ReVLAFwxa4VjjDTgpTwNK6w Zd6SA5CbOZ1lxxCad6/2+wo6ubk= X-Received: from sdf.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:5935]) (user=sdf job=sendgmr) by 2002:a17:902:7085:b0:1b7:eecd:9dae with SMTP id z5-20020a170902708500b001b7eecd9daemr1936538plk.9.1688665589079; Thu, 06 Jul 2023 10:46:29 -0700 (PDT) Date: Thu, 6 Jul 2023 10:46:27 -0700 In-Reply-To: <20230706142228.1128452-1-bjorn@kernel.org> Mime-Version: 1.0 References: <20230706142228.1128452-1-bjorn@kernel.org> Message-ID: Subject: Re: [PATCH bpf-next] selftests/bpf: Bump and validate MAX_SYMS From: Stanislav Fomichev To: "=?utf-8?B?QmrDtnJuIFTDtnBlbA==?=" Cc: Andrii Nakryiko , Mykola Lysenko , bpf@vger.kernel.org, netdev@vger.kernel.org, "=?utf-8?B?QmrDtnJuIFTDtnBlbA==?=" , Alexei Starovoitov , Daniel Borkmann , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL 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 On 07/06, Bj=C3=B6rn T=C3=B6pel wrote: > From: Bj=C3=B6rn T=C3=B6pel >=20 > BPF tests that load /proc/kallsyms, e.g. bpf_cookie, will perform a > buffer overrun if the number of syms on the system is larger than > MAX_SYMS. >=20 > Bump the MAX_SYMS to 400000, and add a runtime check that bails out if > the maximum is reached. >=20 > Signed-off-by: Bj=C3=B6rn T=C3=B6pel Acked-by: Stanislav Fomichev OTOH, should be easy to convert this to malloc/realloc? That should fix it once and for all and avoid future need to bump the limit? > --- > tools/testing/selftests/bpf/trace_helpers.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) >=20 > diff --git a/tools/testing/selftests/bpf/trace_helpers.c b/tools/testing/= selftests/bpf/trace_helpers.c > index 9b070cdf44ac..f83d9f65c65b 100644 > --- a/tools/testing/selftests/bpf/trace_helpers.c > +++ b/tools/testing/selftests/bpf/trace_helpers.c > @@ -18,7 +18,7 @@ > #define TRACEFS_PIPE "/sys/kernel/tracing/trace_pipe" > #define DEBUGFS_PIPE "/sys/kernel/debug/tracing/trace_pipe" > =20 > -#define MAX_SYMS 300000 > +#define MAX_SYMS 400000 > static struct ksym syms[MAX_SYMS]; > static int sym_cnt; > =20 > @@ -46,6 +46,9 @@ int load_kallsyms_refresh(void) > break; > if (!addr) > continue; > + if (i >=3D MAX_SYMS) > + return -EFBIG; > + > syms[i].addr =3D (long) addr; > syms[i].name =3D strdup(func); > i++; >=20 > base-commit: fd283ab196a867f8f65f36913e0fadd031fcb823 > --=20 > 2.39.2 >=20