From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id Bt7aHFjTyWf2JAcAWB0awg (envelope-from ) for ; Thu, 06 Mar 2025 11:54:48 -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=VL75YmeL; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 63C671E105; Thu, 6 Mar 2025 11:54:48 -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 9CE4F1E08E for ; Thu, 6 Mar 2025 11:54:47 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 14A4B385840C for ; Thu, 6 Mar 2025 16:54:42 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14A4B385840C 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=VL75YmeL Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by sourceware.org (Postfix) with ESMTPS id 6B0EA3858D20 for ; Thu, 6 Mar 2025 16:54:09 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6B0EA3858D20 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 6B0EA3858D20 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::82a ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741280049; cv=none; b=ViFca8plvJPc2WLmFVQanKkGTh3p3q1siWMtNKZZAsdUJHJhraIylMFpHrDkdkP06g9pS0dzaUMzQczVbM645JG2jEc6tFbKDgYrJOLbVhMgWIpni8QmQWUAL6Ijfmfe8yqW8Dmf5owJwHbpAVwnu9361blO51lPAgdw+9qfEnE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1741280049; c=relaxed/simple; bh=peMov9tbP4BRk65dWjvGHUAFWNY4UECQeIYGdorW4SQ=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=M1TB8aXdi/sxS8FkmdScC0Q7MQcdE2TJ6cV+XpgxVU7VLn6KPp8Pvxx0GWp9OaOMX0fcNh6THw6XLDK1k4CaDEsuQlx9ZnFEyYQp5CcjyTb2Ro8qcNAlrzOQ63EU9jKr/PL5QRJL3eKoRNUTYtu+jcIirDFlpWfnskjcfhwmOX8= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6B0EA3858D20 Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-474fba180cfso7281671cf.3 for ; Thu, 06 Mar 2025 08:54:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zetier.com; s=gm; t=1741280048; x=1741884848; darn=sourceware.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:resent-message-id:resent-date:resent-from:resent-to :from:to:cc:subject:date:message-id:reply-to; bh=2e5E2woazAftQn6VWDWHq9Ir3pvf+3j1ZVQw4s1hic8=; b=VL75YmeLjN2DPQnU6kEkGzanYKSQTKHP37B/M44vm14grnvsFQ8zQrKjzgQEcs6X5A uAqLstPbAvuBOTuUOWgX8Xrnv2wNRzwa2Xntv9ewwC++9qHtQL4IOjlfjcp79UmE7OGz sPuWsaU0ufqBIWc+HfO1H5Ml5iEX3shyFrEY7q/uYkWLV7oF6pTDD/rclCbbLWqLTMof Gxga3/vOTcJa35THklf4En9yuy6DVWpLKROLmVoKqU4d6m9UxmXZ0JnMVEtg0zSYQXLv KxRdKT5kSkPw47m7Na75qsyfDdH4wnQmEhyngUxby85TA9hBmLkUmWJRYSUwRNCkLCRe 9gyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741280048; x=1741884848; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:to:from:resent-message-id:resent-date:resent-from:resent-to :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2e5E2woazAftQn6VWDWHq9Ir3pvf+3j1ZVQw4s1hic8=; b=N5j3dTGaa3M+qidOWMa8lQ4dv5E+uRKR3vO4zG01lnjK0Wt5FUTjP4XpatvCm8cNoB LSei3IgTymjtUONVi8LgzNtGQ8FZ5j2xY0kce1IrxpHQFuvzKoK+YPFltK0nqiyZn26r mXSEMOEWnDKQsCBkNEN68ZGo0+oQfO7/OHDatK0gS0LXYPVk+ldX35+krwMbNUOrtx4v 8j7QWEPudgcM9CZim+E4EbnnIBS8ldv2tmY+i8qKGyaSXcj/324cHRLZerh0k5ovfNVn QE0KzHnU5I+OjXLdg7gi5+aokVHSAunR84UPupZykQeTy2PmCSkNgS9cXHMivEjdNyFf 6fpQ== X-Forwarded-Encrypted: i=1; AJvYcCVgZTbfY+Q4bCIKc9msO6ZHV5GgD20bxqecFaalJWwmzhQ0Iu2zc6PchoBkiLzJqzsL9YAWwagaPuk0hg==@sourceware.org X-Gm-Message-State: AOJu0Yy7qadIGrP9QXQ9wjfca4R142Lr1NxuoDl/H14ER3v9iN8p+qUZ OzErvv3wQ3Y5nE1g/Yqc54MrDBEFg5R9h1z3liciqU1A6VwbYIKM8nahV6FfQes1jzb0ahXMauX slKY= X-Gm-Gg: ASbGnctKDGF2PkOelRMx+u4zpWlhrJFZXuMdKXmxgMMZ/sfgDzottwVj1ChZ41H5rLL wHbYxkekd9eQTf3gTRJoQm2dJcT4IH+eg7Vk3hPiJUwchFTazPkMtAh0XG6FUh/T3ecQSclZWHY VKl6skWVzPQtD4zkKFNk9n8cdpA16xiweBJmBDeMcLqpjCuUOdTwLU0xyjL6eckdD9EKyO/1+8i wb6BeW/1qIkQScqEzNl6iwxAJfvMooqf4jA1YY2TXenSoF2wJsm9/DGxaxzvR0ndfk4wHUKhcU2 TYdIG/ML4erzw3dtGU29T/bTesdus57WIfunr3R3c2+ARG07jXAtdS+eqcoWpw== X-Google-Smtp-Source: AGHT+IGrlV0ZbyQgGFk0i2wYMIbkuaQm9NKFcQJS9XWz+oBt0c2RdAE13/aBDdWk03q7ABTpFPGlkw== X-Received: by 2002:a05:622a:181e:b0:474:fe6c:be44 with SMTP id d75a77b69052e-4750b43aa1dmr112109351cf.14.1741280047771; Thu, 06 Mar 2025 08:54:07 -0800 (PST) Received: from brandonb.zetier.com ([65.222.209.234]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-4751db4c965sm9233481cf.76.2025.03.06.08.54.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Mar 2025 08:54:07 -0800 (PST) Resent-To: gdb-patches@sourceware.org Resent-From: Brandon Belew Resent-Date: Thu, 06 Mar 2025 11:54:06 -0500 Resent-Message-ID: Received: from brandonb.zetier.com ([65.222.209.234]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7c3b4f3bf73sm325947585a.8.2025.03.04.05.47.36 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Mar 2025 05:47:36 -0800 (PST) From: Brandon Belew To: Joel Brobecker Subject: [PATCH v3] [PR corefiles/32441] Fix segfault if target_fileio_read_alloc fails In-Reply-To: (Joel Brobecker's message of "Tue, 4 Mar 2025 07:12:32 +0400") References: <87ikouz5ys.fsf@redhat.com> Date: Tue, 04 Mar 2025 08:47:31 -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 Was: Re: GDB 16.3 release - 2025-03-01 update. This is a v3 of my patch as requested by Joel Brobecker with a link to the bugzilla PR included in the commit message. Joel Brobecker writes: > Hello Brandon, > >> Hi, I'm a new contributor and I don't have permissions to modify the >> Target Milestone on the bug I reported in bugzilla, but bug 32441 [1] >> has an attached patch that was just approved by Andrew Burgess; see >> Message ID <87ikouz5ys.fsf@redhat.com> [2]. This fixes a segfault in >> core file generation, much like the other corefiles/32634 fix already >> being included in the 16.3 release. I would love to see this fix >> included! >> [1] https://sourceware.org/bugzilla/show_bug.cgi?id=32441 >> [2] https://sourceware.org/pipermail/gdb-patches/2025-February/215909.html > > Thanks for the heads up and the references. > > I think the request to backport looks reasonable to me, but you will > need one of the Global Maintainers to also approve the backport. > > If you haven't pushed the patch to master yet, can you amend > the commit message to include the URL to the GDB PR so that > bugzill automatically gets notified that this was pushed, and > logs its in the activity log? > > If you have already pushed to master, no problem, but can you > at least make sure you do this for the version that gets pushed > to the gdb-16-branch (after it gets approved for backporting)? > > Thank you! Thanks for the updates, Joel. I do not have any commit rights, so my patch hasn't been comitted anywhere. I'm not sure what that process looks like as this is my first contribution. I've been trying to get this merged since December and Andrew gave it a "LGTM" on Feb 28; does someone else need to approve it before it can be merged? Is there someone else I need to ping to request the patch be merged now that it has been approved? Given that it hasn't been merged yet, I can update the commit message to include the link to bugzilla, although I did include "[PR corefiles/32441]" in the subject line of my patch which I thought was sufficient. At any rate, here's an updated patch that includes the URL within the commit message. --- 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. Fixes https://sourceware.org/bugzilla/show_bug.cgi?id=32441 --- 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