Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Host scans break when targeting Android 12/13 (SDK versions 32/33 respectively) due to SELinux blocking nlmsg_getneigh #151

Open
aaronjwood opened this issue Sep 11, 2022 · 3 comments

Comments

@aaronjwood
Copy link
Owner

aaronjwood commented Sep 11, 2022

When targeting SDK version 32 or 33 we run into this:

type=1400 audit(0.0:21): avc: denied { nlmsg_getneigh } for scontext=u:r:untrusted_app:s0:c157,c256,c512,c768 tcontext=u:r:untrusted_app:s0:c157,c256,c512,c768 tclass=netlink_route_socket permissive=0 bug=b/155595000 app=com.aaronjwood.portauthority.donate

The offender originates here:

	if (rtnl_dump_request_n(&rth, &req.n) < 0) {
		perror("Cannot send dump request");
		exit(1);
	}

sendmsg is our problem:

int rtnl_dump_request_n(struct rtnl_handle *rth, struct nlmsghdr *n)
{
	struct sockaddr_nl nladdr = { .nl_family = AF_NETLINK };
	struct iovec iov = {
		.iov_base = n,
		.iov_len = n->nlmsg_len
	};
	struct msghdr msg = {
		.msg_name = &nladdr,
		.msg_namelen = sizeof(nladdr),
		.msg_iov = &iov,
		.msg_iovlen = 1,
	};

	n->nlmsg_flags = NLM_F_DUMP|NLM_F_REQUEST;
	n->nlmsg_pid = 0;
	n->nlmsg_seq = rth->dump = ++rth->seq;

	return sendmsg(rth->fd, &msg, 0);
}
@aaronjwood aaronjwood changed the title Host scans don't work on Android 13 due to SELinux blocking nlmsg_getneigh Host scans don't work on Android 12 or 13 due to SELinux blocking nlmsg_getneigh Sep 11, 2022
@aaronjwood aaronjwood changed the title Host scans don't work on Android 12 or 13 due to SELinux blocking nlmsg_getneigh Host scans break when targeting Android 12/13 (SDK versions 32/33 respectively) due to SELinux blocking nlmsg_getneigh Sep 11, 2022
@Silent-Hunter
Copy link

I assume this is why the app crashes when I do Discover Hosts? Is there any way to fix this problem?

@aaronjwood
Copy link
Owner Author

Yeah, that's probably what you're hitting. The latest version I've rolled out (v2.4.5) works around this for now. It's not a long term solution as I am just targeting an older API version rather than the very latest.

@chimpzilla
Copy link

Has anyone found a workaround for gathering mac addresses? Google Play won't let you publish now unless you target API33. It's so daft, because it means you can't know which device is which on a local network. I think Apple maybe has a similar policy and that Google have simply copied it, without properly thinking through the consequences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants