lib/stream/packet.c bugs?

Stefan (metze) Metzmacher metze at samba.org
Fri Dec 9 08:16:39 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi tridge,

I read through packet.c and I think in packet_recv()
are still some bugs.

void packet_recv(struct packet_context *pc)
{
	size_t npending;
	NTSTATUS status;
	size_t nread = 0;
	DATA_BLOB blob;

	if (pc->processing) {
		EVENT_FD_NOT_READABLE(pc->fde);
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
here I think we should add something like this:
if (pc->processing > 2) {
	status = socket_pending(pc->sock, &npending);
	if (!NT_STATUS_IS_OK(status)) {
		packet_error(pc, status);
		return;
	}
	if (npending == 0) {
		packet_eof(pc);
		return;
	}
}
as if we have set EVENT_FD_NOT_NOT_READABLE() twice and still
got EVENT_FD_READ notifications, there must be something wrong,
and note we map (EPOLLIN|EPOLLHUP|EPOLLERR) to EVENT_FD_READ;
and if we don't lookup the error via socket_recv(with wantlen=0),
or maybe socket_pending(), we'll get the EVENT_FD_READ on each event_loop_once()
till we remove the fd_event, and this will cause a 100% CPU endless loop.
I'm currently working on a patch to convert the winsrepl stuff to packet_context.
and I'll maybe able to give you some instructions to trigger this bug.
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
		pc->processing++;
		return;
	}

	if (pc->recv_disable) {
		EVENT_FD_NOT_READABLE(pc->fde);
>>>>>
here we have the same problem
>>>>>
		return;
	}
...

Comments please:-)

- - --
metze


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3-nr1 (Windows XP)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDmT1km70gjA5TCD8RAhseAJ4iCReydHvQP2uMSVPazYFU5bAhkgCeNbgu
GDDg5m8b/cpw775KsjWZg5I=
=EtVw
-----END PGP SIGNATURE-----


More information about the samba-technical mailing list