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

added mutex to protect self->table #22987

Merged
merged 3 commits into from Apr 24, 2024
Merged

Conversation

thejbte
Copy link
Member

@thejbte thejbte commented Apr 18, 2024

Related issue
#21562

Description

This PR fixes the race condition in remoted bug, the solution was add mutex to self->table.

Tests

  1. delete Privsep_Chroot() and nowChroot() from remoted/main.c
  2. delete fork from ῢremoted/main.c`
       i = 0;
    //while (logr.conn[i] != 0) {
    //    /* Fork for each connection handler */
    //    if (fork() == 0) {
    //        /* On the child */
    //        mdebug1("Forking remoted: '%d'.", i);
            logr.position = i;
            HandleRemote(uid);
    //    } else {
    //        i++;
    //        continue;
    //    }
    //}
  3. add flags to compile with thread-sanitizer CFLAGS="-g -fsanitize=thread -fno-omit-frame-pointer" LDFLAGS="-g -fsanitize=thread -fno-omit-frame-pointer"
  4. build wazuh like this sudo make clean && make clean-deps && rm -rf external/* && make -j12 deps && make -j12 TARGET=server DEBUG=1 CFLAGS="-g -fsanitize=thread -fno-omit-frame-pointer" LDFLAGS="-g -fsanitize=thread -fno-omit-frame-pointer"
  5. copy the binary file sudo cp wazuh-remoted /var/ossec/bin/
  6. kill wazuh-remoted process sudo kill -9 $(pidof /var/ossec/bin/wazuh-remoted)
  7. run wazuh-remoted sudo /var/ossec/bin/wazuh-remoted -f -u root or /var/ossec/bin/wazuh-remoted -f -u root &> threadsanitizer.log in order to save the console output.
  • Compilation without warnings in every supported platform
    • Linux
    • Windows
    • MAC OS X
  • Source installation

@thejbte
Copy link
Member Author

thejbte commented Apr 18, 2024

@thejbte thejbte self-assigned this Apr 24, 2024
@TomasTurina TomasTurina merged commit 8861902 into 4.9.0 Apr 24, 2024
60 of 63 checks passed
@TomasTurina TomasTurina deleted the bug/21562-race-condition-remoted branch April 24, 2024 21:22
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

Successfully merging this pull request may close these issues.

None yet

2 participants