From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8275 invoked by alias); 9 Sep 2013 19:16:51 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 8266 invoked by uid 89); 9 Sep 2013 19:16:50 -0000 Received: from sibelius.xs4all.nl (HELO glazunov.sibelius.xs4all.nl) (83.163.83.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Mon, 09 Sep 2013 19:16:50 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-4.4 required=5.0 tests=ALL_TRUSTED,BAYES_00,KHOP_THREADED autolearn=ham version=3.3.2 X-HELO: glazunov.sibelius.xs4all.nl Received: from glazunov.sibelius.xs4all.nl (kettenis@localhost [127.0.0.1]) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3) with ESMTP id r89JGclR028814; Mon, 9 Sep 2013 21:16:38 +0200 (CEST) Received: (from kettenis@localhost) by glazunov.sibelius.xs4all.nl (8.14.5/8.14.3/Submit) id r89JGbpf009986; Mon, 9 Sep 2013 21:16:37 +0200 (CEST) Date: Mon, 09 Sep 2013 19:16:00 -0000 Message-Id: <201309091916.r89JGbpf009986@glazunov.sibelius.xs4all.nl> From: Mark Kettenis To: yao@codesourcery.com CC: gdb-patches@sourceware.org In-reply-to: <1378641807-24256-1-git-send-email-yao@codesourcery.com> (message from Yao Qi on Sun, 8 Sep 2013 20:03:20 +0800) Subject: Re: [PATCH 0/7 V2] Trust readonly sections if target has memory protection References: <1378432920-7731-1-git-send-email-yao@codesourcery.com> <1378641807-24256-1-git-send-email-yao@codesourcery.com> X-SW-Source: 2013-09/txt/msg00311.txt.bz2 > From: Yao Qi > Date: Sun, 8 Sep 2013 20:03:20 +0800 > > Here is the V2, to address comments to V1, > > - Warn about writes to readonly sections if trust-readonly-sections > is enabled. (patch 1/7) > - Windows targets have memory protection. (patch 7/7) > > Do some refactor in Windows related targets, add a new function > windows_init_abi (done by patch 3/7). It paves the way for patch > 7/7. > > Below the description of this series in V1: > https://sourceware.org/ml/gdb-patches/2013-09/msg00193.html > > When option "trust-readonly-sections" was introduced in this patch > http://www.sourceware.org/ml/gdb-patches/2002-01/msg00711.html, there > was the discussion to turn it on in default. However, we didn't do > that because we have a concern that bad or buggy program may modify the > code on the non-memory protected system. On the other hand, it is > highly recommended to turn this on in remote debugging. > > I am wondering if we can teach GDB to trust read-only sections if it > knows the target system has memory protection. For some targets, such > as linux, we know they do have memory protection. This is what this > patch series tries to do. What does "memory protection" mean? That a target has an MMU that allows pages to be marked read-only? That really is more a hardware feature than a OS aatribute. Even on systems that have an MMU that can mark pages read-only, system calls like mprotect(2) can be used to make read-only pages (temporarily) writable. This is done by the OpenBSD dynamic linker during relocation processing. I expect other systems implementing strict W^X to do the same. Enabling trust-readonly-sections on such systems would be a bad idea.