Well, another module. A guy called me a module man
If we can compile this module we can (hopefully) have native usb/wifi tether on our phone.
Other benefits:
- Firewall apps
- Transparent proxies
- NAT
I'll start trying to make this work on our current kernel. Contribution is appreciated.
Github repo is here : https://github.com/doixanh/X8Features
PLEASE DON'T SPAM THIS DEV THREAD WITH UNCONTRIBUTED POSTS
Once again, great work!
Continue with the modules, you are solving many things extremely fast!
Big thank you from me for contributing to the X8 community!
All u need to do is implement the needed hooks missing from the stock kernel for iptables to attach on.
Sent from my GB MiniCM
Hello. If this module get worked, will be able the reverse usb tether(PC -> phone). I.e to have internet on my phone from the computer via USB.
Can someone explain what is this?
Great job! I use third-party programs, but is good to have native tether. One question. Will I need drivers for PC with native tether?
http://www.google.com/url?sa=t&sour...sg=AFQjCNGsYN4VLe4oQLOtuPksDb87g537lg&cad=rja
maybe it help
He3aBuCuM said:
Hello. If this module get worked, will be able the reverse usb tether(PC -> phone). I.e to have internet on my phone from the computer via USB.
Click to expand...
Click to collapse
no this would allow your phone to become a wifi hot spot, why would you need it the other way? if you have no wifi network you can download APK's to your computer and move to phone and install from your SD card
it would also allow you to use firewall apps to block all apps but the ones you want from connecting to your mobile internet to save you money.
So far, I managed to compile and insmod "netfilter.ko" with no error. But whenever I try to insmod iptable_filter.ko, I got a kernel crash.
The following modules has been insmoded - ordered to solve module dependencies.
insmod netfilter.ko
insmod x_tables.ko
insmod xt_tcpudp.ko
insmod nf_sockopt.ko
insmod ip_tables.ko
insmod ipt_addrtype.ko
insmod iptable_filter.ko <--- crashed here
Kernel crash message:
Code:
[ 466.135716] [<bf06b354>] (nf_register_hook+0x0/0x90 [netfilter]) from [<bf06b408>] (nf_register_hooks+0x24/0x64 [netfilter])
It seems the our nf_register_hook is not working.
Some logs:
Code:
[ 163.394843] nf_register_hook reg=BF059844
[ 163.395055] mutex locking
[ 163.395905] list for each entry pf=2, hooknum=1
<1>Unable to handle kernel NULL pointer dereference at virtual address 00000000
Could u share sources for those? Thanks.
Sent from my X10mini using XDA App
I'm at home now, I put all sources at work I changed lots of things to be able to compile it as module. Maybe I will need to upload whole /kernel/net/ipv4 and /kernel/net/netfilter branches.
I'll upload tomorrow.
It seems that the linked list is empty, that's why it couldn't initialize the list.
nobodyAtall: I've just created a github repo for X8Netfilter, I will push modifications soon.
doixanh said:
It seems that the linked list is empty, that's why it couldn't initialize the list.
nobodyAtall: I've just created a github repo for X8Netfilter, I will push modifications soon.
Click to expand...
Click to collapse
Thanks mate. I'll take a look and see if I can help.
Ok, everything pushed. Let's have fun with it my friend.
Repo is here : https://github.com/doixanh/X8Netfilter
The last time there were null pointers in linked lists because the initialization code (netfilter_init) was not executed. I forgot that now it's a module, so we have to declare module_init.
I added module_init into it. Insmoded fine now, but iptables tool still complains:
iptables v1.3.7: can't initialize iptables table `filter'
Click to expand...
Click to collapse
What are we missing?
/edit : post #200
/edit #2 : during xRecovery to switch to another ROM for testing, I bricked my lovely phone. There are lots of junk files in /system. Now I have to save my X8
/edit #3 : oh and I forgot that x10 mini has another offset for synchronize_rcu() - it should be 0xC0098F88. You have to modify it in netfilter.h
In the kernel config I didn't include xtables (required by iptable_filter) so maybe it's a problem.
I included, compiled, but still the same. I think the problem comes from the iptables userspace tool.
@nobodyAtall: can you modify and compile iptables.c (included in CM6/7 source). We need to know the reason that TC_INIT returns null. Before each "return NULL" you can put a printf so we can know why it's unable to load the table.
I cannot compile android iptables now (at work, the PC is really really slow).
I also pushed kernel config for my current kernel build, and a script to load the modules in order to solve dependencies.
Thanks.
doixanh said:
In the kernel config I didn't include xtables (required by iptable_filter) so maybe it's a problem.
I included, compiled, but still the same. I think the problem comes from the iptables userspace tool.
@nobodyAtall: can you modify and compile iptables.c (included in CM6/7 source). We need to know the reason that TC_INIT returns null. Before each "return NULL" you can put a printf so we can know why it's unable to load the table.
I cannot compile android iptables now (at work, the PC is really really slow).
I also pushed kernel config for my current kernel build, and a script to load the modules in order to solve dependencies.
Thanks.
Click to expand...
Click to collapse
I'm getting undefined references when building the kernel with your github files / .config file. Specifically:
kernel/include/linux/netfilter.h:193: undefined reference to `nf_hook_slow'
kernel/net/ipv4/ip_input.c:270: undefined reference to `nf_hooks'
kernel/net/ipv4/ip_input.c:270: undefined reference to `nf_hooks'
and many more.
Strange, I don't have any problem at all. I compiled those modules with
Code:
ARCH=arm CROSS_COMPILE=arm-eabi- make modules
oh and btw, I compiled with this kernel from SE: x10_x10mini_x10minipro_x8_eclair_2.1.A.0.390.tar.gz
doixanh said:
Strange, I don't have any problem at all. I compiled those modules with
Code:
ARCH=arm CROSS_COMPILE=arm-eabi- make modules
oh and btw, I compiled with this kernel from SE: x10_x10mini_x10minipro_x8_eclair_2.1.A.0.390.tar.gz
Click to expand...
Click to collapse
Ok, it wont make the kernel image but makes the modules.
Here's what's loaded:
Code:
localhost netfilter # ls
arp_tables.ko nfnetlink.ko xt_hashlimit.ko xt_realm.ko
ip_tables.ko nfnetlink_log.ko xt_iprange.ko xt_recent.ko
ipt_LOG.ko x_tables.ko xt_length.ko xt_sctp.ko
ipt_ULOG.ko xt_CLASSIFY.ko xt_limit.ko xt_statistic.ko
ipt_addrtype.ko xt_NFLOG.ko xt_mac.ko xt_string.ko
ipt_ah.ko xt_NFQUEUE.ko xt_multiport.ko xt_tcpudp.ko
iptable_filter.ko xt_TCPOPTSTRIP.ko xt_owner.ko xt_time.ko
iptable_mangle.ko xt_TRACE.ko xt_pkttype.ko xt_u32.ko
iptable_raw.ko xt_comment.ko xt_policy.ko
netfilter.ko xt_esp.ko xt_quota.ko
localhost netfilter # sh /sdcard/insmodnet
[B]insmod: init_module 'xt_NFLOG.ko' failed (No such file or directory)
insmod: init_module 'xt_string.ko' failed (No such file or directory)[/B]
localhost netfilter # lsmod
iptable_filter 2700 0 - Live 0xbf1e7000
ipt_addrtype 2388 0 - Live 0xbf1e1000
ip_tables 11264 1 iptable_filter, Live 0xbf1d9000
xt_u32 2036 0 - Live 0xbf1d3000
xt_time 2880 0 - Live 0xbf1cd000
xt_tcpudp 3016 0 - Live 0xbf1c7000
xt_statistic 1844 0 - Live 0xbf1bb000
xt_sctp 2672 0 - Live 0xbf1b5000
xt_recent 9308 0 - Live 0xbf1ad000
xt_realm 1492 0 - Live 0xbf1a7000
xt_quota 1752 0 - Live 0xbf1a1000
xt_policy 3120 0 - Live 0xbf19b000
xt_pkttype 1596 0 - Live 0xbf195000
xt_owner 2668 0 - Live 0xbf18f000
xt_multiport 3160 0 - Live 0xbf189000
xt_mac 1576 0 - Live 0xbf183000
xt_limit 2224 0 - Live 0xbf17d000
xt_length 1760 0 - Live 0xbf177000
xt_iprange 2640 0 - Live 0xbf171000
xt_hashlimit 9964 0 - Live 0xbf169000
xt_esp 1852 0 - Live 0xbf163000
xt_comment 1492 0 - Live 0xbf15d000
xt_TRACE 1484 0 - Live 0xbf157000
xt_TCPOPTSTRIP 1956 0 - Live 0xbf151000
xt_NFQUEUE 1716 0 - Live 0xbf070000
xt_CLASSIFY 1536 0 - Live 0xbf023000
x_tables 14212 25 ipt_addrtype,ip_tables,xt_u32,xt_time,xt_tcpudp,xt_statistic,xt_sctp,xt_recent,xt_realm,xt_quota,xt_policy,xt_pkttype,xt_owner,xt_multiport,xt_mac,xt_limit,xt_length,xt_iprange,xt_hashlimit,xt_esp,xt_comment,xt_TRACE,xt_TCPOPTSTRIP,xt_NFQUEUE,xt_CLASSIFY, Live 0xbf148000
netfilter 13564 3 iptable_filter,ip_tables,xt_TCPOPTSTRIP,[permanent], Live 0xbf142000
tiwlan_drv 838420 0 - Live 0xbf073000
ext3 110952 1 - Live 0xbf052000
jbd 49480 1 ext3, Live 0xbf040000
x8oc 6664 0 - Live 0xbf039000
synaptics_i2c_rmi4 11068 0 - Live 0xbf034000
twofish 9308 0 - Live 0xbf02c000
twofish_common 15740 1 twofish, Live 0xbf026000
dm_crypt 13052 0 - Live 0xbf01d000
dm_mod 53216 1 dm_crypt, Live 0xbf00b000
sdio 20724 1 tiwlan_drv, Live 0xbf000000
Do we need all there modules?
xt_NFLOG fails with:
xt_NFLOG: Unknown symbol nfulnl_log_packet
xt_string fails with:
xt_string: Unknown symbol textsearch_destroy
xt_string: Unknown symbol textsearch_prepare
I'm not sure, but I tried to compile and load all those modules to make it work first.
iptables tool still gives out error with
iptables -L
doixanh said:
I'm not sure, but I tried to compile and load all those modules to make it work first.
iptables tool still gives out error with
iptables -L
Click to expand...
Click to collapse
The actual error is:
iptables v1.4.7: can't initialize iptables table `filter': Table does not exist (do you need to insmod?)
Perhaps iptables or your kernel needs to be upgraded.
Which is quite *disturbing*
The actual error reported from kernel space is ENOENT (see file libiptc.c in CM sources).
Hi, I'm trying to force Xorg to use /dev/grapgics/fb0 of android. Android's /dev is binded to chroot's /dev.
When I run "cat /dev/urandom > /dev/graphics/fb0" in chroot I see random color pixels on screen, but I can't setup Xorg to properly to use fb0.
I'm using "setprop ctl.stop media && setprop ctl.stop zygote" to kill Android ui to avoid using fb0. After starting Xorg i cant see any changes on screen.
[device: Ainol Fire, A4.0.4(feiyu), Mali400Mp2, 1280x800]
Any ideas what im doing wrong?
Xorg.conf:
Code:
Section "ServerLayout"
Identifier "Default"
Screen 0 "Default Screen" 0 0
# InputDevice "Touchscreen" "CorePointer"
EndSection
#Section "InputDevice"
# Identifier "Touchscreen"
# Driver "tslib"
# Option "Device" "/dev/input/event5"
#EndSection
Section "Device"
Identifier "Configured Video Device"
Driver "fbdev"
Option "fbdev" "/dev/graphics/fb0"
EndSection
Section "Monitor"
Identifier "Configured Monitor"
DisplaySize 1280 800
EndSection
Section "Screen"
Identifier "Default Screen"
Monitor "Configured Monitor"
Device "Configured Video Device"
DefaultDepth 24
EndSection
Section "ServerFlags"
Option "DefaultServerLayout" "Default"
Xorg log on pastebin: "Wngrb9D7" (I can't post url)
Hi, on my Samsung Galaxy Tab 2 10.1" I have a running X11 with this config.
Code:
[email protected]:/# cat /etc/X11/xorg.conf
Section "ServerLayout"
Identifier "Layout0"
Screen "Screen0"
#InputDevice "Mouse0" "CorePointer"
InputDevice "cyttsp-i2c" "CorePointer"
InputDevice "Keyboard0" "CoreKeyboard"
EndSection
Section "InputDevice"
Identifier "Keyboard0"
Driver "evdev"
#Option "Device" "/dev/input/event7"
Option "Device" "/dev/input/event9"
Option "Protocol" "usb"
EndSection
Section "InputDevice"
Identifier "Mouse0"
#Driver "evdev"
Driver "mouse"
Option "Protocol" "IMPS/2"
#Option "Device" "/dev/input/event0"
Option "Device" "/dev/input/mice"
#Option "Protocol" "usb"
EndSection
Section "InputDevice"
Identifier "cyttsp-i2c"
Driver "multitouch"
Option "Device" "/dev/input/event0"
# mouse should move as fast as finger and not faster
Option "AccelerationScheme" "none"
# evdev has it, multitouch doesn't so it behaves like touchpad
# Option "IgnoreRelativeAxes" "True"
EndSection
Section "Device"
Identifier "Card0"
Driver "fbdev"
Option "fbdev" "/dev/graphics/fb0"
VendorName "Unknown"
BoardName "Unknown"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
DefaultDepth 24
SubSection "Display"
Depth 24
Modes "1024x600_60.00"
EndSubSection
EndSection
Section "ServerFlags"
Option "AutoAddDevices" "false"
EndSection
I hope it helps
I tried with conf like this and still is something wrong, can you post xorg.conf.d conf files and xorg.0.log? (or pm)
AW: [Q] chroot + framebuffer [Ainol Fire][Android 4.0.4]
Try to shutdown surfaceflinger with:
setprop ctl.stop surfaceflinger
May thats the problem...
Sent from my GT-S5830 using xda app-developers app
Only screen frezee, nothing changed on screen/buffer like a xorg cant acces to fb (im pretty sure about this). In log I cant see anything about fbdevhw, maybe it is related to problem?
//edit
On gt540 (Android 2.3.7) it works without killing android, screen goes black and xorg starts successfully, but msm7227 needs something to refresh screen (i can see desktop when im killing xorg and zygote+media gets back framebuffer). So is there any other part of android (killed zygote, media, drm, surfaceflinger) using framebuffer in Android 4.0.4 ?
//edit
Partial success, xorg is using framebuffer, but there is an errror
Anybody know how to fix it?
Code:
[[email protected] /]# xinit -- :0 ttyS0 vt1 -verbose
This is a pre-release version of the X server from The X.Org Foundation.
It is not supported in any way.
Bugs may be filed in the bugzilla at http://bugs.freedesktop.org/.
Select the "xorg" product for bugs you find in this release.
Before reporting bugs in pre-release versions please check the
latest version in the X.Org Foundation git repository.
See http://wiki.x.org/wiki/GitPage for git access instructions.
X.Org X Server 1.13.2.901 (1.13.3 RC 1)
Release Date: 2013-02-15
X Protocol Version 11, Revision 0
Build Operating System: Linux 3.2.34-1-FARM armv7l
Current Operating System: Linux localhost 3.0.8 #3 SMP PREEMPT Wed Nov 14 11:26:15 CST 2012 armv7l
Kernel command line: init=/init console=ttyS0,115200n8 hlt no_console_suspend vmalloc=256m mem=1024m logo=osd1,loaded,panel,debug hdmitx=vdacoff,powermode1,unplug_powerdown a9_clk_max=1512000000
Build Date: 24 February 2013 12:25:58AM
Current version of pixman: 0.28.2
Before reporting problems, check http://wiki.x.org
to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
(++) from command line, (!!) notice, (II) informational,
(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(==) Log file: "/var/log/Xorg.0.log", Time: Mon Mar 11 09:08:09 2013
(==) Using config file: "/etc/X11/xorg.conf"
(==) Using config directory: "/etc/X11/xorg.conf.d"
(**) ServerLayout "Layout0"
(**) |-->Screen "DefaultScreen" (0)
(**) | |-->Monitor "Configured Monitor"
(**) | |-->Device "Mali FBDEV"
(==) Automatically adding devices
(==) Automatically enabling devices
(==) Automatically adding GPU devices
(WW) The directory "/usr/share/fonts/TTF/" does not exist.
Entry deleted from font path.
(WW) The directory "/usr/share/fonts/OTF/" does not exist.
Entry deleted from font path.
(WW) The directory "/usr/share/fonts/Type1/" does not exist.
Entry deleted from font path.
(==) FontPath set to:
/usr/share/fonts/misc/,
/usr/share/fonts/100dpi/,
/usr/share/fonts/75dpi/
(==) ModulePath set to "/usr/lib/xorg/modules"
(**) Extension "Composite" is disabled
(**) Extension "RENDER" is enabled
(II) The server relies on udev to provide the list of input devices.
If no devices become available, reconfigure udev or disable AutoAddDevices.
Initializing built-in extension Generic Event Extension
Initializing built-in extension SHAPE
Initializing built-in extension MIT-SHM
Initializing built-in extension XInputExtension
Initializing built-in extension XTEST
Initializing built-in extension BIG-REQUESTS
Initializing built-in extension SYNC
Initializing built-in extension XKEYBOARD
Initializing built-in extension XC-MISC
Initializing built-in extension SECURITY
Initializing built-in extension XINERAMA
Initializing built-in extension XFIXES
Initializing built-in extension RENDER
Initializing built-in extension RANDR
Initializing built-in extension COMPOSITE
Initializing built-in extension DAMAGE
Initializing built-in extension MIT-SCREEN-SAVER
Initializing built-in extension DOUBLE-BUFFER
Initializing built-in extension RECORD
Initializing built-in extension DPMS
Initializing built-in extension X-Resource
Initializing built-in extension XVideo
Initializing built-in extension XVideo-MotionCompensation
Initializing built-in extension XFree86-VidModeExtension
Initializing built-in extension XFree86-DGA
Initializing built-in extension XFree86-DRI
Initializing built-in extension DRI2
(II) Loading /usr/lib/xorg/modules/extensions/libglx.so
(II) Module glx: vendor="X.Org Foundation"
compiled for 1.13.2.901, module version = 1.0.0
(==) AIGLX enabled
Loading extension GLX
(II) Loading /usr/lib/xorg/modules/drivers/fbdev_drv.so
(II) Module fbdev: vendor="X.Org Foundation"
compiled for 1.13.0, module version = 0.4.3
(II) FBDEV: driver for framebuffer: fbdev
(++) using VT number 1
(WW) Falling back to old probe method for fbdev
(II) Loading /usr/lib/xorg/modules/libfbdevhw.so
(II) Module fbdevhw: vendor="X.Org Foundation"
compiled for 1.13.2.901, module version = 0.0.2
(II) FBDEV(0): using /dev/graphics/fb0
(WW) VGA arbiter: cannot open kernel arbiter, no multi-card support
(**) FBDEV(0): Depth 32, (--) framebuffer bpp 32
(EE) FBDEV(0): Weight given (000) is inconsistent with the depth (32)
(EE) Screen(s) found, but none have a usable configuration.
Fatal server error:
no screens found
(EE)
Please consult the The X.Org Foundation support
at http://wiki.x.org
for help.
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE)
Server terminated with error (1). Closing log file.
xinit: giving up
xinit: unable to connect to X server: Connection refused
xinit: server error
[[email protected] /]#
So it works (24bit depth), touch as touchpad, usb keyboard/mouse works too (only if connected before startx).
And first time i get sound working in chroot (visible as pcm card) but works only with rhytmbox playing mp3 stream, when i try to play mp3 file i get gstreamer backend error (not enough data). Sound works too with flash player (10.1).
I have the same tab as you (ainol fire, F-0506 A4.2.2) and want to get ubuntu working on my device. I faced with the same problem: Xorg don't want work with my fb0. So I want know: how you solved this problem?
Sorry for my bad English
EDIT
Framebuffer works, I can see some parts of full picture, but not full. I use gnome environment and all i see is mouse pointer that doesn't respond and Hide all buttom in left bottom corner. What I am doing wrong?
EDIT
Yes, I completely right, fb works, but with lags. I don't know why.. may be this lag is in cause of using new feiyu's kernel.. I take a photo of screen but I can't show them.
Also after I choose (I MADE IT!) Shut down - my fire freeze & I can't doing anything except restart my device.
I have nexus4 and nexus7 (both are 4.3), I noticed all apps resolve dns connection as root (uid 0).
I want to know/ask, why on android, all apps resolve dns connection as root?
I block dns connection as root, then all apps can not resolve dns.
(iptables -I OUTPUT -p udp --dport 53 -m owner --uid-owner 0 -j DROP)
I also noticed, my nexus7 will resolve dns as root, if the connection blocked, then the apps will not resolve dns.
but my nexus4 will resolve dns as root first, if it blocked, then apps will resolve dns as apps-id.
why will that?
anyone have this problem?
both n4/n7 is running stock andorid 4.3 (donwload from google)
thanks.
I can confirm that something very strange is going on in Android 4.3, I'm runing the Slimrom mod and the same thing is true for me, all dns request are done as root. But to make things even stranger the dns props are set but not used, it seems like something is really broken within bioinc that makes it impossible to change dns servers on the fly.
Mine is running android stock rom for both, downloaded from google.
I still not understand, why will that.
Thanks.
Sent from my Nexus 4 using xda app-developers app
Browsing through the AOSP sources, I noticed that Android 4.3 incorporated a somewhat confusing series of commits under the heading of "dns cache per interface," which effectively causes all Bionic DNS requests to be proxied through netd. This commit is the most important element.
Here is the old implementation from Android 4.2.2:
Code:
static struct hostent *
gethostbyname_internal(const char *name, int af, res_state res)
{
const char *cp;
char *bp, *ep;
int size;
struct hostent *hp;
struct resolv_cache* cache;
[b]res_static rs = __res_get_static();[/b]
static const ns_dtab dtab[] = {
NS_FILES_CB(_gethtbyname, NULL)
{ NSSRC_DNS, _dns_gethtbyname, NULL }, /* force -DHESIOD */
{ 0, 0, 0 }
};
assert(name != NULL);
switch (af) {
case AF_INET:
size = INADDRSZ;
break;
case AF_INET6:
size = IN6ADDRSZ;
break;
default:
h_errno = NETDB_INTERNAL;
errno = EAFNOSUPPORT;
return NULL;
}
rs->host.h_addrtype = af;
rs->host.h_length = size;
[...]
h_errno = NETDB_INTERNAL;
if (nsdispatch(&hp, dtab, NSDB_HOSTS, "gethostbyname",
default_dns_files, name, strlen(name), af) != NS_SUCCESS) {
return NULL;
}
h_errno = NETDB_SUCCESS;
return hp;
Note the use of the libc resolver. The library is issuing the DNS requests directly.
By contrast, here is the new Android 4.3 implementation:
Code:
// very similar in proxy-ness to android_getaddrinfo_proxy
static struct hostent *
gethostbyname_internal(const char *name, int af, res_state res, const char *iface)
{
[b]const char *cache_mode = getenv("ANDROID_DNS_MODE");[/b]
FILE* proxy = NULL;
struct hostent *result = NULL;
[b]if (cache_mode != NULL && strcmp(cache_mode, "local") == 0) {[/b]
res_setiface(res, iface);
return gethostbyname_internal_real(name, af, res);
}
proxy = android_open_proxy();
if (proxy == NULL) goto exit;
/* This is writing to system/netd/DnsProxyListener.cpp and changes
* here need to be matched there */
if (fprintf(proxy, "gethostbyname %s %s %d",
iface == NULL ? "^" : iface,
name == NULL ? "^" : name,
af) < 0) {
goto exit;
}
if (fputc(0, proxy) == EOF || fflush(proxy) != 0) {
goto exit;
}
result = android_read_hostent(proxy);
So by default, Android 4.3 will proxy the requests through netd (owned by UID 0). This can be verified by setting DBG to 1 in system/netd/DnsProxyListener.cpp, then watching logcat:
Code:
D/DnsProxyListener( 146): argv[0]=getaddrinfo
D/DnsProxyListener( 146): argv[1]=omg.yahoo.com
D/DnsProxyListener( 146): argv[2]=^
D/DnsProxyListener( 146): argv[3]=1024
D/DnsProxyListener( 146): argv[4]=0
D/DnsProxyListener( 146): argv[5]=1
D/DnsProxyListener( 146): argv[6]=0
D/DnsProxyListener( 146): argv[7]=^
D/DnsProxyListener( 146): GetAddrInfoHandler for omg.yahoo.com / [nullservice] / [nulliface] / 1489
D/DnsProxyListener( 146): GetAddrInfoHandler, now for omg.yahoo.com / (null) / (null)
D/DnsProxyListener( 146): argv[0]=getaddrinfo
D/DnsProxyListener( 146): argv[1]=l1.yimg.com
D/DnsProxyListener( 146): argv[2]=^
D/DnsProxyListener( 146): argv[3]=1024
D/DnsProxyListener( 146): argv[4]=0
D/DnsProxyListener( 146): argv[5]=1
D/DnsProxyListener( 146): argv[6]=0
D/DnsProxyListener( 146): argv[7]=^
D/DnsProxyListener( 146): GetAddrInfoHandler for l1.yimg.com / [nullservice] / [nulliface] / 1489
D/DnsProxyListener( 146): GetAddrInfoHandler, now for l1.yimg.com / (null) / (null)
As seen in the Android 4.3 code snippet, it is possible to temporarily revert to the old behavior by setting ANDROID_DNS_MODE to "local", causing Bionic to send the request through gethostbyname_internal_real(), the old implementation. On this system, the shell user is blocked from sending network traffic via netfilter, but the root user (which owns netd) has full network access:
Code:
[email protected]:/ $ id
uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats) context=u:r:shell:s0
[email protected]:/ $ ANDROID_DNS_MODE= telnet google.com 80
telnet: can't connect to remote host (74.125.227.135): Connection refused
1|[email protected]:/ $ ANDROID_DNS_MODE=local telnet google.com 80
telnet: bad address 'google.com'
1|[email protected]:/ $
In the former case (proxied request), the application was able to look up the hostname via netd, but could not send data traffic. In the latter case (direct request), the application was not able to look up the hostname at all.
It is possible to change the systemwide default by making a tweak to system/core/rootdir/init.rc and rebuilding your kernel image:
Code:
diff --git a/rootdir/init.rc b/rootdir/init.rc
index b6d7335..d0efc46 100644
--- a/rootdir/init.rc
+++ b/rootdir/init.rc
@@ -47,6 +47,7 @@ loglevel 3
export ANDROID_ASSETS /system/app
export ANDROID_DATA /data
export ANDROID_STORAGE /storage
+ export ANDROID_DNS_MODE local
export ASEC_MOUNTPOINT /mnt/asec
export LOOP_MOUNTPOINT /mnt/obb
export BOOTCLASSPATH /system/framework/core.jar:/system/framework/core-junit.jar:/system/framework/bouncycastle.jar:/system/framework/ext.jar:/system/framework/framework.jar:/system/framework/telephony-common.jar:/system/framework/voip-common.jar:/system/framework/mms-common.jar:/system/framework/android.policy.jar:/system/framework/services.jar:/system/framework/apache-xml.jar
Maybe there is a better way to patch existing ROMs in place.
So, any easyway to deny some apps, to resolve dns?
How apps connect to netd to resolve dns? Unix socket? Or inet socket?
Ok, what I want to do is, some apps connect through tor network and prevent dns leaks.
Thanks.
Sent from my Nexus 4 using xda app-developers app
Ok, I found it in android_open_proxy().
It look like use unix socket "/dev/socket/dnsproxyd".
So I can not use iptables to deny some apps connect to dnsproxy? right?
Any idea to prevent some apps/uid (but not all), connect to dnsproxy?
Thank you.
Sent from my Nexus 4 using xda app-developers app
I tried export ANDROID_DNS_MODE=local
but it make no different on my nexus 4
(my nexus 4 use android stock room 4.3, download from google)
[email protected]:/ $ id
uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats) context=u:r:shell:s0
[email protected]:/ $ telnet google.com
telnet: bad address 'google.com'
1|[email protected]:/ $ set |grep -i dns
1|[email protected]:/ $ export ANDROID_DNS_MODE=local
[email protected]:/ $ set |grep -i dns
ANDROID_DNS_MODE=local
_='ANDROID_DNS_MODE=local'
[email protected]:/ $ telnet google.com
telnet: bad address 'google.com'
any idea why will that?
thank you.
johnw.xda said:
I tried export ANDROID_DNS_MODE=local
but it make no different on my nexus 4
(my nexus 4 use android stock room 4.3, download from google)
[email protected]:/ $ id
uid=2000(shell) gid=2000(shell) groups=1003(graphics),1004(input),1007(log),1009(mount),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats) context=u:r:shell:s0
[email protected]:/ $ telnet google.com
telnet: bad address 'google.com'
1|[email protected]:/ $ set |grep -i dns
1|[email protected]:/ $ export ANDROID_DNS_MODE=local
[email protected]:/ $ set |grep -i dns
ANDROID_DNS_MODE=local
_='ANDROID_DNS_MODE=local'
[email protected]:/ $ telnet google.com
telnet: bad address 'google.com'
any idea why will that?
thank you.
Click to expand...
Click to collapse
Hmm, it looks like this change removed the logic that populates the nameserver list from the system properties. So with ANDROID_DNS_MODE=local, libc will search /system/etc/hosts but it won't actually be able to contact any nameservers:
Code:
[email protected] / $ ANDROID_DNS_MODE=local RES_OPTIONS=debug ping -c1 localhost
;; res_setoptions("debug", "env")..
;; debug
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=1.85 ms
--- localhost ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.852/1.852/1.852/0.000 ms
[email protected] / $ ANDROID_DNS_MODE=local RES_OPTIONS=debug ping -c1 google.com;; res_setoptions("debug", "env")..
;; debug
;; res_nquerydomain(google.com, <Nil>, 1, 1)
;; res_query(google.com, 1, 1)
;; res_nmkquery(QUERY, google.com, IN, A)
;; res_send()
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28372
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; google.com, type = A, class = IN
;; res_query: send error
;; res_nquerydomain(google.com, , 1, 1)
;; res_query(google.com., 1, 1)
;; res_nmkquery(QUERY, google.com., IN, A)
;; res_send()
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41613
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; google.com, type = A, class = IN
;; res_query: send error
ping: unknown host google.com
[email protected] / $
There's some code in _resolv_set_nameservers_for_iface() that might help, but I don't think this gets run from ordinary command-line utilities.
Any idea to prevent some apps/uid (but not all), connect to dnsproxy?
Click to expand...
Click to collapse
You could try applying filesystem ACLs or SELinux rules to /dev/socket/dnsproxyd
Compiling setfacl with Bionic is a hassle, but you could boot e.g. a Debian ARM image in QEMU and build a binary that is statically linked with glibc. You might also need to build a kernel with CONFIG_TMPFS_POSIX_ACL=y; this setting is currently disabled on the CM10.2 grouper builds.
Other possibilities include:
Modify Bionic to reinstate the old nameserver list behavior, and modify /init.rc as above
Modify netd; you could try calling setresuid() to send out each request under the UID of the client instead of UID 0
Write a daemon that intercepts DNS requests intended for netd; this could use a modified version of the netd DnsProxy logic or it could pass the request through to the real netd
Sorry, I forgot to mention before, maybe the reason is, my busybox/telnet is compiled on debian use glibc with -static flags, so telnet/busybox does not use android's libc, and does not use dnsproxy too.
Anyway, is it possible to compile owner libc for android? Where can download android 4.3 libc source code? Do I need to setup ndk to compile it? or can I use gcc to compile it.
Did you do that before?
Thank you again.
Sent from my Nexus 4 using xda app-developers app
I'm using pppwidget to access the network and I think that is affected by this DNS issues. As specific way to get network, is not aware of all this new stuff and thus unable to resolv dns queries.
johnw.xda said:
Sorry, I forgot to mention before, maybe the reason is, my busybox/telnet is compiled on debian use glibc with -static flags, so telnet/busybox does not use android's libc, and does not use dnsproxy too.
Anyway, is it possible to compile owner libc for android? Where can download android 4.3 libc source code? Do I need to setup ndk to compile it? or can I use gcc to compile it.
Did you do that before?
Thank you again.
Sent from my Nexus 4 using xda app-developers app
Click to expand...
Click to collapse
johnw.xda said:
Anyway, is it possible to compile owner libc for android? Where can download android 4.3 libc source code? Do I need to setup ndk to compile it? or can I use gcc to compile it.
Did you do that before?
Click to expand...
Click to collapse
I've been building my Android 4.3 ROMs from the CM10.2 sources.
You can try building from AOSP directly (instructions here). CM builds aren't difficult, but they did require a few extra steps.
I'm not aware of a way to build Bionic standalone. Trying the obvious stuff like running "ndk-build" in that directory, or using crosstool-ng, didn't work for me. Others can jump in if they know...
cernekee said:
Hmm, it looks like this change removed the logic that populates the nameserver list from the system properties. So with ANDROID_DNS_MODE=local, libc will search /system/etc/hosts but it won't actually be able to contact any nameservers:
Code:
[email protected] / $ ANDROID_DNS_MODE=local RES_OPTIONS=debug ping -c1 localhost
;; res_setoptions("debug", "env")..
;; debug
PING localhost (127.0.0.1) 56(84) bytes of data.
64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=1.85 ms
--- localhost ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.852/1.852/1.852/0.000 ms
[email protected] / $ ANDROID_DNS_MODE=local RES_OPTIONS=debug ping -c1 google.com;; res_setoptions("debug", "env")..
;; debug
;; res_nquerydomain(google.com, <Nil>, 1, 1)
;; res_query(google.com, 1, 1)
;; res_nmkquery(QUERY, google.com, IN, A)
;; res_send()
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28372
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; google.com, type = A, class = IN
;; res_query: send error
;; res_nquerydomain(google.com, , 1, 1)
;; res_query(google.com., 1, 1)
;; res_nmkquery(QUERY, google.com., IN, A)
;; res_send()
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41613
;; flags: rd; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 0
;; google.com, type = A, class = IN
;; res_query: send error
ping: unknown host google.com
[email protected] / $
There's some code in _resolv_set_nameservers_for_iface() that might help, but I don't think this gets run from ordinary command-line utilities.
You could try applying filesystem ACLs or SELinux rules to /dev/socket/dnsproxyd
Compiling setfacl with Bionic is a hassle, but you could boot e.g. a Debian ARM image in QEMU and build a binary that is statically linked with glibc. You might also need to build a kernel with CONFIG_TMPFS_POSIX_ACL=y; this setting is currently disabled on the CM10.2 grouper builds.
Other possibilities include:
Modify Bionic to reinstate the old nameserver list behavior, and modify /init.rc as above
Modify netd; you could try calling setresuid() to send out each request under the UID of the client instead of UID 0
Write a daemon that intercepts DNS requests intended for netd; this could use a modified version of the netd DnsProxy logic or it could pass the request through to the real netd
Click to expand...
Click to collapse
Hi,
Thanks for this analysis.
It certainly does look like 4.3 is ignoring net.dns1 value as the nameserver.
I'm running my custom dns server inside Android and now I suddenly find that it's not being queried.
I may have a small step towards solving this problem.
iptables -t nat -I OUTPUT -p udp -d 192.168.1.1 --dport 53 -j DNAT --to-destination 192.168.1.5:53
iptables -t nat -I OUTPUT -p tcp -d 192.168.1.1 --dport 53 -j DNAT --to-destination 192.168.1.5:53
This works by intercepting the DNS requests meant for the remote nameserver and redirecting it to the local DNS server.
Hope this helps someone figure it out.
There may be a way to programmatically change the active interface DNS server?
Or a way to perhaps disable the DNS proxy completely (ANDROID_DNS_MODE=local doesn't work any more as mentioned)?
cernekee said:
Write a daemon that intercepts DNS requests intended for netd; this could use a modified version of the netd DnsProxy logic or it could pass the request through to the real netd
Click to expand...
Click to collapse
This is what I wound up doing: I copied the DnsProxyListener and Bionic resolver code into an experimental new program called "dnsproxy2", and then tweaked the logic a little bit. Sources are posted here and I'm attaching binaries to this message.
Currently it allows you to pass in a single DNS server address which will unconditionally override the OS-provided DNS servers, and when it proxies requests on behalf of an application it will change the thread's UID (Linux fsuid) to match the caller so that the traditional netfilter app/UID restrictions will be honored.
To see it in action, just do:
Code:
adb push libs/armeabi-v7a/dnsproxy2 /data/local/tmp
adb shell "su -c '/data/local/tmp/dnsproxy2 -v 8.8.8.8'"
The "-v" flag will show the DNS requests on the console.
This was tested with CM10.2. Note that Firefox appears to bypass the DNS proxy.
If this proves useful it may be worth writing a GUI installer/settings app. Another possible improvement would be to allow selectively overriding the DNS server based on the active connection.
cernekee said:
This is what I wound up doing: I copied the DnsProxyListener and Bionic resolver code into an experimental new program called "dnsproxy2", and then tweaked the logic a little bit. Sources are posted here and I'm attaching binaries to this message.
Currently it allows you to pass in a single DNS server address which will unconditionally override the OS-provided DNS servers, and when it proxies requests on behalf of an application it will change the thread's UID (Linux fsuid) to match the caller so that the traditional netfilter app/UID restrictions will be honored.
To see it in action, just do:
Code:
adb push libs/armeabi-v7a/dnsproxy2 /data/local/tmp
adb shell "su -c '/data/local/tmp/dnsproxy2 -v 8.8.8.8'"
The "-v" flag will show the DNS requests on the console.
This was tested with CM10.2. Note that Firefox appears to bypass the DNS proxy.
If this proves useful it may be worth writing a GUI installer/settings app. Another possible improvement would be to allow selectively overriding the DNS server based on the active connection.
Click to expand...
Click to collapse
Is this method still going strong? At this moment there is no app on the market that can change DNS (mobile data access).
hardKNOXbz said:
Is this method still going strong? At this moment there is no app on the market that can change DNS (mobile data access).
Click to expand...
Click to collapse
I'd suggest reading the last few pages of the CrossBreeder thread. I don't think dnsproxy2 is in the official release yet but a number of people have been experimenting with it and posting their results.
cernekee said:
I'd suggest reading the last few pages of the CrossBreeder thread. I don't think dnsproxy2 is in the official release yet but a number of people have been experimenting with it and posting their results.
Click to expand...
Click to collapse
Thank you, I'll do that.
I have created a bug for AOSP regarding broken ANDROID_DNS_MODE=local behavior:
https://code.google.com/p/android/issues/detail?id=75232
Plz try this to connect throo vpn.
This is not my work i just take it from cm11 and put it to stock rom and it work.
sshtunnel_support.zip
https://docs.google.com/file/d/0BzL6ekv_OuX2cE9uY3pfYzNmdWs/edit?usp=docslist_api