From nobody Tue Apr 7 16:28:40 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 556B7ECAAD4 for ; Fri, 26 Aug 2022 15:16:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344394AbiHZPQn (ORCPT ); Fri, 26 Aug 2022 11:16:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344443AbiHZPPe (ORCPT ); Fri, 26 Aug 2022 11:15:34 -0400 Received: from mail-ej1-x64a.google.com (mail-ej1-x64a.google.com [IPv6:2a00:1450:4864:20::64a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64B9ABA9F6 for ; Fri, 26 Aug 2022 08:10:15 -0700 (PDT) Received: by mail-ej1-x64a.google.com with SMTP id qa35-20020a17090786a300b0073d4026a97dso718306ejc.9 for ; Fri, 26 Aug 2022 08:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc; bh=rCTBedHFoD5mjPc5axfz3IhJFNkE8btw4kiDfQuZoWM=; b=fg/g7W5SFXhbc3u2Ka10S6sfG+hleQgHtIujYd0emCXLuaRjW/Lp6/k4/2cWo7l/yp VDQQl06jPUO4V5hkPUjOfNuax5shhJaKnbpXyd21jWZdCRxSmNTw/c5xxG3zrihbz+OE Ljd50zcy2oKUZWQBLmYWsMOuW6qxf6tCX2W3+KQJUFv3PXm77b5Ak7Io2QiMeQ/oK9vK ZD8Tqs0aoGX8nDwtNuhyBXUzYeCZIaWWl/08zjdMFlG1dJKaN0WeEcKRi8ejkQvW4T1P wvM92OSrEzTbGCfmQLEw8aa8qLoI04nx9tn9Pj1TgR/4CFpWvS9JnaF3HfLp1oJuw/pj zqCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc; bh=rCTBedHFoD5mjPc5axfz3IhJFNkE8btw4kiDfQuZoWM=; b=48kUcZ0NnFGe3Ss/CC8T8+u43Ct8+5tikaa29+CBqEkKbcVXnvWZE7+fD4qnCISphN Z0m06uQR5XXETAGJGY18Pv9Oyvkq2fMM98S5ByLJkmr3qeA7Nri0a2Xq+Jc+PBfMezqV 0Ee43ZOLSHZqVuCMi2Nv0qQS2FRiHtX49Wu2a/FZx6kViPmSlw1XP4eEOfkfnOhLA1ds /vl3LSgN/HX/gZfMWt7FQTmMjHYdw7KchD4heiXlkFBxjd3gGbgwMQFWzaLDd/3wyJer zHn/+Gbw6efN1dZUEEd58AHn/UT6saAMe9Jxs+98grSWgW1/eX1xbn0PXknXpjCVFclc EEkQ== X-Gm-Message-State: ACgBeo3VxiVP0LFHMWyiBOreunJEPA7nGNwtOYqGWwgNiX97TS6u5n4J cu1/4JjeiA36yV/jaL8ZYYiLo1Ilyis= X-Google-Smtp-Source: AA6agR7tXjpYxk8MsRplqzj3thTzocuzhsrofVe2ZMXjeqhyHHZW7zWMaS3lAs0uR1Cb77CsZjqkIFO/xsw= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:5207:ac36:fdd3:502d]) (user=glider job=sendgmr) by 2002:a05:6402:2816:b0:434:ed38:16f3 with SMTP id h22-20020a056402281600b00434ed3816f3mr7084895ede.116.1661526610607; Fri, 26 Aug 2022 08:10:10 -0700 (PDT) Date: Fri, 26 Aug 2022 17:08:05 +0200 In-Reply-To: <20220826150807.723137-1-glider@google.com> Mime-Version: 1.0 References: <20220826150807.723137-1-glider@google.com> X-Mailer: git-send-email 2.37.2.672.g94769d06f0-goog Message-ID: <20220826150807.723137-43-glider@google.com> Subject: [PATCH v5 42/44] bpf: kmsan: initialize BPF registers with zeroes From: Alexander Potapenko To: glider@google.com Cc: Alexander Viro , Alexei Starovoitov , Andrew Morton , Andrey Konovalov , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Christoph Hellwig , Christoph Lameter , David Rientjes , Dmitry Vyukov , Eric Dumazet , Greg Kroah-Hartman , Herbert Xu , Ilya Leoshkevich , Ingo Molnar , Jens Axboe , Joonsoo Kim , Kees Cook , Marco Elver , Mark Rutland , Matthew Wilcox , "Michael S. Tsirkin" , Pekka Enberg , Peter Zijlstra , Petr Mladek , Steven Rostedt , Thomas Gleixner , Vasily Gorbik , Vegard Nossum , Vlastimil Babka , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When executing BPF programs, certain registers may get passed uninitialized to helper functions. E.g. when performing a JMP_CALL, registers BPF_R1-BPF_R5 are always passed to the helper, no matter how many of them are actually used. Passing uninitialized values as function parameters is technically undefined behavior, so we work around it by always initializing the registers. Signed-off-by: Alexander Potapenko --- Link: https://linux-review.googlesource.com/id/I8ef9dbe94724cee5ad1e3a162f2= b805345bc0586 --- kernel/bpf/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c index c1e10d088dbb7..547d139ab98af 100644 --- a/kernel/bpf/core.c +++ b/kernel/bpf/core.c @@ -2002,7 +2002,7 @@ static u64 ___bpf_prog_run(u64 *regs, const struct bp= f_insn *insn) static unsigned int PROG_NAME(stack_size)(const void *ctx, const struct bp= f_insn *insn) \ { \ u64 stack[stack_size / sizeof(u64)]; \ - u64 regs[MAX_BPF_EXT_REG]; \ + u64 regs[MAX_BPF_EXT_REG] =3D {}; \ \ FP =3D (u64) (unsigned long) &stack[ARRAY_SIZE(stack)]; \ ARG1 =3D (u64) (unsigned long) ctx; \ --=20 2.37.2.672.g94769d06f0-goog