Skip to content

Native transports: Fix possible fd leak when fcntl fails.#16442

Merged
chrisvest merged 1 commit into
4.2from
fd_leak
Mar 12, 2026
Merged

Native transports: Fix possible fd leak when fcntl fails.#16442
chrisvest merged 1 commit into
4.2from
fd_leak

Conversation

@normanmaurer

Copy link
Copy Markdown
Member

Motivation:

When accept4(...) is not present on the platform we fallback to using normal accept(...) syscall. In this case we also need two extra syscalls (fcntl). If one of the fcntl calls failed we did not close the previous accepted fd and so leaked it.

Modifications:

Call close(...) before returning early

Result:

No more fd leak in case of fcntl failure

Motivation:

When accept4(...) is not present on the platform we fallback to using normal accept(...) syscall. In this case we also need two extra syscalls (fcntl). If one of the fcntl calls failed we did not close the previous accepted fd and so leaked it.

Modifications:

Call close(...) before returning early

Result:

No more fd leak in case of fcntl failure
@normanmaurer normanmaurer added this to the 4.2.11.Final milestone Mar 12, 2026
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Mar 12, 2026
@normanmaurer normanmaurer requested a review from chrisvest March 12, 2026 19:09
@chrisvest chrisvest merged commit 9f2900f into 4.2 Mar 12, 2026
24 checks passed
@chrisvest chrisvest deleted the fd_leak branch March 12, 2026 19:43
netty-project-bot pushed a commit that referenced this pull request Mar 12, 2026
Motivation:

When accept4(...) is not present on the platform we fallback to using
normal accept(...) syscall. In this case we also need two extra syscalls
(fcntl). If one of the fcntl calls failed we did not close the previous
accepted fd and so leaked it.

Modifications:

Call close(...) before returning early

Result:

No more fd leak in case of fcntl failure

(cherry picked from commit 9f2900f)
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #16446

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Mar 12, 2026
netty-project-bot pushed a commit that referenced this pull request Mar 12, 2026
Motivation:

When accept4(...) is not present on the platform we fallback to using
normal accept(...) syscall. In this case we also need two extra syscalls
(fcntl). If one of the fcntl calls failed we did not close the previous
accepted fd and so leaked it.

Modifications:

Call close(...) before returning early

Result:

No more fd leak in case of fcntl failure

(cherry picked from commit 9f2900f)
@netty-project-bot

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #16447

@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Mar 12, 2026
normanmaurer added a commit that referenced this pull request Mar 13, 2026
…ls. (#16446)

Auto-port of #16442 to 4.1
Cherry-picked commit: 9f2900f

---
Motivation:

When accept4(...) is not present on the platform we fallback to using
normal accept(...) syscall. In this case we also need two extra syscalls
(fcntl). If one of the fcntl calls failed we did not close the previous
accepted fd and so leaked it.

Modifications:

Call close(...) before returning early

Result:

No more fd leak in case of fcntl failure

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
normanmaurer added a commit that referenced this pull request Mar 13, 2026
…ls. (#16447)

Auto-port of #16442 to 5.0
Cherry-picked commit: 9f2900f

---
Motivation:

When accept4(...) is not present on the platform we fallback to using
normal accept(...) syscall. In this case we also need two extra syscalls
(fcntl). If one of the fcntl calls failed we did not close the previous
accepted fd and so leaked it.

Modifications:

Call close(...) before returning early

Result:

No more fd leak in case of fcntl failure

Co-authored-by: Norman Maurer <norman_maurer@apple.com>
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.

3 participants