Closed Bug 1778211 Opened 3 years ago Closed 3 years ago

Try to reject adding virtual methods to xpidl interfaces in CDATA blocks

Categories

(Core :: XPCOM, defect)

defect

Tracking

()

RESOLVED FIXED
104 Branch
Tracking Status
firefox104 --- fixed

People

(Reporter: nika, Assigned: nika)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

In order for xpidl to correctly reflect interfaces between multiple languages, it needs to know the true layout of the interface's VTable so that it can reflect that VTable into both Rust and JS through XPConnect. If virtual methods are added to an XPIDL interface using a CDATA (%{C++) block, this throws off xpidl's ability to correctly handle this situation, and could lead to soundness issues.

This bug is to track adding a mechanism to xpidl to attempt to reject interfaces which add additional virtual methods using CDATA blocks. Non-virtual methods don't impact the layout of the VTable and so are OK.

It turns out we have a number of cases of methods being added in this way, which need to be fixed as well.

We'll probably want to do something more accurate in the future with a
custom clang static analysis pass which validates that XPIDL interfaces
have the expected vtable and struct layout, however doing so would be
more involved than the string matching done in this patch.

In addition to checking for extra virtual methods, we'll likely also
want to check for data members on interfaces, and reject them unless the
class is marked as [builtinclass] in addition to some other attribute
which we'll need to add to prevent them from being implemented in Rust
(as c++ data members will not be reflected by the rust macro).

There were 2 instances of a comment which contained the word 'virtual'
within a CDATA block. These comments were moved out of the CDATA block
to avoid triggering the error.

Pushed by nlayzell@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/51a7356478ec Reject xpidl CDATA containing 'virtual', r=xpcom-reviewers,necko-reviewers,mccr8,dragana
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 104 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: