From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id FK5uDxIdtWeWwDUAWB0awg (envelope-from ) for ; Tue, 18 Feb 2025 18:51:46 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=zetier.com header.i=@zetier.com header.a=rsa-sha256 header.s=gm header.b=WXIdP4gE; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 2FD771E105; Tue, 18 Feb 2025 18:51:46 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.0 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 758C81E08E for ; Tue, 18 Feb 2025 18:51:45 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EBF823858C52 for ; Tue, 18 Feb 2025 23:51:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EBF823858C52 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=zetier.com header.i=@zetier.com header.a=rsa-sha256 header.s=gm header.b=WXIdP4gE Received: from mail-qv1-xf35.google.com (mail-qv1-xf35.google.com [IPv6:2607:f8b0:4864:20::f35]) by sourceware.org (Postfix) with ESMTPS id F39893858D20 for ; Tue, 18 Feb 2025 23:44:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F39893858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=zetier.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=zetier.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F39893858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::f35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739922246; cv=none; b=Jhzu3BVnnUjZnQeDE/MbIMkaZOcIKX4Tq+KHO0ZFq2iPakDT6TGzaJPRwZczivBSx5VwnO+y8MQHoQhbuVNyxnBL79vUg73xCX0/7fs5GnQJuuyusgeeuh8PMJjFuqNUe8YhV997MypfL95fAeFDl6iPd8+idYLTOOHpQaclOrM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1739922246; c=relaxed/simple; bh=X0AJiGTWzVYs8z11BNEgAeHSbfvy1894ZWS7wWb/fTg=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=kiHufmIGPvMUhQue2awnNb0MYUpmfx+aPXsMCmT5VO85dVPO1jnS7BqwtTP6fg5x8OZuoJQNlvz9UQ8l8vC/p+bIF4qW68cfX+gNsiPvld6zPXaRVCpBwtudYYkES8UjbGiZHy2t02k9NB9qKemlD6tFodJDKaAGAiglsOoodi0= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F39893858D20 Received: by mail-qv1-xf35.google.com with SMTP id 6a1803df08f44-6e17d3e92d9so52865976d6.1 for ; Tue, 18 Feb 2025 15:44:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zetier.com; s=gm; t=1739922245; x=1740527045; darn=sourceware.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=+6INsO4lG2NuRdD94Y7jzkRHrhvbt17N+3Abp3vH8gg=; b=WXIdP4gErByVLOE2H+lk3LUNMR2JBlhRKrr8KSC2fMrHMZ1Ybt11HSziK/FClsmQtH gLcgMft8trQJerOo3EuQiYW8vj9tSwh+txNf9oJHdQIWSyAfsUmDSyED01ue0RU0JwxP 5PEJGlujyf0m3v0NhDlcob5YpYDqWJelqY6rqNIRNinRymhtGHI93qvDKCyYPlGpSyT3 nq+lqAJJzrxVha4Fhp+qiFM5jE58lklz+f5DAAYa0oSIOtIhY3rzPewlaoR8n+KVvnfG 5bd27AcXmDFL0NE0CXqbsgCO/0BRVI/5UUDLUyZvkBVMLLuMm7N4SIjtNqN5208LP510 RwIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739922245; x=1740527045; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+6INsO4lG2NuRdD94Y7jzkRHrhvbt17N+3Abp3vH8gg=; b=xG/0Ez5eWO5Dr/UZSOyxTHpor6reNgHV/2uRYFZO5kh2unV2jquMOVq+Zpy9luMhUZ fYq3q7B1oVGoZDlKujSjLvzqB9caOttsYER7fiD2A6uPLY3CbCMt698uc7SxV9KnhcFk cGlg/SS8d9e24d/YvjdnqeTaIIUcHj/0s1vF7s+MiR4FBaLkkejOqL2d3rKjGufHgvbE awPW6riUrSWHAUrTTgPlg5eJIVhQN6BNVdV6FRQiiYnTOyTrNERp3o7KZxTPSUXuZwEa hqyrYRPNqyPiFMHoLrjpI8mohOd8fBiT9z6v0MtJ16X021hc4ynv290SBBT7oGhLmfI0 mBCg== X-Gm-Message-State: AOJu0YzgV9y7mY9+mZfIIvzCLgJQbGIwDPJ54l4tfmkb2eBSORrFZMYy 8MfjLHGQt1XVILYDJ6640YnYIrqIt42CPTxfAL6vrB+roxZaWDWvO9waAtn5yLAnWvjBRHuKS/y sIt4= X-Gm-Gg: ASbGnctuZKGo48dNO7RHnRTCWIxbEDDAH/LsjMziiEzdYVngdYHdQkGT10m6jSALBYy +jR7NMyMijabMW38jQ4iZGbcrpOJtVqNbfetBRfiYm5UzfGewQd4cBT+k+YWIfImMfwkY08ptex WJkTDLKUdiqIDI0aGQQFEQd2VoYrCLIaDmjo041pCzOkKg4QUWgV42ABu/tyrfQ/ZDSxwfmThaC RLBYBoicnT8+uU/feUou9YWtiXtle/l+srNnZgqtTmn0kDEpNop305iXXhXpLYSRsAsH0fzFgxq FoOKQjOlBzJeBb290ugkWHXlRUA/NfPs X-Google-Smtp-Source: AGHT+IGPIZuOshmOz73oPtZnMT4IXhxOh5mxnQDTnSvw0ocdm02LveLY1pfF1Dta1SlKyugiM6tjlg== X-Received: by 2002:a05:6214:194b:b0:6e1:a4ed:4b0c with SMTP id 6a1803df08f44-6e66cce49dcmr205923076d6.26.1739922245066; Tue, 18 Feb 2025 15:44:05 -0800 (PST) Received: from brandonb.zetier.com ([65.222.209.234]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6e65d7a4430sm69123876d6.65.2025.02.18.15.44.04 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 18 Feb 2025 15:44:04 -0800 (PST) From: Brandon Belew To: Andrew Burgess Cc: gdb-patches@sourceware.org Subject: Re: [PATCH v2] [PR corefiles/32441] Fix segfault if target_fileio_read_alloc fails In-Reply-To: (Brandon Belew's message of "Mon, 27 Jan 2025 15:20:48 -0500") References: <87v7ueog73.fsf@redhat.com> Date: Tue, 18 Feb 2025 18:44:03 -0500 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Ping, does anyonee have time to review this patch? > Check for target_fileio_read_alloc failure in linux_fill_prpsinfo > before dereferencing buffer. This fixes a segfault in the 'gcore' > command when attached to certain remote targets. > --- > gdb/linux-tdep.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c > index d3ab02d03e0..735d20dc050 100644 > --- a/gdb/linux-tdep.c > +++ b/gdb/linux-tdep.c > @@ -854,7 +854,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, > { > xsnprintf (filename, sizeof filename, "/proc/%ld/cmdline", pid); > gdb_byte *buffer; > - ssize_t len = target_fileio_read_alloc (NULL, filename, &buffer); > + LONGEST len = target_fileio_read_alloc (nullptr, filename, &buffer); > > if (len > 0) > { > @@ -2180,17 +2180,17 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) > /* The number of fields read by `sscanf'. */ > int n_fields = 0; > > - gdb_assert (p != NULL); > + gdb_assert (p != nullptr); > > /* Obtaining PID and filename. */ > pid = inferior_ptid.pid (); > xsnprintf (filename, sizeof (filename), "/proc/%d/cmdline", (int) pid); > /* The full name of the program which generated the corefile. */ > - gdb_byte *buf = NULL; > - size_t buf_len = target_fileio_read_alloc (NULL, filename, &buf); > + gdb_byte *buf = nullptr; > + LONGEST buf_len = target_fileio_read_alloc (nullptr, filename, &buf); > gdb::unique_xmalloc_ptr fname ((char *)buf); > > - if (buf_len < 1 || fname.get ()[0] == '\0') > + if (buf_len < 1 || fname.get () == nullptr || fname.get ()[0] == '\0') > { > /* No program name was read, so we won't be able to retrieve more > information about the process. */ > -- > 2.47.1