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

Fix possible crash with high client activity #1777

Merged
merged 1 commit into from Dec 10, 2023
Merged

Conversation

DL6ER
Copy link
Member

@DL6ER DL6ER commented Nov 22, 2023

What does this implement/fix?

Fix possible race-collision leading to a theoretical out-of-bounds read

Related issue or feature (if applicable): N/A

Pull request in docs with documentation (if applicable): N/A


By submitting this pull request, I confirm the following:

  1. I have read and understood the contributors guide, as well as this entire template. I understand which branch to base my commits and Pull Requests against.
  2. I have commented my proposed changes within the code.
  3. I am willing to help maintain this change if there are issues with it later.
  4. It is compatible with the EUPL 1.2 license
  5. I have squashed any insignificant commits. (git rebase)

Checklist:

  • The code change is tested and works locally.
  • I based my code and PRs against the repositories developmental branch.
  • I signed off all commits. Pi-hole enforces the DCO for all contributions
  • I signed all my commits. Pi-hole requires signatures to verify authorship
  • I have read the above and my PR is ready for review.

@DL6ER DL6ER added the Bugfix label Nov 22, 2023
Copy link
Member

@yubiuser yubiuser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The race would be that counters->clients could be increased while the counter for clientID is still running?

@DL6ER
Copy link
Member Author

DL6ER commented Nov 22, 2023

We declare an object of size counters->clients here:

lock_shm();
const int clients = counters->clients;
unlock_shm();
enum arp_status client_status[clients];

and later on use it in a loop that is running from 0 to counters->clients. The race is that counters->clients may have increased meanwhile. This is prevented by passing the counters->clients we have used before and use this as upper limit for the loop. It may mean we are missing a few clients, but we will pick them up shortly after when the code is run again.

@DL6ER DL6ER marked this pull request as ready for review December 3, 2023 08:07
@DL6ER
Copy link
Member Author

DL6ER commented Dec 3, 2023

Unfortunately, we never got feedback from the affected users. As they were target active before we suggested this bugfix, I can only assume it fixed the issue for them. Anyway, it's a meaningful change and we can use it to push a v5.x FTL patch release.

@DL6ER DL6ER requested a review from a team December 3, 2023 08:11
@yubiuser
Copy link
Member

yubiuser commented Dec 3, 2023

Mhh...

nanopi@nanopi:~$ pihole checkout ftl fix/many_clients
  Please note that changing branches severely alters your Pi-hole subsystems
  Features that work on the master branch, may not on a development branch
  This feature is NOT supported unless a Pi-hole developer explicitly asks!
  Have you read and understood this? [y/N] y

  [✗] Requested branch "fix/many_clients" is not available
  [i] Available branches for FTL are:
      - development
      - development-v6
      - fix/delete_dhcp_lease
      - fix/many_clients
      - group_dependabot

@DL6ER DL6ER merged commit fd114e0 into development Dec 10, 2023
20 checks passed
@DL6ER DL6ER deleted the fix/many_clients branch December 10, 2023 17:06
@DL6ER DL6ER mentioned this pull request Dec 10, 2023
@pralor-bot
Copy link

This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there:

https://discourse.pi-hole.net/t/pi-hole-ftl-v5-24-and-core-v5-17-3-released/67486/1

Ornias1993 added a commit to truecharts/charts that referenced this pull request Jan 9, 2024
…c4 by renovate (#17027)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [pihole/pihole](https://togithub.com/pi-hole/docker-pi-hole) | major |
`2023.11.0` -> `2024.01.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>pi-hole/docker-pi-hole (pihole/pihole)</summary>

###
[`v2024.01.0`](https://togithub.com/pi-hole/docker-pi-hole/releases/tag/2024.01.0)

[Compare
Source](https://togithub.com/pi-hole/docker-pi-hole/compare/2023.11.0...2024.01.0)

Nothing docker specific this time around.

<!-- Release notes generated using configuration in .github/release.yml
at development -->

#### What's Changed (FTL v5.24)

- Update dependabot.yml by
[@&#8203;PromoFaux](https://togithub.com/PromoFaux) in
[pi-hole/FTL#1587
- Add pihole-FTL sqlite3 -ni by
[@&#8203;DL6ER](https://togithub.com/DL6ER) in
[pi-hole/FTL#1820
- Fix possible crash with high client activity by
[@&#8203;DL6ER](https://togithub.com/DL6ER) in
[pi-hole/FTL#1777
- Implement special domains whitelisting by
[@&#8203;DL6ER](https://togithub.com/DL6ER) in
[pi-hole/FTL#1808

**Full Changelog**: pi-hole/FTL@v5.23...v5.24

<!-- Release notes generated using configuration in .github/release.yml
at development -->

#### What's Changed (Core v5.17.3)

- Add "-ni" to all sqlite3 invocations (v5) by
[@&#8203;DL6ER](https://togithub.com/DL6ER) in
[pi-hole/pi-hole#5519

**Full Changelog**:
pi-hole/pi-hole@v5.17.2...v5.17.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10pm on monday" in timezone
Europe/Amsterdam, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjYuMiIsInVwZGF0ZWRJblZlciI6IjM3LjEyNi4yIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->

Signed-off-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Co-authored-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
GabrielBarzen pushed a commit to GabrielBarzen/charts that referenced this pull request Feb 2, 2024
…c4 by renovate (truecharts#17027)

This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [pihole/pihole](https://togithub.com/pi-hole/docker-pi-hole) | major |
`2023.11.0` -> `2024.01.0` |

---

> [!WARNING]
> Some dependencies could not be looked up. Check the Dependency
Dashboard for more information.

---

### Release Notes

<details>
<summary>pi-hole/docker-pi-hole (pihole/pihole)</summary>

###
[`v2024.01.0`](https://togithub.com/pi-hole/docker-pi-hole/releases/tag/2024.01.0)

[Compare
Source](https://togithub.com/pi-hole/docker-pi-hole/compare/2023.11.0...2024.01.0)

Nothing docker specific this time around.

<!-- Release notes generated using configuration in .github/release.yml
at development -->

#### What's Changed (FTL v5.24)

- Update dependabot.yml by
[@&truecharts#8203;PromoFaux](https://togithub.com/PromoFaux) in
[pi-hole/FTL#1587
- Add pihole-FTL sqlite3 -ni by
[@&truecharts#8203;DL6ER](https://togithub.com/DL6ER) in
[pi-hole/FTL#1820
- Fix possible crash with high client activity by
[@&truecharts#8203;DL6ER](https://togithub.com/DL6ER) in
[pi-hole/FTL#1777
- Implement special domains whitelisting by
[@&truecharts#8203;DL6ER](https://togithub.com/DL6ER) in
[pi-hole/FTL#1808

**Full Changelog**: pi-hole/FTL@v5.23...v5.24

<!-- Release notes generated using configuration in .github/release.yml
at development -->

#### What's Changed (Core v5.17.3)

- Add "-ni" to all sqlite3 invocations (v5) by
[@&truecharts#8203;DL6ER](https://togithub.com/DL6ER) in
[pi-hole/pi-hole#5519

**Full Changelog**:
pi-hole/pi-hole@v5.17.2...v5.17.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - "before 10pm on monday" in timezone
Europe/Amsterdam, Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR has been generated by [Renovate
Bot](https://togithub.com/renovatebot/renovate).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4xMjYuMiIsInVwZGF0ZWRJblZlciI6IjM3LjEyNi4yIiwidGFyZ2V0QnJhbmNoIjoibWFzdGVyIn0=-->

Signed-off-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Co-authored-by: Kjeld Schouten <kjeld@schouten-lebbing.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants