Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1oPjyo-0004cL-E8 for mharc-grub-devel@gnu.org; Sun, 21 Aug 2022 08:23:02 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34168) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oPjym-0004aw-ML for grub-devel@gnu.org; Sun, 21 Aug 2022 08:23:00 -0400 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:33617) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oPjyl-0007Gd-4m for grub-devel@gnu.org; Sun, 21 Aug 2022 08:23:00 -0400 Received: by mail-pj1-x1030.google.com with SMTP id ds12-20020a17090b08cc00b001fae6343d9fso3982806pjb.0 for ; Sun, 21 Aug 2022 05:22:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axtens.net; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Uu+jfBeCwJsGMFnWtrGtusy/s8iz9MnUHuyxJfKQTi0=; b=L28r8oAdgjyLuNNYsst8+CbDZprHhXwSCK/we9rP8D+mokYPsI13hsFMp8JI2MAVpS f+BusisL4wKvUz8EJ46O49dkBPhCQaA6MMqucPcxYsxT6WHxCesA+JBlztrpJvrKHge+ N261lvNnWWUNYV8Nka86fSrF9HMbvQLfE0+nQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Uu+jfBeCwJsGMFnWtrGtusy/s8iz9MnUHuyxJfKQTi0=; b=3NPPa2eOkwulXxNlpTEZJStfmmQmlWQ4CSOWRDqPYcgb2rvmVzi259E2dLAZm9NtuF aZ7uYMDSWLaZVrF1au7hienpt3EP66fh/Nl6z8d8GTOlwaVA+b4sBkgjoy65ctew2kkm 83DFIy0p6h9ENN0VXjP/GPowfE3aZ3ORnTSvKGm8yEzVZvyE2Sqy6HzG9UHzgwglf460 Dr6K76veRksUfEIhZUBfnWlq0MuR/1VVevf11sRImQ8EnNe8cCaNlonAdjkkANVtwCdV AEmEylM9zWgU+Paa/ZUuFyPgdD1DMn+DOsGEHym2kjEsiiA918ErVCLenz4ASvjdV1Ks 17Tw== X-Gm-Message-State: ACgBeo1umivzfNNpDp3VfMnccTK7Tdae2JXEtAgV3YN5bMuBoKe9qp9X W9i0Aq2+GTaVDGhPHZKTfJcE52+LRKrn/A== X-Google-Smtp-Source: AA6agR7MrqEw8uNK/tyiTooBHZRGhXjJS4RtmACv6DOyXikt1FsWeZQG4O4X387HUEDIdn4CrDZ1Lg== X-Received: by 2002:a17:902:ce0e:b0:172:69cc:60aa with SMTP id k14-20020a170902ce0e00b0017269cc60aamr15554174plg.31.1661084577687; Sun, 21 Aug 2022 05:22:57 -0700 (PDT) Received: from linkitivity.lan ([2001:4479:e300:5b00:dab:c9a7:28f3:a267]) by smtp.gmail.com with ESMTPSA id p6-20020a622906000000b0052dc12cded3sm6658974pfp.196.2022.08.21.05.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Aug 2022 05:22:57 -0700 (PDT) From: Daniel Axtens To: grub-devel@gnu.org Cc: Daniel Axtens Subject: [PATCH 2/2] diskfilter: don't make a RAID array with more than 1024 disks Date: Sun, 21 Aug 2022 22:22:36 +1000 Message-Id: <20220821122236.32491-2-dja@axtens.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220821122236.32491-1-dja@axtens.net> References: <20220821122236.32491-1-dja@axtens.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=dja@axtens.net; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 21 Aug 2022 12:23:00 -0000 This is 'belt and braces' with the last fix: we end up trying to use too much memory in situations like corrupted Linux software raid setups purporting to usew a huge number of disks. Simply refuse to permit such configurations. 1024 is a bit arbitrary, yes, and I feel a bit like I'm tempting fate here, but I think 1024 disks in an array (that grub has to read to boot!) should be enough for anyone. Signed-off-by: Daniel Axtens --- grub-core/disk/diskfilter.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/grub-core/disk/diskfilter.c b/grub-core/disk/diskfilter.c index 4ac50320ef4e..79c5f4db940a 100644 --- a/grub-core/disk/diskfilter.c +++ b/grub-core/disk/diskfilter.c @@ -1046,6 +1046,13 @@ grub_diskfilter_make_raid (grub_size_t uuidlen, char *uuid, int nmemb, struct grub_diskfilter_pv *pv; grub_err_t err; + /* We choose not to support more than 1024 disks */ + if (nmemb > 1024) + { + grub_free (uuid); + return NULL; + } + switch (level) { case 1: -- 2.25.1