plperl and sqrt.

Started by Travis Bauerabout 25 years ago4 messagesgeneral
Jump to latest
#1Travis Bauer
trbauer@indiana.edu

I have plperl compiled, installed, and generally working on
Solaris. But when I try to execute the sqrt function, an error
is issued:

ERROR: creation of function failed: sqrt trapped by operation
mask at (eval 10) line 4.

The number after eval changes depending on where I put the line
of code which calls sqrt. Can someone tell me how to get around
this?

Thanks,

--
----------------------------------------------------------------
Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
----------------------------------------------------------------

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Travis Bauer (#1)
Re: plperl and sqrt.

Travis Bauer <trbauer@indiana.edu> writes:

I have plperl compiled, installed, and generally working on
Solaris. But when I try to execute the sqrt function, an error
is issued:
ERROR: creation of function failed: sqrt trapped by operation
mask at (eval 10) line 4.

There's an "operation mask" inside plperl that defines which Perl
opcodes it thinks are safe to allow the user to execute. I think
the mask is set pretty conservatively at the moment ... definitely
too conservatively, if it rejects sqrt :-(. But no one's gotten
round to looking at the situation more closely to decide what's
safe and what's not. Feel free to look at the documentation for
Perl's Opcode module and propose a more reasonable mask.

regards, tom lane

#3Travis Bauer
trbauer@indiana.edu
In reply to: Tom Lane (#2)
Re: plperl and sqrt.

Tom Lane (tgl@sss.pgh.pa.us) wrote:

There's an "operation mask" inside plperl that defines which Perl
opcodes it thinks are safe to allow the user to execute. I think
the mask is set pretty conservatively at the moment ... definitely
too conservatively, if it rejects sqrt :-(. But no one's gotten
round to looking at the situation more closely to decide what's
safe and what's not. Feel free to look at the documentation for
Perl's Opcode module and propose a more reasonable mask.

regards, tom lane

The existing mask seems the most reasonable. The mast is :default,
which is not the most strict, but reasonably so. It allows users to
write scripts that would consume system resources, tying up the
system, but prevents them (probably) from getting too much access to
the host system. sqrt is disables because you can use it to produce
floating point exceptions which would call $SIG{??}. I'm not sure
why this is bad, but it seems that this would violate the comparment
somehow.

Anyway, it would be nice to have a commandline switch for the
Makefile.PL script which would allow people to customize the
operation mask that plperl.so uses. I have to use the :base_math
mask because I need sqrt. When plperl is re-enabled in the
configure script, it should be added there too.

--
----------------------------------------------------------------
Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer
----------------------------------------------------------------

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Travis Bauer (#3)
Re: Re: plperl and sqrt.

Travis Bauer <trbauer@indiana.edu> writes:

... sqrt is disables because you can use it to produce
floating point exceptions which would call $SIG{??}.

That seems a little silly, unless they also lock out *all* floating
point ops plus integer division (what about divide by zero?).

I'm not sure why this is bad, but it seems that this would violate the
comparment somehow.

Offhand I think this is not reasonable or necessary for Postgres' use.
I'd support adding base_math to our standard mask.

Anyway, it would be nice to have a commandline switch for the
Makefile.PL script which would allow people to customize the
operation mask that plperl.so uses.

Submit a patch (and more importantly, documentation patches so that
people will know about this issue).

regards, tom lane