From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20803 invoked by alias); 20 Nov 2005 16:08:54 -0000 Received: (qmail 20751 invoked by uid 22791); 20 Nov 2005 16:08:51 -0000 X-Spam-Check-By: sourceware.org Received: from nevyn.them.org (HELO nevyn.them.org) (66.93.172.17) by sourceware.org (qpsmtpd/0.31.1) with ESMTP; Sun, 20 Nov 2005 16:08:51 +0000 Received: from drow by nevyn.them.org with local (Exim 4.54) id 1EdrkG-0006w7-Ea; Sun, 20 Nov 2005 11:08:48 -0500 Date: Mon, 21 Nov 2005 04:41:00 -0000 From: Daniel Jacobowitz To: Mark Kettenis Cc: gdb-patches@sourceware.org Subject: Re: [RFA] s/PIOD_WRITE_D/PIOD_WRITE_I in inf-ptrace.c Message-ID: <20051120160847.GA26558@nevyn.them.org> Mail-Followup-To: Mark Kettenis , gdb-patches@sourceware.org References: <200511201312.jAKDCe8r008006@elgar.sibelius.xs4all.nl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200511201312.jAKDCe8r008006@elgar.sibelius.xs4all.nl> User-Agent: Mutt/1.5.8i X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2005-11/txt/msg00380.txt.bz2 On Sun, Nov 20, 2005 at 02:12:40PM +0100, Mark Kettenis wrote: > The motivation for the change in OpenBSD is very much related to an > issue we had when using gdb to debug a nasty X problem. The new > malloc(3) in OpenBSD 3.8 is pretty aggressive in inserting "guard > pages" before and after allocated memory to catch buffer overflows. > The guard pages actually do exists in the page map but have read, > write and execute permission removed from them. At one point we were > tracking a problem in X where some code in X was accessing memory > beyond the allocated area, i.e. in the guard page. The program would > segfault upon accessing that guard page, but when running in gdb, it > would appear if nothing was wrong. Examining the memory (using "x" or > "print") in gdb happily returned the contents of the guard page > because ptrace(2) was temporarily lifting the page protections. > > I'm still thinking about what needs to be changed in gdb to make > things work properly. Somehow we must differentiate between access to > I-space and access to D-space. But at least OpenBSD now provides the > low-level support to do that. Meanwhile, this patch will do as a > stopgap. Is this really the right way to solve the problem of GDB ignoring protections? Don't you have a way for the debugger to query the inferior's memory map in *BSD? Then it can do all the permission checks that it wants to, including things like "this instruction is faulting because the page is rw- instead of r-x". The bypass-permissions and dont-bypass-permissions variants may be useful to somewhat simpler programs anyway. > I'd really like to see this change in GDB 6.4, because otherwise it > will not work at all on OpenBSD 3.9. But since the release of OpenBSD > 3.9 is still months ahead, having a GDB 6.4.1 with this issue fixed > would be fine for me too. I have no objection to putting this in 6.4. -- Daniel Jacobowitz CodeSourcery, LLC