Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2148463rdg; Sun, 15 Oct 2023 13:35:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHlFJmwM5U/hC6N3Gm0KdCFar9OJary1gkODGBF1I71monzFr6uMILm16XVnD4/85B9v2br X-Received: by 2002:a5b:c3:0:b0:d62:6514:45b7 with SMTP id d3-20020a5b00c3000000b00d62651445b7mr30019645ybp.37.1697402152031; Sun, 15 Oct 2023 13:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697402151; cv=none; d=google.com; s=arc-20160816; b=0ZQaQaDmIxFB4ZkPS7ZWCIMPynyteqUZ1ssMVHt/WRD4KyuOnMeMrG0WjCvmqIhy05 Yavfs6+dcaRjSRQoubr29/xKLgMAqrdvvYLFn6K1eW7FnesHgWCKO468nLuYhdlf0nXq dYi4oPtF/Gc88GpD8twv0RXHAPYYcr26/Ia5xruBxjFv1AVRj5esU1r9Cdc141L3SXzC znZMzqR1ndQMehPyZAE21tdDm9FZvX8VP5yLVc9e8vmzKon2KndWIvjRXVLHMTH/68JP 3B92aYCvbxXebkP0fa0/YhoHU9xHXzKxDVUMJc1BTpdAEVaNKPECjs+c4uqyV1goSuKi BjhA== 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=KUi6hE5CuO5LVhmusvTHYPNNPWcnkaNQ7utVUkV5A98=; fh=dzDjLnSBpiWteN3VeVwQViw99DTJGyKI7iTcYcsotVc=; b=XQ34GIp0R0vPtS21vFRB3ZTURPHlkQlAJiOdkIGLvJKLY/s1sM40bGcuR+pieBbbTD M2b+45W4rKxMY9Vq7t1zBSbOewg134xrWojTynvxbV+wlMi2zMrU2fqLuyh8N8So+PCL aWcWPOlM/oLO+JyNzksBvyRDxeFlSs8WbQ9P2HohA4wT9XaV55RItXu0qxcA8c2mL1jc UapPAfiXVhaB4qmbN3YXuoetUk/2b7Ivz1jpk0Gc2Snj/r/7vD5QxNtYO7ezZzUl3Txz rx+PgpPnBoOIpWo72s+KpLj8Jh8XEmPs/o+g02Lh/pX77kvnDNMk936rprQ/dEM3EsDx zYCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MxqBHeP+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b6-20020a056a00114600b00690f9e835d8si21258605pfm.132.2023.10.15.13.35.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 15 Oct 2023 13:35:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=MxqBHeP+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D9422807BA3A; Sun, 15 Oct 2023 13:35:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229990AbjJOUfm (ORCPT + 99 others); Sun, 15 Oct 2023 16:35:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbjJOUfl (ORCPT ); Sun, 15 Oct 2023 16:35:41 -0400 Received: from mail-ua1-x931.google.com (mail-ua1-x931.google.com [IPv6:2607:f8b0:4864:20::931]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3817CB7 for ; Sun, 15 Oct 2023 13:35:38 -0700 (PDT) Received: by mail-ua1-x931.google.com with SMTP id a1e0cc1a2514c-7b5fcf9c682so1762959241.2 for ; Sun, 15 Oct 2023 13:35:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697402137; x=1698006937; 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=KUi6hE5CuO5LVhmusvTHYPNNPWcnkaNQ7utVUkV5A98=; b=MxqBHeP+N1BoEhDvnO38u9mSnfoMpXqoAUmXqf/6R1rgE+aTqjagNJ+KwwNCqWrec6 wR7MyaVgd2b5+OKKNJEzHxmd7PgMgiQwEsJOwW6XljEkSvrxjC+DmkEGNSakQr1UDT3O MQ8EX8Oj0robLskDuUHZwS25lbOpzRBzU3tZIcdcYdtvOX8AnD2PugS75z9b7dl8/9st KCbzsb8/u1CZbowGXiScmGTl0RURpFT1DdOr5k4b51NO+R4uPDkXzZ6NMrFeuOGWuvYP qnIOdIFRX2idRyB+/RZHE1NhC/Y3P2KDquUsdThkRr8AxD0vkSSrgtHztkp/zWyeaES6 HQ5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697402137; x=1698006937; 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=KUi6hE5CuO5LVhmusvTHYPNNPWcnkaNQ7utVUkV5A98=; b=P0YRxZhTJMNl4oLl+g8ZY4xJLLOAkJnqtTnn/q+xl58mkU7I7FlheEh7I0FDNwcinS UleTLl8N/RjnQPqpcNkSbWBrMS16Cbrd5TBWzSP86x9pvYjp5TRYEBCDzAO2yu5IsKoN YPT4bR6bYfZGLLKBOQGxyHxhpj0tdUufoyCT/AqaebuxMJJsFfdENBBg8C1GGV0StI+P bGSC8vx1aJQPhyFjepXz1DChDWoIs4iJ/LqBppzQr24//RzwvLDTwimybNkQ4dpAQ0YW 1/EobSxuuPaTzaRYRYvc7iGDFsFZ1C+RJeexrRLmTQV8Y1UG6FefDoou4r5uKJ7cDYgG vvKA== X-Gm-Message-State: AOJu0Ywsk/DwADE8NwIgTuHW5AUoBOOtqIRH6uPNky8eddmUqHlS97GE jrNxpKTZzluyergYfpSe6/g6YArtJnufogWssoQ= X-Received: by 2002:a67:e006:0:b0:457:c57c:ef13 with SMTP id c6-20020a67e006000000b00457c57cef13mr4889967vsl.31.1697402137240; Sun, 15 Oct 2023 13:35:37 -0700 (PDT) MIME-Version: 1.0 References: <20231015202650.85777-1-pedro.falcato@gmail.com> In-Reply-To: <20231015202650.85777-1-pedro.falcato@gmail.com> From: Pedro Falcato Date: Sun, 15 Oct 2023 21:35:26 +0100 Message-ID: Subject: Re: [PATCH] mm: kmsan: Panic on failure to allocate early boot metadata To: kasan-dev@googlegroups.com, Alexander Potapenko Cc: 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=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.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 (groat.vger.email [0.0.0.0]); Sun, 15 Oct 2023 13:35:50 -0700 (PDT) On Sun, Oct 15, 2023 at 9:26=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. Ugh, forgot to run checkpatch.pl until it was too late :/ > Instead of eating a NULL deref kernel oops, check explicitly for memblock= _alloc() If there's no need for a v2, please wrap the above line and... > failure and panic with a nice error message. > > Signed-off-by: Pedro Falcato > --- > mm/kmsan/shadow.c | 10 ++++++++-- > 1 file changed, 8 insertions(+), 2 deletions(-) > > diff --git a/mm/kmsan/shadow.c b/mm/kmsan/shadow.c > index 87318f9170f..3dae3d9c0b3 100644 > --- a/mm/kmsan/shadow.c > +++ b/mm/kmsan/shadow.c > @@ -285,12 +285,18 @@ void __init kmsan_init_alloc_meta_for_range(void *s= tart, void *end) > size =3D PAGE_ALIGN((u64)end - (u64)start); > shadow =3D memblock_alloc(size, PAGE_SIZE); > origin =3D memblock_alloc(size, PAGE_SIZE); > + > + if (!shadow || !origin) > + panic("%s: Failed to allocate metadata memory for early b= oot range " > + "of size %llu", unwrap this string like this: "%s: Failed to allocate metadata memory for early boot range of size %l= lu", Silly mistake... --=20 Pedro