Closed
Bug 710412
Opened 14 years ago
Closed 11 years ago
nsIDOMGeoPositionOptions handling looks suspicious
Categories
(Core :: DOM: Geolocation, defect)
Tracking
()
RESOLVED
FIXED
mozilla13
People
(Reporter: smaug, Unassigned)
Details
(Keywords: sec-moderate, Whiteboard: [sg:moderate])
Attachments
(1 file, 1 obsolete file)
|
11.89 KB,
patch
|
mrbkap
:
review+
|
Details | Diff | Splinter Review |
nsIDOMGeoPositionOptions is a JS implemented object and it seems to be handled
asynchronously (it is used for example in nsGeolocationRequest::Allow()).
Since the implementation relies on xpconnect, for example maximumAge could be implemented
as a getter, so random JS could run at an unexpected time. And I have no idea
which JSContext is on the stack at that moment so don't know if there is a sg:crit
somewhere...
I believe in the spec PositionOptions should be a dictionary, not an interface.
Though Geolocation spec predates WebIDL dictionaries.
I hope the tool in bug 709569 could be useful here, since the values of
nsIDOMGeoPositionOptions could be read before using them (that is the way dictionaries
are handled).
| Reporter | ||
Updated•14 years ago
|
Assignee: nobody → bugs
Comment 1•14 years ago
|
||
fwiw (which is not a lot), during the automated crash testing I get lots of instances of crashes with geolocation stuff on the stack and some times deleted or otherwise not-nice memory addresses but have never been able to reproduce them. This has been happening for a long time. If this issue is somehow related I might see a decrease if you have a fix.
| Reporter | ||
Comment 2•14 years ago
|
||
This relies on bug 709569.
The tool creates the following class (in mozilla::dom namespace) automatically
class DOMGeoPositionOptions
{
public:
DOMGeoPositionOptions() :
enableHighAccuracy(false),
timeout(0),
maximumAge(0)
{}
nsresult Init(JSContext* aCx, const jsval* aVal);
bool enableHighAccuracy;
PRInt32 timeout;
PRInt32 maximumAge;
};
Unfortunately we don't seem to have good tests for various nsIDOMGeoPositionOptions values.
Doug, do you have any manual tests? Could you try the patch?
Attachment #581460 -
Flags: review?(doug.turner)
| Reporter | ||
Comment 3•14 years ago
|
||
Attachment #581460 -
Attachment is obsolete: true
Attachment #581460 -
Flags: review?(doug.turner)
Attachment #581461 -
Flags: review?(doug.turner)
Comment 4•14 years ago
|
||
Comment on attachment 581461 [details] [diff] [review]
patch
Review of attachment 581461 [details] [diff] [review]:
-----------------------------------------------------------------
I really don't understand these changes and like to defer them to someone that knows xpconnect better. Blake?
Attachment #581461 -
Flags: review?(doug.turner) → review?(mrbkap)
| Reporter | ||
Comment 5•14 years ago
|
||
The idea is to read the values from the JS object right after it has been passed to the method,
not later at random time.
Comment 6•14 years ago
|
||
Comment on attachment 581461 [details] [diff] [review]
patch
Review of attachment 581461 [details] [diff] [review]:
-----------------------------------------------------------------
This seems cleaner to me. I'm not sure I understand the motivation here, though. Do we call into the options object at times that are more weird than any other place we call into JS?
Either way, I like this patch. Olli, did you end up finding tests for this? I know that there are at least *some* tests for geolocation.
::: dom/ipc/ContentParent.cpp
@@ +1197,5 @@
> nsCOMPtr<nsIDOMGeoGeolocation> geo = do_GetService("@mozilla.org/geolocation;1");
> if (!geo) {
> return true;
> }
> + jsval dummy;
It looks really scary to pass an uninitialized jsval around. Even though we know it isn't used because of the null context, I'd prefer seeing this initialized to JSVAL_VOID.
Attachment #581461 -
Flags: review?(mrbkap) → review+
| Reporter | ||
Comment 7•14 years ago
|
||
(In reply to Blake Kaplan (:mrbkap) from comment #6)
> This seems cleaner to me. I'm not sure I understand the motivation here,
> though. Do we call into the options object at times that are more weird than
> any other place we call into JS?
In other cases when we're calling into content JS we for example explicitly push
JS context to stack. I don't recall any other place where we're calling into
content JS this way.
Also, per spec the values of the properties in JS object should
be assigned to internal variables when the methods are called.
> > + jsval dummy;
>
> It looks really scary to pass an uninitialized jsval around. Even though we
> know it isn't used because of the null context, I'd prefer seeing this
> initialized to JSVAL_VOID.
Indeed.
| Reporter | ||
Comment 8•14 years ago
|
||
Doug, do you know any tests (manual or automatic) for GeoPositionOptions?
Comment 9•14 years ago
|
||
guessing moderate because we don't know exactly how to trigger the issue, but it probably does happen per comment 1.
Whiteboard: [sg:moderate]
Comment 10•14 years ago
|
||
olli, nope. just have to write some.
Comment 11•14 years ago
|
||
olli, checkin-needed?
| Reporter | ||
Comment 12•14 years ago
|
||
Bah, forgot when waiting for possible tests.
| Reporter | ||
Updated•14 years ago
|
Assignee: bugs → nobody
OS: Linux → Mac OS X
Target Milestone: --- → mozilla13
Version: unspecified → Trunk
| Reporter | ||
Comment 13•14 years ago
|
||
Ok, we need to fix this to prevent a leak too :/
Updated•14 years ago
|
Keywords: sec-moderate
Comment 14•11 years ago
|
||
Olli, is this bug still relevant? Blake r+'d your patch three years ago, but you were waiting to write tests and fix a leak. :)
Flags: needinfo?(bugs)
| Reporter | ||
Comment 15•11 years ago
|
||
This is all using webidl now, so we don't run JS at unexpected times.
Status: NEW → RESOLVED
Closed: 11 years ago
Flags: needinfo?(bugs)
Resolution: --- → FIXED
Updated•11 years ago
|
Group: core-security → core-security-release
Updated•10 years ago
|
Group: core-security-release
You need to log in
before you can comment on or make changes to this bug.
Description
•