From patchwork Wed Sep 6 10:10:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicholas Piggin X-Patchwork-Id: 1830312 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=W1alLMai; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=2404:9400:2:0:216:3eff:fee1:b9f1; helo=lists.ozlabs.org; envelope-from=skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=patchwork.ozlabs.org) Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2404:9400:2:0:216:3eff:fee1:b9f1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RgdSC1hWsz1yh5 for ; Wed, 6 Sep 2023 20:11:07 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=W1alLMai; dkim-atps=neutral Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4RgdSC0m0Vz3c8D for ; Wed, 6 Sep 2023 20:11:07 +1000 (AEST) X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20221208 header.b=W1alLMai; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::d2e; helo=mail-io1-xd2e.google.com; envelope-from=npiggin@gmail.com; receiver=lists.ozlabs.org) Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4RgdRh5J3wz2ydW for ; Wed, 6 Sep 2023 20:10:40 +1000 (AEST) Received: by mail-io1-xd2e.google.com with SMTP id ca18e2360f4ac-792707f78b5so148900939f.1 for ; Wed, 06 Sep 2023 03:10:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693995037; x=1694599837; darn=lists.ozlabs.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Mw2T1HhD44ktsMduN7m3gsPhRMsi9D6ZrYLJcqC/5IY=; b=W1alLMai99FVU1XuRprX5k80gtbtuC9vXEXP5/zon7WnVeZFPpW87RDSuB2mVqPoBi PJC7D1pHP6JFzOjENSi7oXzMMjmdH8xakpWtjEXFnMV7pJyMax1mHx0X9NLYNDBy17at IjiQmxtfEfvGIJEqOolgsKtHlHII/nKviaEKTURjnH18aWOa15kIYZZZMdI/hjKf1QDy MB+9J7CVX/RpnE+tds1K9zYpYWpbeapO/0R/Ya3vyaYgH5AeQOYi2jQzpGKWihdwZcjo u5Co4TJYwEf81Ct+z9uVhiJlSe0hSyimVH+ijQ/6r/kej5xOeHNAqJJ43A30ywWCluGb MhTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693995037; x=1694599837; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Mw2T1HhD44ktsMduN7m3gsPhRMsi9D6ZrYLJcqC/5IY=; b=AzhwXUKxUWy4SVvdxVr2LhsoBZM/yl+/h+TW1MXIOSjbtdPA+/ngFhA8JyCBfLyO3t 3AyZ+xECNis3svgXT+SWBpHexpI3Q/Qtq4oapDcXlLYR50Ig/aZohz2IGTvfv4vJtioC KmvY6XcmiYkyKmIlm1pcnyT43Pbdn+Ma4j9LtuLV5bTkypil+6gini35PGWDUxGCGhJJ /yIVghtMxuVr59eNBpg8Qcq0aOXhNvRXKZbJudOmYNYBfl0Pld6QoghpYTdz+7ou32Mb dCYbf3QwcjOGNsT4P4kUIFlpZz/u72mjgnPiWuN+J3zBMPYlNgoKWzxfVZ+uKj2tqmbz iLoQ== X-Gm-Message-State: AOJu0YywEzq8isiplucJQNgxUE1YiJqeUfDUlH8EflRKKZHBx8lI7RAs exkO9yaSkcB3Gw8E9ZkvAbPx42HgIVs= X-Google-Smtp-Source: AGHT+IHRJqfJ5ZNBfLjsIk86LEEjTnm8PpLXTW1rNO5KYCsRlCSMoHPqth4+fcrHmyD/2OHIfsumxA== X-Received: by 2002:a05:6e02:1a41:b0:34d:ee49:5114 with SMTP id u1-20020a056e021a4100b0034dee495114mr21234204ilv.23.1693995037472; Wed, 06 Sep 2023 03:10:37 -0700 (PDT) Received: from wheely.local0.net (193-116-105-24.tpgi.com.au. [193.116.105.24]) by smtp.gmail.com with ESMTPSA id m13-20020a17090a7f8d00b002609cadc56esm10639705pjl.11.2023.09.06.03.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Sep 2023 03:10:37 -0700 (PDT) From: Nicholas Piggin To: skiboot@lists.ozlabs.org Date: Wed, 6 Sep 2023 20:10:13 +1000 Message-Id: <20230906101017.130276-4-npiggin@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230906101017.130276-1-npiggin@gmail.com> References: <20230906101017.130276-1-npiggin@gmail.com> MIME-Version: 1.0 Subject: [Skiboot] [PATCH 3/7] hdata: Make hdata child accessors check the header X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Like other (idata) accessors already do, check the common header in hdata child accessor calls. Signed-off-by: Nicholas Piggin --- hdata/hdif.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hdata/hdif.c b/hdata/hdif.c index 13c128c97..aba7f3660 100644 --- a/hdata/hdif.c +++ b/hdata/hdif.c @@ -157,6 +157,12 @@ HDIF_child_arr(const struct HDIF_common_hdr *hdif, unsigned int idx) { struct HDIF_child_ptr *children; + if (!HDIF_check(hdif, NULL)) { + prerror("HDIF: Bad header format !\n"); + backtrace(); + return NULL; + } + children = (void *)hdif + be32_to_cpu(hdif->child_off); if (idx >= be16_to_cpu(hdif->child_count)) { @@ -177,6 +183,12 @@ struct HDIF_common_hdr *HDIF_child(const struct HDIF_common_hdr *hdif, struct HDIF_common_hdr *ret; long child_off; + if (!HDIF_check(hdif, NULL)) { + prerror("HDIF: Bad header format !\n"); + backtrace(); + return NULL; + } + /* child must be in hdif's child array */ child_off = (void *)child - (base + be32_to_cpu(hdif->child_off)); assert(child_off % sizeof(struct HDIF_child_ptr) == 0);