[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lwip-devel] possible issue in sockets.c
From: |
Albert Huitsing |
Subject: |
[lwip-devel] possible issue in sockets.c |
Date: |
Tue, 24 Dec 2013 12:35:03 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.1 |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello members of this list,
Sorry to cut straight to the point, but I think I maybe have a usefull
contribution to the project.
I've encountered a possible issue in src/api/sockets.c
in the function event_callback() there seems to be a potential problem with
detecting possible
modification of the list while looping:
}
if (do_signal) {
scb->sem_signalled = 1;
/* Don't call SYS_ARCH_UNPROTECT() before signaling the semaphore, as
this might
lead to the select thread taking itself off the list, invalidagin
the semaphore. */
sys_sem_signal(&scb->sem);
}
}
/* unlock interrupts with each step */
last_select_cb_ctr = select_cb_ctr;
the call to sys_sem_signal() could cause a modification of the list.
so I think the 'select_cb_ctr' has to be stored *before* the call to
sys_sem_signal()
what do you think?
kindest regards,
Albert Huitsing
for (scb = select_cb_list; scb != NULL; scb = scb->next) {
// remember the cb_ctr before anyone can change
// select_cb_list (note: 'sys_sem_signal()' can cause a context switch!)
last_select_cb_ctr = select_cb_ctr;
if (scb->sem_signalled == 0) {
/* semaphore not signalled yet */
int do_signal = 0;
/* Test this select call for our socket */
if (sock->rcvevent > 0) {
if (scb->readset && FD_ISSET(s, scb->readset)) {
do_signal = 1;
}
}
if (sock->sendevent != 0) {
if (!do_signal && scb->writeset && FD_ISSET(s, scb->writeset)) {
do_signal = 1;
}
}
if (sock->errevent != 0) {
if (!do_signal && scb->exceptset && FD_ISSET(s, scb->exceptset)) {
do_signal = 1;
}
}
if (do_signal) {
scb->sem_signalled = 1;
/* Don't call SYS_ARCH_UNPROTECT() before signaling the semaphore, as
this might
lead to the select thread taking itself off the list, invalidagin
the semaphore. */
sys_sem_signal(&scb->sem);
}
}
/* unlock interrupts with each step */
SYS_ARCH_UNPROTECT(lev);
/* this makes sure interrupt protection time is short */
SYS_ARCH_PROTECT(lev);
if (last_select_cb_ctr != select_cb_ctr) {
/* someone has changed select_cb_list, restart at the beginning */
goto again;
}
}
- --
Albert Huitsing (address@hidden)
Huitsing Embedded Systems
Dr. Mondenweg 5
7831 JA Nw. Weerdinge
+31-(0)591-521222
http://www.huitsing.nl
"conformity is the uncomfortable feeling of wearing
somebody else's clothes; even when they don't fit"
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iQEcBAEBAgAGBQJSuXFnAAoJEIhVw35ZSGXEsmMIAJ3yZMTjfc+P1Q1mcN8sLnPF
JLc9DhY6ReSyjuwi0XYkaxFkYV40F2FKD88HneXdD4v8PPcH+jPC3LxUEB/r17jk
QK+MIM9ziySG+L2OCln2+XsFYmW0xdYCp99ARKkvNpEdj4WhS2i1Jkm6yXGza4+D
e4djMPybnrArn7TDycB6E8af5EUFkTwZBCTsgFeBk1q/KdhlWmDWrHBslT/8FuIO
LcQFval9Z3lKcecTUYUkDeF9A0gty5oDtK6W6ifoEegyGQYcoZ1gEhn9B7tzNTFd
11NcaClYo1RLaAMxbv+ILUBPnaz9dieNP8k/FYEXyLJxATJ30GmMvXpBSyOng1w=
=yiHo
-----END PGP SIGNATURE-----
- [lwip-devel] possible issue in sockets.c,
Albert Huitsing <=