emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#28489: closed (27.0.50; eieio-persistent slot type


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#28489: closed (27.0.50; eieio-persistent slot type validation should be a bit smarter)
Date: Sat, 14 Oct 2017 12:16:02 +0000

Your message dated Sat, 14 Oct 2017 14:13:34 +0200
with message-id <address@hidden>
and subject line Re: bug#28489: Acknowledgement (27.0.50; eieio-persistent slot 
type validation should be a bit smarter)
has caused the debbugs.gnu.org bug report #28489,
regarding 27.0.50; eieio-persistent slot type validation should be a bit smarter
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
28489: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=28489
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 27.0.50; eieio-persistent slot type validation should be a bit smarter Date: Sun, 17 Sep 2017 17:43:58 -0700 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)
EIEIO object slots can have a :type that looks like "(or thing1 thing2
...)", meaning, obviously, that the value of the slot is legal if it is
of any of those types.

`eieio-persistent-validate/fix-slot-value' makes a first pass over the
slot type specification, to see if any of the "things" are class
symbols. The checking is done by
`eieio-persistent-slot-type-is-class-p', which is able to handle an `or'
statement. The bug comes with:

((eq (car-safe type) 'or)
 ;; If type is a list, and is an or, it is possibly something
 ;; like (or null myclass), so check for that.
 (let ((ans nil))
   (dolist (subtype (cdr type))
     (setq ans (eieio-persistent-slot-type-is-class-p
                subtype)))
   ans))

In effect, only the last element of the `or' statement is checked, which
is obviously a bug. The Right Thing would probably be to return all the
valid class types in the list (with `seq-filter' or its equivalent), and
then change the rest of the code to accept that list.

Otherwise, the spec and value get passed to `cl-typep' directly, which
would successfully validate, except that "value" is still an object
construction form, not a constructed object.

It just seems like there's a lot of overlap between this and `cl-typep'.
And, coincidentally, I'm getting bug reports about the very slow
performance of `eieio-persistent-read'! I wonder if `cl-typep' could be
taught to handle some more of these cases.

The minimum fix seems to be to have
`eieio-persistent-slot-type-is-class-p' return a list of classes when
necessary. I can take a whack at a patch for that, if acceptable.

In GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.22.21)
 of 2017-09-17 built on clem



--- End Message ---
--- Begin Message --- Subject: Re: bug#28489: Acknowledgement (27.0.50; eieio-persistent slot type validation should be a bit smarter) Date: Sat, 14 Oct 2017 14:13:34 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.0.90 (gnu/linux)
Eric Abrahamsen <address@hidden> writes:

> On 09/28/17 20:35 PM, Noam Postavsky wrote:
>> Eric Abrahamsen <address@hidden> writes:
>>
>>> Essentially it is validating twice, both before and after the actual
>>> objects are created. I don't have a very firm grasp of all the code
>>> involved, but in principle I would prefer just to eval all object
>>> construction forms regardless, and then let it blow up at "real"
>>> validation time -- it was going to blow up anyway.
>>
>> Hmm, yeah, it does look the prevalidation is mostly redundant work.  The
>> docstring of eieio-persistent-convert-list-to-object mentions malicious
>> code, perhaps the prevalidation should be with unsafep (i.e., don't try
>> to typecheck anything, just make sure it's safe to eval).  This would
>> require that object constructors could be marked safe though.
>
> I've never looked at `unsafep' and don't know what's involved in marking
> object constructors as safe, but that certainly sounds like the right
> solution.
>
> Object creation *ought to* be safe. First, properties are already
> stripped from strings. Second, the only way a creation of an object
> could have side effects is if someone overloaded `initialize-instance'
> or `shared-initialize' and inserted random hard-drive-destroying code
> there. But `eieio-persistent-read' can't do that by itself; it would
> have to be run in conjunction with a separate malicious library.
>
> Otherwise, object creation really just involves making objects,
> validating the data that 
>
> Aga
>
>>> But again, my patch or something like it would be enough to get
>>> everything working as advertised.
>>
>> Right.  I think your patch is probably fine, though a few tests might a
>> good idea too.
>
> Tests are an excellent idea. Why don't I fool with this patch a bit
> longer, write some tests, and commit the smallest change possible. Then
> open another bug report on the larger question of validation, and the
> possibility of marking object constructors as safe.


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]