You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/08 20:52:38 UTC
[GitHub] [incubator-nuttx] anchao opened a new pull request, #6590: net/poll: fix race condition if connect free before poll teardown
anchao opened a new pull request, #6590:
URL: https://github.com/apache/incubator-nuttx/pull/6590
## Summary
net/poll: fix race condition if connect free before poll teardown
Net poll teardown is not protected by net lock, if the conn is released
before teardown, the assertion failure will be triggered during free dev
callback, this patch will add the net lock around net poll teardown to
fix race condition
nuttx/libs/libc/assert/lib_assert.c:36
nuttx/net/devif/devif_callback.c:85
nuttx/net/tcp/tcp_netpoll.c:405
nuttx/fs/vfs/fs_poll.c:244
nuttx/fs/vfs/fs_poll.c:500
Signed-off-by: chao.an <an...@xiaomi.com>
## Impact
socket in multi-thread
## Testing
close socket fd during poll
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on a diff in pull request #6590: net/poll: fix race condition if connect free before poll teardown
Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #6590:
URL: https://github.com/apache/incubator-nuttx/pull/6590#discussion_r917246387
##########
net/icmpv6/icmpv6_netpoll.c:
##########
@@ -142,17 +142,25 @@ static uint16_t icmpv6_poll_eventhandler(FAR struct net_driver_s *dev,
int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
{
- FAR struct icmpv6_conn_s *conn = psock->s_conn;
+ FAR struct icmpv6_conn_s *conn;
FAR struct icmpv6_poll_s *info;
FAR struct devif_callback_s *cb;
int ret = OK;
- DEBUGASSERT(conn != NULL && fds != NULL);
-
- /* Some of the following must be atomic */
+ /* Some of the following must be atomic */
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #6590: net/poll: fix race condition if connect free before poll teardown
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged PR #6590:
URL: https://github.com/apache/incubator-nuttx/pull/6590
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] anchao commented on a diff in pull request #6590: net/poll: fix race condition if connect free before poll teardown
Posted by GitBox <gi...@apache.org>.
anchao commented on code in PR #6590:
URL: https://github.com/apache/incubator-nuttx/pull/6590#discussion_r917239342
##########
net/icmp/icmp_netpoll.c:
##########
@@ -142,17 +142,27 @@ static uint16_t icmp_poll_eventhandler(FAR struct net_driver_s *dev,
int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
{
- FAR struct icmp_conn_s *conn = psock->s_conn;
+ FAR struct icmp_conn_s *conn;
FAR struct icmp_poll_s *info;
FAR struct devif_callback_s *cb;
int ret = OK;
- DEBUGASSERT(conn != NULL && fds != NULL);
-
/* Some of the following must be atomic */
net_lock();
+ conn = psock->s_conn;
+
+ /* Sanity check */
+
+#ifdef CONFIG_DEBUG_FEATURES
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6590: net/poll: fix race condition if connect free before poll teardown
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6590:
URL: https://github.com/apache/incubator-nuttx/pull/6590#discussion_r917222088
##########
net/icmp/icmp_netpoll.c:
##########
@@ -142,17 +142,27 @@ static uint16_t icmp_poll_eventhandler(FAR struct net_driver_s *dev,
int icmp_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
{
- FAR struct icmp_conn_s *conn = psock->s_conn;
+ FAR struct icmp_conn_s *conn;
FAR struct icmp_poll_s *info;
FAR struct devif_callback_s *cb;
int ret = OK;
- DEBUGASSERT(conn != NULL && fds != NULL);
-
/* Some of the following must be atomic */
net_lock();
+ conn = psock->s_conn;
+
+ /* Sanity check */
+
+#ifdef CONFIG_DEBUG_FEATURES
Review Comment:
should we remove #ifdef/#endif?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a diff in pull request #6590: net/poll: fix race condition if connect free before poll teardown
Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 commented on code in PR #6590:
URL: https://github.com/apache/incubator-nuttx/pull/6590#discussion_r917244786
##########
net/icmpv6/icmpv6_netpoll.c:
##########
@@ -142,17 +142,25 @@ static uint16_t icmpv6_poll_eventhandler(FAR struct net_driver_s *dev,
int icmpv6_pollsetup(FAR struct socket *psock, FAR struct pollfd *fds)
{
- FAR struct icmpv6_conn_s *conn = psock->s_conn;
+ FAR struct icmpv6_conn_s *conn;
FAR struct icmpv6_poll_s *info;
FAR struct devif_callback_s *cb;
int ret = OK;
- DEBUGASSERT(conn != NULL && fds != NULL);
-
- /* Some of the following must be atomic */
+ /* Some of the following must be atomic */
Review Comment:
remove the extra space
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org