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

Avoid infinite-loop in avahi-daemon by handling HUP event in client_work #330

Merged
merged 1 commit into from
Jan 2, 2023

Conversation

ret2libc
Copy link
Contributor

If a client fills the input buffer, client_work() disables the
AVAHI_WATCH_IN event, thus preventing the function from executing the
read syscall the next times it is called. However, if the client then
terminates the connection, the socket file descriptor receives a HUP
event, which is not handled, thus the kernel keeps marking the HUP event
as occurring. While iterating over the file descriptors that triggered
an event, the client file descriptor will keep having the HUP event and
the client_work() function is always called with AVAHI_WATCH_HUP but
without nothing being done, thus entering an infinite loop.

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=984938

If a client fills the input buffer, client_work() disables the
AVAHI_WATCH_IN event, thus preventing the function from executing the
`read` syscall the next times it is called. However, if the client then
terminates the connection, the socket file descriptor receives a HUP
event, which is not handled, thus the kernel keeps marking the HUP event
as occurring. While iterating over the file descriptors that triggered
an event, the client file descriptor will keep having the HUP event and
the client_work() function is always called with AVAHI_WATCH_HUP but
without nothing being done, thus entering an infinite loop.

See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=984938
@ret2libc
Copy link
Contributor Author

By the way, I've requested a CVE through Red Hat for this issue.

@carnil
Copy link

carnil commented Mar 27, 2021

CVE-2021-3468 has been assigned for this issue according to https://bugzilla.redhat.com/show_bug.cgi?id=1939614

@utkarsh2102
Copy link

@lathiat, could you take a look at this whenever free, please? 😅

bmwiedemann pushed a commit to bmwiedemann/openSUSE that referenced this pull request Apr 24, 2021
https://build.opensuse.org/request/show/887505
by user dimstar + dimstar_suse
- Add avahi-CVE-2021-3468.patch: avoid infinite loop by handling
  HUP event in client_work (boo#1184521 CVE-2021-3468).
  avahi/avahi#330 (forwarded request 887071 from mgorse)
@ret2libc
Copy link
Contributor Author

Ping on this.

jpuhlman pushed a commit to MontaVista-OpenSourceTechnology/poky that referenced this pull request Nov 19, 2021
Source: https://github.com/lathiat/avahi
MR: 111703
Type: Security Fix
Disposition: Backport from avahi/avahi#330
ChangeID: 6236249cc3c0e170f1ba87d47b0fa7720317f2cc
Description:

CVE-2021-3468 : Avoid infinite-loop in avahi-daemon by handling HUP event in client_work

Signed-off-by: Milan Shah <mshah@mvista.com>
Reviewed-by: Armin Kuster <akuster@mvista.com>
Signed-off-by: Jeremy Puhlman <jpuhlman@mvista.com>
@mbiebl
Copy link
Contributor

mbiebl commented Jul 29, 2022

@lathiat could you have a look at this PR?
This was raised downstream at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=984938 but before applying this PR into the Debian package, I'd appreciate if you could review the changes.

Copy link
Member

@pemensik pemensik left a comment

Choose a reason for hiding this comment

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

It seems an important, yet simple fix.

@pemensik pemensik added bug important High priority labels Nov 24, 2022
evverx added a commit to evverx/avahi that referenced this pull request Dec 2, 2022
to catch issues like avahi#330
and avahi#338
evverx added a commit to evverx/avahi that referenced this pull request Dec 2, 2022
to catch issues like avahi#330
and avahi#338
evverx added a commit to evverx/avahi that referenced this pull request Dec 2, 2022
to catch issues like avahi#330
and avahi#338
evverx added a commit to evverx/avahi that referenced this pull request Dec 2, 2022
to catch issues like avahi#330
and avahi#338
evverx added a commit to evverx/avahi that referenced this pull request Dec 2, 2022
to catch issues like avahi#330
and avahi#338
evverx added a commit to evverx/avahi that referenced this pull request Dec 2, 2022
to catch issues like avahi#330
and avahi#338
@carnil
Copy link

carnil commented Dec 29, 2022

@lathiat could you have a look at this PR? This was raised downstream at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=984938 but before applying this PR into the Debian package, I'd appreciate if you could review the changes.

@lathiat any chance you could review the pull request so we can have the fixes applied in time for the next Debian release 'bookworm'?

@pemensik pemensik merged commit 6e72b84 into avahi:master Jan 2, 2023
@pemensik
Copy link
Member

pemensik commented Jan 2, 2023

Merged, haven't found anything this might break. Has this change been tested on any distribution already, at least rolling one? It was not tested in Fedora.

@pemensik pemensik added this to the v0.9 milestone Jan 2, 2023
@pemensik pemensik self-assigned this Jan 2, 2023
@mbiebl
Copy link
Contributor

mbiebl commented Jan 6, 2023

It wasn't tested in Debian either, as I wanted to have an ack from upstream first.

f-denkena added a commit to f-denkena/gentoo that referenced this pull request Feb 21, 2023
This fixes the infinite loop bug of net-dns/avahi as described here:
avahi/avahi#330

Bug: https://bugs.gentoo.org/793953
Signed-off-by: Federico Denkena <federico.denkena@posteo.de>
f-denkena added a commit to f-denkena/gentoo that referenced this pull request Feb 21, 2023
This fixes the infinite loop bug of net-dns/avahi as described here:
avahi/avahi#330

Bug: https://bugs.gentoo.org/793953
Signed-off-by: Federico Denkena <federico.denkena@posteo.de>
evverx added a commit to evverx/avahi that referenced this pull request Oct 31, 2023
evverx added a commit to evverx/avahi that referenced this pull request Oct 31, 2023
evverx added a commit to evverx/avahi that referenced this pull request Oct 31, 2023
evverx added a commit that referenced this pull request Oct 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug important High priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants