From nobody Mon Apr 6 18:42:58 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 3ACF7ECAAD5 for ; Mon, 5 Sep 2022 12:35:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238243AbiIEMfh (ORCPT ); Mon, 5 Sep 2022 08:35:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238196AbiIEMce (ORCPT ); Mon, 5 Sep 2022 08:32: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 B1D3161737 for ; Mon, 5 Sep 2022 05:26:55 -0700 (PDT) Received: by mail-ej1-x64a.google.com with SMTP id nb19-20020a1709071c9300b0074151953770so2298333ejc.21 for ; Mon, 05 Sep 2022 05:26:55 -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:subject:date; bh=63Lbiss0mCSaP/JatuEwb7Qda7JVHXONR7b7gS/f0zw=; b=UDsvJYgtTXPZF5a9agPh2mXyrYJrhXMTAzXPZNghSJw5ee3mNMwXIwpKa+RKY0zuMd 0oketLAQ8tAqBq9H1OztfYXsFZLC3/GjPvaRGV4Tf5cx5pY09RUcAdfIPub4N1YomTRe qN17vYLlykWW3fcYQY5yUk9fGBNhlorODfdAFeJeB/phj1xFUAdvMGDkePvsaAAnNZDZ QNcHmgGjaBYlCKkJsPpqD7vIZwk92kcg49ObV7TTQ+SLXpAZ9pO/JJZcCHGzK92euOmB wKHTk01woRx7PzSGgjyowKFGJYseYwyRla1r4RWjs1ovT7LskcrPtqUZWACg7jNiOAET dJPQ== 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:subject:date; bh=63Lbiss0mCSaP/JatuEwb7Qda7JVHXONR7b7gS/f0zw=; b=3Gbrd/lIqI5c9WDn9mik8oCKO3zsEwR6a690/Yr9w/G3o8m+uD+0jjnrK3CyxDrjEe tcUFzifNB9MwGAtEDib03lPphFF1q7yia3RiVC7pzhcRIoIptLXhKFmgl6zqx9pqSpUa ptEJsbmOU7E5IeWDrHmmnKLiopyVLzVDK4lI+AZgCOCMApTOt/be8eu8Fa0RjWp458uJ m+ft2uEk1Pk30bO77WKdbIWS1XNEiA594Zs0Nd6vLDxCcF44CtRaJ8rS1qakjLh1M5WG K+TtGONvSNfQTZI2QNufsLtSs75TnZxyctGrPAL3l6wScXneoWNTS8lSFk9JmnDKK8p8 s4uw== X-Gm-Message-State: ACgBeo3fmooAvmx5W+B9dEXAHdj8oC9/fs0huPD7u9EWcNRrhdKIMy04 C5K0BtEfuAoz03DiTI69ASX2fLFsTHA= X-Google-Smtp-Source: AA6agR5LBRpdlR606D8rNDqY5QJ3OBC/wbbIgC3X8Ct4s02WNlqHsbJo9IxNX+CTnN40NsuDZAMm2jER36E= X-Received: from glider.muc.corp.google.com ([2a00:79e0:9c:201:b808:8d07:ab4a:554c]) (user=glider job=sendgmr) by 2002:a17:907:2c41:b0:741:4906:482b with SMTP id hf1-20020a1709072c4100b007414906482bmr28414813ejc.239.1662380813588; Mon, 05 Sep 2022 05:26:53 -0700 (PDT) Date: Mon, 5 Sep 2022 14:24:50 +0200 In-Reply-To: <20220905122452.2258262-1-glider@google.com> Mime-Version: 1.0 References: <20220905122452.2258262-1-glider@google.com> X-Mailer: git-send-email 2.37.2.789.g6183377224-goog Message-ID: <20220905122452.2258262-43-glider@google.com> Subject: [PATCH v6 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 3d9eb3ae334ce..21c74fac5131c 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.789.g6183377224-goog