From patchwork Wed Aug 9 17:50:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1819497 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=BewAU9F8; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RLd0F4KSsz1yYl for ; Thu, 10 Aug 2023 03:51:25 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qTnK5-0000Po-Ag; Wed, 09 Aug 2023 13:50:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qTnK3-0000OO-0i for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:15 -0400 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qTnK1-0005fC-4b for qemu-devel@nongnu.org; Wed, 09 Aug 2023 13:50:14 -0400 Received: by mail-pj1-x1034.google.com with SMTP id 98e67ed59e1d1-269304c135aso27716a91.3 for ; Wed, 09 Aug 2023 10:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1691603412; x=1692208212; 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=ljQLvXBY81ZagAz+vbBgSRpeNzKthjrbvj4TtE4JxtM=; b=BewAU9F8uxcXcjMSwnG7vSFog8x6+0b77+Zl8kth06lQlqkv7O11O2S+xMxcViMWlp UVRh70LQPc3CwtfRBmLSt9cIRjvrH6CtwwmuKnMOV43whuzaIpB5Fi0sctaSRY23SIOR +/c76Ck9O5RnYIncBjJosgfQsjPIfvwv1JQlt982/IXaFvEBW5ITbFJehZ7gCTpelu+J jlESAX5baX+zxb3j01/iIxDbaYSz5wzbGojA4symALLSw3kv9I5nDbAkMZNxuC8JEwZ3 F4cNjXMC2LbJCErLR1I+JOUAbJ9EaRaeLZmusIl6ShSY4BUWJ95KXN7e3WH5oXgbWBwx C24w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691603412; x=1692208212; 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=ljQLvXBY81ZagAz+vbBgSRpeNzKthjrbvj4TtE4JxtM=; b=fYDTCK62d61UNvoNyCOK/t5Xb1QrMLpl5abZrtL3rUPhdkcgeG/BhNP5cjSfrChRvM efF+Fq/wV2b/1ynvsDuqM8UVJFbf5/kqID46hHLJ8VUVU0RSKauSEnCeDN6miCIWm0Gs 8fAzQQsIbSFQv4ohhYn4cCqMaHUJpBb0CrrGg8/D53DeLN4gETrM77Y1xRWG4rIX34xy OlagJ9SjJ7EIo3v2eGUeOVTLyLaluOgB0EIv0IccAKEyDTWlwPMW4E7iztxeUOtip7hx nk2VcRpoXuNogWaPGUFc/TlHCJmsrcNSO+sdVROfsCxJf1HheRb/EzqxwoVSNUNqkXtx Dz2Q== X-Gm-Message-State: AOJu0YyfEM6f8wgJKBygbvq23gb0aMTPCWnofyk/MLqRJ3a0/ogOsMBr xwqbBXMAt38TWnKvSnz7KXoYTRIoIdyEMPCON94= X-Google-Smtp-Source: AGHT+IFf524T2OY5wZEVc69M1YR73Tk7aW6o0LEc6IpKGStSJKu4Ff26lJiTKPEcERZA5sk/GjN2jw== X-Received: by 2002:a17:90b:20b:b0:268:14a0:f8a with SMTP id fy11-20020a17090b020b00b0026814a00f8amr2794757pjb.39.1691603411859; Wed, 09 Aug 2023 10:50:11 -0700 (PDT) Received: from stoup.. ([2602:47:d483:7301:6bf0:9674:6ac4:f74c]) by smtp.gmail.com with ESMTPSA id y7-20020a17090a2b4700b0025dc5749b4csm1753710pjc.21.2023.08.09.10.50.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 10:50:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: Helge Deller Subject: [PULL 5/6] util/interval-tree: Check root for null in interval_tree_iter_first Date: Wed, 9 Aug 2023 10:50:05 -0700 Message-Id: <20230809175006.242479-6-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230809175006.242479-1-richard.henderson@linaro.org> References: <20230809175006.242479-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::1034; envelope-from=richard.henderson@linaro.org; helo=mail-pj1-x1034.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 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Helge Deller Fix a crash in qemu-user when running cat /proc/self/maps in a chroot, where /proc isn't mounted. The problem was introduced by commit 3ce3dd8ca965 ("util/selfmap: Rewrite using qemu/interval-tree.h") where in open_self_maps_1() the function read_self_maps() is called and which returns NULL if it can't read the hosts /proc/self/maps file. Afterwards that NULL is fed into interval_tree_iter_first() which doesn't check if the root node is NULL. Fix it by adding a check if root is NULL and return NULL in that case. Signed-off-by: Helge Deller Fixes: 3ce3dd8ca965 ("util/selfmap: Rewrite using qemu/interval-tree.h") Message-Id: Reviewed-by: Richard Henderson Signed-off-by: Richard Henderson --- util/interval-tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/interval-tree.c b/util/interval-tree.c index f2866aa7d3..53465182e6 100644 --- a/util/interval-tree.c +++ b/util/interval-tree.c @@ -797,7 +797,7 @@ IntervalTreeNode *interval_tree_iter_first(IntervalTreeRoot *root, { IntervalTreeNode *node, *leftmost; - if (!root->rb_root.rb_node) { + if (!root || !root->rb_root.rb_node) { return NULL; }