Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2592521rdg; Mon, 16 Oct 2023 08:53:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHkh4n8XSjTvgohJv54WPwM0NksKL6N0L2ZbcaunHTfXIVBKQQKSzkOHbrd9E1OHVz+djOR X-Received: by 2002:a05:6a20:72a2:b0:15e:bf2b:e6d3 with SMTP id o34-20020a056a2072a200b0015ebf2be6d3mr36399989pzk.46.1697471606432; Mon, 16 Oct 2023 08:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697471606; cv=none; d=google.com; s=arc-20160816; b=f/WUjCSj05fYlxzkfvaCfvo4VXEY0wm9wyFP7T+i3ASCkhH5OZar8d8gWNuiKLVlAe 9Mpj8ivaFVjBOiQT1HyLEoPh4NX+fQMKIGu5VqFPnSs9taWWvUoBDxEh6ZzgAgefxn6V Er6IGGs63FIfsQlYrlh7UpksWv2Ghbb2Zhz9ax7SB7T2xpGwsWJ94Ct0QuPIWrqm4op8 fYTpZjQZGuT9I1/SXcTOoymNPE2tSfjh6ShV7S/6MZTz2iiqL4WBOEqGaOO42pGwz2aO YFmqAGToVrdpbM5eZO87wl6ZpzBp7j3FW4PRsOLfMI2JOuPR57/0OewyXQmxrdpdX8s+ Rwvw== 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:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=LYpi+Y74+blfqQ7+iyjrYGXZgsEgnThgUXh2i1YfeDY=; fh=qHzrIxpYIOyJP7kenXxkLkDAYnrch2fZLsMg0SlFlLA=; b=hlXTkO4TyZIyZVj2LNyvC6T018pnQPkDp5tLFss32GjdL1agfT6jHOdo/YDTcacADA 5Y1z3MetEtwi+IL3DtOB2kc4F7fgCgJ4UfH7+EMf4gwxHpeNnm1ry1PqSvYkWa/YfOg+ 45yawP9TX6kzd+IaeuRjMzpdYlEFCkIUNCjYlzCkLuzvDeiVQI5Xg2dsUX8IXUZvVkUz WStLI/yQ6otyBm4sPN/7lL9fFTP6/6gsShClDxVM4TCEG+Q5nPqkCLtXpBZu/Tf0E6tC w7vu/Trkbarz0iRvgF2Ina8+WnvSC+e4vJ/YwpPN9/bvdEp7vCpPyAJMk8ldDilw7tzR tXIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="WtoG/k5n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id l17-20020a170903245100b001c413905d87si11739530pls.49.2023.10.16.08.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 08:53:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="WtoG/k5n"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6D50F80465C4; Mon, 16 Oct 2023 08:53:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233188AbjJPPxP (ORCPT + 99 others); Mon, 16 Oct 2023 11:53:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47282 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233425AbjJPPxO (ORCPT ); Mon, 16 Oct 2023 11:53:14 -0400 Received: from mail-yw1-x112d.google.com (mail-yw1-x112d.google.com [IPv6:2607:f8b0:4864:20::112d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9340F5 for ; Mon, 16 Oct 2023 08:53:12 -0700 (PDT) Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-5a7e5dc8573so57806037b3.0 for ; Mon, 16 Oct 2023 08:53:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697471592; x=1698076392; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=LYpi+Y74+blfqQ7+iyjrYGXZgsEgnThgUXh2i1YfeDY=; b=WtoG/k5nNQxQLxND1DwlOC8E2KNVBIdA5k6GffMiAOquxJ701M3N/82inuFiBXwzsV GtaXZtzOkRFoyh/BebrY+nJOCPNEZ/9J9gIDRVFTUyXGb8xcURz+KZWJnTNdYDAhEfpK z6izCBo2NqEUStCHgXJGZOH0G1CqP0RrEJgLgALnyatBUVNNjFXjpgKUzpiaEsLhAHzg hwXSQnjxYrnsyt7+CYGGGjzFubc9Ow6jnc3ZcgEeYJ2uhaIKPsAhOnYuYW5CqycEPJ2P Z/yqPpBk9sBJsI/x3ehG+KonwLKMEmSUY7sF7O+22OgZaO0D3E5uTe7oEqLD9c1BOqwH Whug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697471592; x=1698076392; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LYpi+Y74+blfqQ7+iyjrYGXZgsEgnThgUXh2i1YfeDY=; b=qh+Nn/A2AJQHOUULfMkTUFCXzp/NjU8nUqCXDDja6WEl+NC5KQFEZ80WySlALhIn1S 5T/btNOQd8nUaHvdymtMXZSvGxUgjWF+Y9Jtaga2CKt87s9oncN9/OSYLpob5lQfS2ie 5g1be0LMuT2VTleJVplGjbOnsD7VN+E4jsAhAaZybD+KcXrrpUUO2Hi+Zfg583mha6fg dhPwaIGC603zHm0RPr5WYa909MA2CZllhjV/JexT5HRSn1xpvDLs6jLVNHTjy0C9KE9w wwgxR4qSXknW8/AouLJnAp36efeSzR6c4a3zAjA87FqO859cUXUnykwdlPX7ZdgAqbrW XI1w== X-Gm-Message-State: AOJu0Ywy2/3Ta7iRgRhWicGRrzGWFT4OCBZi7C3mvEgFs00pUo95tj1o dBmpL27DQkKNNPmCfZeSQNnLFFXGh4ue9EtgCOOorg== X-Received: by 2002:a0d:d713:0:b0:5a8:72ee:463d with SMTP id z19-20020a0dd713000000b005a872ee463dmr3725033ywd.49.1697471591735; Mon, 16 Oct 2023 08:53:11 -0700 (PDT) MIME-Version: 1.0 References: <20231016153446.132763-1-pedro.falcato@gmail.com> In-Reply-To: <20231016153446.132763-1-pedro.falcato@gmail.com> From: Alexander Potapenko Date: Mon, 16 Oct 2023 17:52:29 +0200 Message-ID: Subject: Re: [PATCH v2] mm: kmsan: Panic on failure to allocate early boot metadata To: Pedro Falcato Cc: kasan-dev@googlegroups.com, Marco Elver , Dmitry Vyukov , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Mon, 16 Oct 2023 08:53:24 -0700 (PDT) On Mon, Oct 16, 2023 at 5:34=E2=80=AFPM Pedro Falcato wrote: > > Given large enough allocations and a machine with low enough memory (i.e > a default QEMU VM), it's entirely possible that > kmsan_init_alloc_meta_for_range's shadow+origin allocation fails. > > Instead of eating a NULL deref kernel oops, check explicitly for > memblock_alloc() failure and panic with a nice error message. For posterity, it is generally quite important for the allocated shadow and origin to be contiguous, otherwise an unaligned memory write may result in memory corruption (the corresponding unaligned shadow write will be assuming that shadow pages are adjacent). So instead of panicking we could have split the range into smaller ones until the allocation succeeds, but that would've led to hard-to-debug problems in the future. > > Signed-off-by: Pedro Falcato Reviewed-by: Alexander Potapenko