develooper Front page | perl.perl5.porters | Postings from July 2012

Re: [perl #113980] [PATCH] pp_syscall: "I32 retval" truncates thereturned value

Thread Next
Oleg Nesterov
July 5, 2012 02:14
Re: [perl #113980] [PATCH] pp_syscall: "I32 retval" truncates thereturned value
Message ID:

I do not know if it is OK to reply to,
so I CC'ed you explicitly.

On 07/04, Father Chrysostomos via RT wrote:
> I don’t supposed it’s possible to
> write an automated test for this, is it?

Well, please see below. Not sure it is the best...

So. The test-case assumes 64-bit linux, otherwise it won't work.

It exploits the fact that vdso is mmapped at "high" address which
can't fit in I32.

It does mremap(vdso_addr, 1, 1, 0) which is "nop" but should return
the original address.

Btw, "-w" complains:

	Hexadecimal number > 0xffffffff non-portable at ...

a bit annoying on 64-bit systems... Not sure why Perl_grok_hex()
thinks this is not portable.


#!/usr/bin/perl -w
use strict;

sub find_vdso()
	open my $maps, '<', '/proc/self/maps' or die;
	/^(.*?)-.*\[vdso\]$/ and return hex $1 for <$maps>;

my $vdso_addr = find_vdso || die 'not 64-bit linux?';

my $ret = syscall 25,		# __NR_mremap
		$vdso_addr,	# old_addr
		1,		# old_len
		1,		# new_len
		0,		# flags
		0;		# new_addr (unused)

$ret == $vdso_addr or die "FAILED\n";

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About