Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp2333600rdg; Mon, 16 Oct 2023 00:25:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEhMqNk1JpgX1dg6XjT01S5WlqTIhpLtDfmrLpjMFDVFQzd1TaKmg9PUpw7lOClE0amGPJ X-Received: by 2002:a05:6a20:258e:b0:159:c24f:5fa4 with SMTP id k14-20020a056a20258e00b00159c24f5fa4mr33318175pzd.1.1697441131844; Mon, 16 Oct 2023 00:25:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697441131; cv=none; d=google.com; s=arc-20160816; b=VZID28Ou2+6ghtByS5j545/y5IJFVOpDBqJJPTd2haiJec0zr8IWhbjbIRMowqSlsQ xr7y7IR7tk3rJSRTF6Ps2EybFZmsz7qu7ua3e7EFt1iVzTfuJ83Z4RhGfGX/n+lrEf1t YmtnHKoxSNLqtd6nthymaSLYI4IG6UlsXnuK3Lt88LG3M5jbnvxVvXMLvq2oDCKxjcXH tHLeWxa3imeVoLU1CWwtEnGUpyD5n7KAB8+87dlYRGHQKbFUgHwkr+jq7NpiMwqKwEJj 0nfvzU7b+TKOX6/xXdTTAmZIFMijPP3T6tEc/MywYhypviF/gHKCd7iqH7s5IzBKlFFp MzrA== 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=Aaq5gGSXXFhrvTLVP4/6JBiex67TLmoZv6JITqT6ub0=; fh=o7j3g/q31jIib6BlUkVe9tNKCoo8Apz9BzqHyz/4Kpk=; b=Cq5zvqEatHv1twWb/h7bgiQmRaWMcbFGA5DAxwVeoMPDqJdZDaYAx2Pu0Io7V6XZxZ ezCDeoXqJk+5zG/BKULDxL7cQLrWiDMakGj8BHz7O5R9DsqB/hi8P4LxAUNsGwqtzZVl H+MN8Yn/y2OM6wAcEcTiAnS7IqJunsfgS3peDkrKZQHR9VMv4nw0x/CsOU9FlKpKONEy Mts+UAjuAJsLmRsVlldlhmCCx0kOp94fBPD2lEU8alwu/cTLSbLVoEMClar4l036Nz1Z ablMQx+UMyBAJKshbaXiH0wEarcFG5gxexVhjxLWdgKnH/i7VItoxs7lRKSf8fdepKmP sIyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GiJXhH5H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id pc14-20020a17090b3b8e00b0027d33155aefsi6173907pjb.99.2023.10.16.00.25.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Oct 2023 00:25:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=GiJXhH5H; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id 62FB7805744B; Mon, 16 Oct 2023 00:25:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229633AbjJPHZS (ORCPT + 99 others); Mon, 16 Oct 2023 03:25:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjJPHZR (ORCPT ); Mon, 16 Oct 2023 03:25:17 -0400 Received: from mail-vs1-xe2a.google.com (mail-vs1-xe2a.google.com [IPv6:2607:f8b0:4864:20::e2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A73C1AD for ; Mon, 16 Oct 2023 00:25:14 -0700 (PDT) Received: by mail-vs1-xe2a.google.com with SMTP id ada2fe7eead31-457c2d81f7fso1099826137.3 for ; Mon, 16 Oct 2023 00:25:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1697441114; x=1698045914; 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=Aaq5gGSXXFhrvTLVP4/6JBiex67TLmoZv6JITqT6ub0=; b=GiJXhH5HaQDPuXXycEANmjbh5fQuSmfyhWORx6aqrdUTWmdUZNa7oThSMNe8grKN/A 2ImBPu+vBPSVLlVwKbXwTWKhUbeghd/O6b9x1MCXarZXwRd8hvVLJf9ti+/8ecIRYtgu OLTNJYsTfpLUoTk1s6VgBqAkUrXdrDZ637yCoXgE0bAS8EbocVjYLvwZwxKBzxGZU1i7 ptStMBTYhx4x+YtG6wxMaTgqhHgpWgjGKc19F+Kebi97l4+EYKkjDTjj7S643fySQUOv vq9bmiESQTthhRA2DU0SvixlbS0CcBN1yEnCmdZZd0yFsRYk6Tvj/WvKUIPncsl05onz /w6w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697441114; x=1698045914; 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=Aaq5gGSXXFhrvTLVP4/6JBiex67TLmoZv6JITqT6ub0=; b=SNrSAxnV1R8nanPL5Y9N0HbbPLFqEJIp5Igm6BiC/bReJaoC76KPKOIaEmzTfwuxWr Y1/wgTRdnYLqiMXaSf2mNr4HoqJFSZ6Cn8l57Dcr9D82S6C7xq/9gdzBhSmi88tbJ1Xv XwNNNhGRNro00P/ve70fxRqxOg7vC8lsBiwvl658BJBRk2WoxxNKf1Kq3p8xSVVGnct7 aPH7IEHJ4DHMdiztuxPJi5UF0MijxVgzpFbBhhwyaBmOnEsso0v59YknKnRjhVWgxV7j lxHjlsjvkGQMu0zR6cleyRDkGFZ5CaMuhfCJvqrxl+4nXriDYMZNwEyQZLNYDIPHA66S zG9Q== X-Gm-Message-State: AOJu0YwpRwB93ntUv5A2MutxYETe/pULF8r3LV3uD7KYjIV/gtTzg+SL gZy2q5UVjrQiZuGEVhP6NCpY/BkgFfr4KmePQzErLg== X-Received: by 2002:a67:e00b:0:b0:457:c052:1949 with SMTP id c11-20020a67e00b000000b00457c0521949mr6953894vsl.25.1697441113556; Mon, 16 Oct 2023 00:25:13 -0700 (PDT) MIME-Version: 1.0 References: <20231015202650.85777-1-pedro.falcato@gmail.com> In-Reply-To: From: Marco Elver Date: Mon, 16 Oct 2023 09:24:37 +0200 Message-ID: Subject: Re: [PATCH] mm: kmsan: Panic on failure to allocate early boot metadata To: Pedro Falcato Cc: kasan-dev@googlegroups.com, Alexander Potapenko , 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 pete.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 (pete.vger.email [0.0.0.0]); Mon, 16 Oct 2023 00:25:29 -0700 (PDT) On Sun, 15 Oct 2023 at 22:35, Pedro Falcato wrote= : > > 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 memblo= ck_alloc() > > If there's no need for a v2, please wrap the above line and... Probably easier to send v2. Otherwise looks good. > > 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 = *start, 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= boot range " > > + "of size %llu", > > unwrap this string like this: > "%s: Failed to allocate metadata memory for early boot range of size = %llu", > > Silly mistake... > > -- > Pedro