Fix denial of service - memory corruption.
authorJeremy Allison <jra@samba.org>
Sun, 27 Feb 2011 16:58:06 +0000 (17:58 +0100)
committerKarolin Seeger <kseeger@samba.org>
Sun, 27 Feb 2011 17:00:09 +0000 (18:00 +0100)
CVE-2011-0719

Fix bug #7949 (DoS in Winbind and smbd with many file descriptors open).

All current released versions of Samba are vulnerable to
a denial of service caused by memory corruption. Range
checks on file descriptors being used in the FD_SET macro
were not present allowing stack corruption. This can cause
the Samba code to crash or to loop attempting to select
on a bad file descriptor set.

A connection to a file share, or a local account is needed
to exploit this problem, either authenticated or unauthenticated
(guest connection).

Currently we do not believe this flaw is exploitable
beyond a crash or causing the code to loop, but on the
advice of our security reviewers we are releasing fixes
in case an exploit is discovered at a later date.

tevent/tevent_select.c
tevent/tevent_standard.c

index d97418991ae3e3dd8bec6edd13d7fb5a0144b0ff..890e0311c6033be92cb8b36ba573587965b3901e 100644 (file)
@@ -111,6 +111,11 @@ static struct tevent_fd *select_event_add_fd(struct tevent_context *ev, TALLOC_C
                                                           struct select_event_context);
        struct tevent_fd *fde;
 
+       if (fd < 0 || fd >= FD_SETSIZE) {
+               errno = EBADF;
+               return NULL;
+       }
+
        fde = tevent_common_add_fd(ev, mem_ctx, fd, flags,
                                   handler, private_data,
                                   handler_name, location);
@@ -143,6 +148,11 @@ static int select_event_loop_select(struct select_event_context *select_ev, stru
 
        /* setup any fd events */
        for (fde = select_ev->ev->fd_events; fde; fde = fde->next) {
+               if (fde->fd < 0 || fde->fd >= FD_SETSIZE) {
+                       errno = EBADF;
+                       return -1;
+               }
+
                if (fde->flags & TEVENT_FD_READ) {
                        FD_SET(fde->fd, &r_fds);
                }
index c3f8b36e840faf52773d1e7c6327a23cf909c7c4..d4a00cc062a4e472a309d211f490e979cc36c134 100644 (file)
@@ -457,6 +457,11 @@ static int std_event_loop_select(struct std_event_context *std_ev, struct timeva
 
        /* setup any fd events */
        for (fde = std_ev->ev->fd_events; fde; fde = fde->next) {
+               if (fde->fd < 0 || fde->fd >= FD_SETSIZE) {
+                       std_ev->exit_code = EBADF;
+                       return -1;
+               }
+
                if (fde->flags & TEVENT_FD_READ) {
                        FD_SET(fde->fd, &r_fds);
                }