Closed Bug 784226 Opened 12 years ago Closed 11 years ago

dom/wifi does not handle JellyBean wpa supplicant API and pass corrupted string to wifi_connect_on_socket_path

Categories

(Core :: DOM: Device Interfaces, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla24

People

(Reporter: romaxa, Assigned: mwu)

References

Details

Attachments

(1 file, 4 obsolete files)

Attempt to run and init wifi on JB 4.1.1, got failed with message:
E/WifiHW  (  750): Unable to open connection to supplicant on "/data/misc/wifi/sockets/�ŰLF|D$h#hC���2�رM": No such file or directory


Backtrace show that it seems ctypes not handling JB wpa api correctly
#0  wifi_connect_on_socket_path (index=1, path=0x446cd2c4 "/data/misc/wifi/sockets/\265Ű\034L\005F|D$h#hC\223\377\367\062\372ر\031M") at hardware/libhardware_legacy/wifi/wifi.c:620
#1  0x40039826 in wifi_connect_to_supplicant (ifname=<optimized out>) at hardware/libhardware_legacy/wifi/wifi.c:673
#2  0x41390344 in ffi_call_SYSV () from B2G/objdir-gecko/dist/bin/libxul.so
#3  0x41383baa in ffi_call (cif=0x471f00b0, fn=<optimized out>, rvalue=0x4a1c8ba8, avalue=<optimized out>) at B2G/gecko/js/src/ctypes/libffi/src/arm/ffi.c:228
#4  0x41381a62 in js::ctypes::FunctionType::Call (cx=0x435b6240, argc=<optimized out>, vp=0x44ef50e0) at B2G/gecko/js/src/ctypes/CTypes.cpp:5577
#5  0x4120ef80 in CallJSNative (args=<optimized out>, native=<optimized out>, cx=<optimized out>) at B2G/gecko/js/src/jscntxtinlines.h:389
#6  js::InvokeKernel (cx=0x435b6240, args=..., construct=js::NO_CONSTRUCT) at B2G/gecko/js/src/jsinterp.cpp:351
#7  0x4120ab8a in js::Interpret (cx=0x435b6240, entryFrame=0x44ef5040, interpMode=js::JSINTERP_NORMAL) at B2G/gecko/js/src/jsinterp.cpp:2423
#8  0x4120eed2 in js::RunScript (cx=0x435b6240, script=0x4600d230, fp=<optimized out>) at B2G/gecko/js/src/jsinterp.cpp:308
#9  0x4120f00c in js::InvokeKernel (cx=0x435b6240, args=..., construct=js::NO_CONSTRUCT) at B2G/gecko/js/src/jsinterp.cpp:362
#10 0x4120f3fe in Invoke (construct=js::NO_CONSTRUCT, args=..., cx=0x435b6240) at B2G/gecko/js/src/jsinterp.h:119
#11 js::Invoke (cx=0x435b6240, thisv=..., fval=..., argc=<optimized out>, argv=0x446cdb28, rval=0x446cdb30) at B2G/gecko/js/src/jsinterp.cpp:394
#12 0x411b8e22 in JS_CallFunctionValue (cx=0x435b6240, objArg=<optimized out>, fval=..., argc=1, argv=0x446cdb28, rval=0x446cdb30) at B2G/gecko/js/src/jsapi.cpp:5891
#13 0x40bfac14 in mozilla::dom::workers::EventListenerManager::DispatchEvent (this=<optimized out>, aCx=0x435b6240, aTarget=..., aEvent=0x460098b0, aRv=...) at B2G/gecko/dom/workers/EventListenerManager.cpp:406
#14 0x40f90bda in DispatchEvent (aRv=..., this=0x44c687c0, aEvent=0x460098b0) at B2G/gecko/dom/workers/EventTarget.h:52
#15 dispatchEvent (vp=0x44ef5010, self=0x44c687c0, cx=0x435b6240, obj=<optimized out>, argc=<optimized out>) at B2G/objdir-gecko/dom/bindings/EventTargetBinding.cpp:537
#16 mozilla::dom::EventTargetBinding_workers::dispatchEvent (cx=0x435b6240, obj=<optimized out>, self=0x44c687c0, argc=<optimized out>, vp=0x44ef5010) at B2G/objdir-gecko/dom/bindings/EventTargetBinding.cpp:519
#17 0x40f90d3a in mozilla::dom::EventTargetBinding_workers::genericMethod (cx=0x435b6240, argc=1, vp=0x44ef5010) at B2G/objdir-gecko/dom/bindings/EventTargetBinding.cpp:570
#18 0x4120ef80 in CallJSNative (args=<optimized out>, native=<optimized out>, cx=<optimized out>) at B2G/gecko/js/src/jscntxtinlines.h:389
#19 js::InvokeKernel (cx=0x435b6240, args=..., construct=js::NO_CONSTRUCT) at B2G/gecko/js/src/jsinterp.cpp:351
#20 0x4120f3fe in Invoke (construct=js::NO_CONSTRUCT, args=..., cx=0x435b6240) at B2G/gecko/js/src/jsinterp.h:119
#21 js::Invoke (cx=0x435b6240, thisv=..., fval=..., argc=<optimized out>, argv=0x446cdd20, rval=0x446cdd28) at B2G/gecko/js/src/jsinterp.cpp:394
#22 0x411b8ed0 in JS_CallFunctionName (cx=0x435b6240, objArg=<optimized out>, name=<optimized out>, argc=<optimized out>, argv=0x446cdd20, rval=0x446cdd28) at B2G/gecko/js/src/jsapi.cpp:5877
#23 0x40bfa596 in mozilla::dom::workers::events::DispatchEventToTarget (aCx=0x435b6240, aTarget=0x46009040, aEvent=0x460098b0, aPreventDefaultCalled=0x446cdd4b) at B2G/gecko/dom/workers/Events.cpp:1081
#24 0x40c01fa2 in (anonymous namespace)::MessageEventRunnable::WorkerRun (this=0x4a745460, aCx=0x435b6240, aWorkerPrivate=0x43215400) at B2G/gecko/dom/workers/WorkerPrivate.cpp:822
#25 0x40c00cb8 in mozilla::dom::workers::WorkerRunnable::Run (this=0x4a745460) at B2G/gecko/dom/workers/WorkerPrivate.cpp:1799
#26 0x40c03ba6 in mozilla::dom::workers::WorkerPrivate::DoRunLoop (this=0x43215400, aCx=0x435b6240) at B2G/gecko/dom/workers/WorkerPrivate.cpp:2757
#27 0x40bfcbf0 in (anonymous namespace)::WorkerThreadRunnable::Run (this=<optimized out>) at B2G/gecko/dom/workers/RuntimeService.cpp:337
#28 0x40fc233e in nsThread::ProcessNextEvent (this=0x43ff9e20, mayWait=<optimized out>, result=0x446cdeb7) at B2G/gecko/xpcom/threads/nsThread.cpp:624
#29 0x40fa3e60 in NS_ProcessNextEvent_P (thread=<optimized out>, mayWait=<optimized out>) at B2G/objdir-gecko/xpcom/build/nsThreadUtils.cpp:220
#30 0x40fc214c in nsThread::ThreadFunc (arg=0x43ff9e20) at B2G/gecko/xpcom/threads/nsThread.cpp:257
#31 0x40184560 in _pt_root (arg=0x43cc7900) at B2G/gecko/nsprpub/pr/src/pthreads/ptthread.c:156
#32 0x400eddd4 in __thread_entry (func=0x40184501 <_pt_root>, arg=0x43cc7900, tls=<optimized out>) at bionic/libc/bionic/pthread.c:217
#33 0x400ed52c in pthread_create (thread_out=0x127b058, attr=0xbe8add18, start_routine=0x40184501 <_pt_root>, arg=0x43cc7900) at bionic/libc/bionic/pthread.c:356
wifi_connect_to_supplicant - on ICS has no arguments and on JB it takes ifname char argument, same for some other functions
Blocks: gonk-jb
Dear Oleg,

After porint to JB use your patch, I found wifi function does not work.

In you patch  wifi_worker.js 
case "start_supplicant":
	    var ret = libhardware_legacy.start_supplicant(1);
	    debug("WIFI: start_supplicant: " + ret + "\n");
	    postMessage({ id: id, status: ret });
	    break;

libhardware_legacy.start_supplicant(1);
means to start p2p_supplicant,not to start wpa_supplicant
which cause wifi cannot use wpa_supplicant.

I change to libhardware_legacy.start_supplicant(0);
Then wifi module work well.

The best way is add parameter for start_supplicant to choose wpa or p2p.
ok, I see. thanks, will update patches.
Attached patch WIP wifi fix (obsolete) — Splinter Review
This fix is a bit less hacky. I can list networks but not connect. There's probably some issue with the dhcp stuff.

The nexus 4 will require additional hacks due to its unusual wireless init requirements.
Got things working. Turns out there's a bug in libnetutil. It's fixed upstream but our tag (or any newer one) doesn't have it.

https://android.googlesource.com/platform/system/core/+/ba2ba5c011a3fb13cba538296b70888dd0fb129b
https://github.com/marcofreda527/jb412gecko/commit/e13c4272162fb4c42ec1d5059f01a9ce209386f9

The link above is what we did temporarily to let wifi work on JB 4.1.2.
Just for your reference.
Assignee: nobody → mwu
Attachment #653660 - Attachment is obsolete: true
Attachment #653661 - Attachment is obsolete: true
Attachment #760657 - Attachment is obsolete: true
Attachment #764407 - Attachment is obsolete: true
Attachment #764508 - Flags: review?(mrbkap)
Note that on the nexus 4, we currently also need these two commands to setup wifi:

adb shell "echo STA > /sys/module/wlan/parameters/fwpath"
adb shell setprop net.hostname foobar
blocking-b2g: --- → koi?
Comment on attachment 764508 [details] [diff] [review]
Support libhardware_legacy and libnetutils on JB, v2

Review of attachment 764508 [details] [diff] [review]:
-----------------------------------------------------------------

Vincent, can you review this?
Attachment #764508 - Flags: review?(vchang)
Comment on attachment 764508 [details] [diff] [review]
Support libhardware_legacy and libnetutils on JB, v2

Review of attachment 764508 [details] [diff] [review]:
-----------------------------------------------------------------

The patch looks good, thank you. 
One thing in my mind is how can we handle the wpa_supplicant API 
changes in more graceful way. Using sdkversion is good enough for now.
Attachment #764508 - Flags: review?(vchang) → review+
Attachment #764508 - Flags: review?(mrbkap)
(In reply to Vincent Chang[:vchang] from comment #13)
> The patch looks good, thank you. 
> One thing in my mind is how can we handle the wpa_supplicant API 
> changes in more graceful way. Using sdkversion is good enough for now.

I think we can clean things up a little bit by dropping GB support. However, the only other option than sdkversion that I can think of is preprocessing these files.. which isn't very graceful either, though it is more efficient.
https://hg.mozilla.org/mozilla-central/rev/cf549bdc7d87
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla25
Target Milestone: mozilla25 → mozilla24
> adb shell setprop net.hostname foobar
Not quite sure where is the proper position to set the hostname ? It's a little strange for me if we set the hostname in wifi module ? Any comments is welcome.
Flags: needinfo?(mwu)
(In reply to Vincent Chang[:vchang] from comment #17)
> > adb shell setprop net.hostname foobar
> Not quite sure where is the proper position to set the hostname ? It's a
> little strange for me if we set the hostname in wifi module ? Any comments
> is welcome.

Hostname does not need to be set anymore. See comment 7 for the commit that fixes this issue.
Flags: needinfo?(mwu)
blocking-b2g: koi? → ---
Removing koi? since this is in gecko 24 which will be the basis for Firefox OS 1.2.
Oops, I mean that 24 < _26_ which will be the basis of b2g 1.2
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: