From: Patrick Bernaud <patrickb@chez.com>
To: 12095@debbugs.gnu.org
Subject: bug#12095: Protecting pointer on bytevector with guardian does not protect memory
Date: Mon, 30 Jul 2012 18:01:09 +0200 [thread overview]
Message-ID: <20502.44997.295661.951990@vagabond.local> (raw)
[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 658 bytes --]
The memory from a bytevector of which a pointer is taken (with
'bytevector->pointer') can be overwritten even if that pointer has
been put inside a guardian. 'make-c-struct' from (system foreign) is
using 'bytevector->pointer'.
With the test script attached:
$ guile -v | head -1
guile (GNU Guile) 2.0.6.8-cc26b9-dirty
$ guile --no-auto-compile -s test.scm
#<pointer 0x974648c>
#vu8(1 1 1 1 1 1 1 1 1 1)
#vu8(1 1 1 1 1 1 1 1 1 1)
#vu8(110 103 45 108 101 110 103 116 104 0) <<<< memory overwrite with "ng-length\0" from module
#<pointer 0x974648c>
$
With auto compilation turned on, it looks like the problem can not be
reproduced.
--
Patrick Bernaud
[-- Attachment #2: test.scm --]
[-- Type: application/octet-stream, Size: 526 bytes --]
(use-modules (system foreign) (rnrs bytevectors))
(define my-guardian (make-guardian))
(define len 10)
(define x (bytevector->pointer (make-bytevector len 1)))
(define a (pointer-address x))
(display x)(newline)
(my-guardian x)
;(my-guardian (pointer->bytevector x len))
(set! x #f)
(write (pointer->bytevector (make-pointer a) len))(newline)
(gc)
(write (pointer->bytevector (make-pointer a) len))(newline)
(use-modules (htmlprag))
(write (pointer->bytevector (make-pointer a) len))(newline)
(display (my-guardian))(newline)
next reply other threads:[~2012-07-30 16:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-30 16:01 Patrick Bernaud [this message]
2012-08-06 16:37 ` bug#12095: Protecting pointer on bytevector with guardian does not protect memory Ian Price
2012-08-07 3:32 ` Daniel Hartwig
2012-10-06 21:41 ` Ludovic Courtès
2012-10-07 2:56 ` Daniel Hartwig
2012-10-07 20:38 ` Ludovic Courtès
2012-10-07 23:49 ` Daniel Hartwig
2012-10-08 13:44 ` Ludovic Courtès
2012-10-08 14:10 ` Daniel Hartwig
2012-10-08 15:42 ` Ludovic Courtès
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20502.44997.295661.951990@vagabond.local \
--to=patrickb@chez.com \
--cc=12095@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).