From patchwork Sun Nov 23 15:19:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Thibault X-Patchwork-Id: 3858 Received: (qmail 17136 invoked by alias); 23 Nov 2014 15:19:57 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 17125 invoked by uid 89); 23 Nov 2014 15:19:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: sonata.ens-lyon.org Received: from sonata.ens-lyon.org (HELO sonata.ens-lyon.org) (140.77.166.138) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Sun, 23 Nov 2014 15:19:54 +0000 Received: from localhost (localhost [127.0.0.1]) by sonata.ens-lyon.org (Postfix) with ESMTP id 505ED200AF; Sun, 23 Nov 2014 16:19:51 +0100 (CET) Received: from sonata.ens-lyon.org ([127.0.0.1]) by localhost (sonata.ens-lyon.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id SbXA-c4HZZeG; Sun, 23 Nov 2014 16:19:51 +0100 (CET) Received: from type.youpi.perso.aquilenet.fr (youpi.perso.aquilenet.fr [80.67.176.89]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by sonata.ens-lyon.org (Postfix) with ESMTPSA id 05FCC200A8; Sun, 23 Nov 2014 16:19:51 +0100 (CET) Received: from samy by type.youpi.perso.aquilenet.fr with local (Exim 4.84) (envelope-from ) id 1XsYx0-00077l-6v; Sun, 23 Nov 2014 16:19:46 +0100 Date: Sun, 23 Nov 2014 16:19:46 +0100 From: Samuel Thibault To: Joel Brobecker Cc: bug-hurd@gnu.org, thomas@codesourcery.com, gdb-patches@sourceware.org Subject: Re: [PATCHv2,Hurd] Fix deallocation after proc_getprocinfo call Message-ID: <20141123151946.GF4576@type.youpi.perso.aquilenet.fr> Mail-Followup-To: Joel Brobecker , bug-hurd@gnu.org, thomas@codesourcery.com, gdb-patches@sourceware.org References: <20141102152537.GG2991@type.youpi.perso.aquilenet.fr> <20141123074452.GC7136@adacore.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141123074452.GC7136@adacore.com> User-Agent: Mutt/1.5.21+34 (58baf7c9f32f) (2010-12-30) 2014-10-02 Samuel Thibault * gdb/gnu-nat.c (inf_validate_procinfo): Multiply the number of elements pi_len by the size of the elements before calling vm_deallocate. (inf_validate_task_sc): Likewise, and properly deallocate the noise array. diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index d17a750..6dbf31d 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -804,7 +804,8 @@ inf_validate_procinfo (struct inf *inf) inf->nomsg = !!(pi->state & PI_NOMSG); if (inf->nomsg) inf->traced = !!(pi->state & PI_TRACED); - vm_deallocate (mach_task_self (), (vm_address_t) pi, pi_len); + vm_deallocate (mach_task_self (), (vm_address_t) pi, + pi_len * sizeof (*(procinfo_t) 0)); if (noise_len > 0) vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len); } @@ -844,9 +845,10 @@ inf_validate_task_sc (struct inf *inf) suspend_count = pi->taskinfo.suspend_count; - vm_deallocate (mach_task_self (), (vm_address_t) pi, pi_len); + vm_deallocate (mach_task_self (), (vm_address_t) pi, + pi_len * sizeof (*(procinfo_t) 0)); if (noise_len > 0) - vm_deallocate (mach_task_self (), (vm_address_t) pi, pi_len); + vm_deallocate (mach_task_self (), (vm_address_t) noise, noise_len); if (inf->task->cur_sc < suspend_count) {