lighttpd是德国软件开发者Jan Kneschke所研发的一款开源的Web服务器,它的主要特点是仅需少量的内存及CPU资源即可达到同类网页服务器的性能。 Lighttpd在分配全局文件描述符数组时存在计算错误,远程攻击者可能利用此漏洞导致服务不可用。 创建文件描述符数组的方式如下: fdevent.c: 15 fdevents *fdevent_init(size_t maxfds, fdevent_handler_t type) { 19 ev->fdarray = calloc(maxfds, sizeof(*ev->fdarray)); server.c: 1076 if (NULL == (srv->ev = fdevent_init(srv->max_fds + 1, srv->event_handler))) { 在同一文件中的之前部分: 679 if (0 != getrlimit(RLIMIT_NOFILE, &rlim)) { 680 log_error_write(srv, __FILE__, __LINE__, 681 \"ss\", \"couldn\'\'t get \'\'max filedescriptors\'\'\", 682 strerror(errno)); 683 return -1; 684 } 685 686 if (use_rlimit && srv->srvconf.max_fds) { 687 /* set rlimits */ 688 689 rlim.rlim_cur = srv->srvconf.max_fds; 690 rlim.rlim_max = srv->srvconf.max_fds; 691 692 if (0 != setrlimit(RLIMIT_NOFILE, &rlim)) { 693 log_error_write(srv, __FILE__, __LINE__, 694 \"ss\", \"couldn\'\'t set \'\'max filedescriptors\'\'\", 695 strerror(errno)); 696 return -1; 697 } 698 } 700 /* #372: solaris need some fds extra for...
lighttpd是德国软件开发者Jan Kneschke所研发的一款开源的Web服务器,它的主要特点是仅需少量的内存及CPU资源即可达到同类网页服务器的性能。 Lighttpd在分配全局文件描述符数组时存在计算错误,远程攻击者可能利用此漏洞导致服务不可用。 创建文件描述符数组的方式如下: fdevent.c: 15 fdevents *fdevent_init(size_t maxfds, fdevent_handler_t type) { 19 ev->fdarray = calloc(maxfds, sizeof(*ev->fdarray)); server.c: 1076 if (NULL == (srv->ev = fdevent_init(srv->max_fds + 1, srv->event_handler))) { 在同一文件中的之前部分: 679 if (0 != getrlimit(RLIMIT_NOFILE, &rlim)) { 680 log_error_write(srv, __FILE__, __LINE__, 681 \"ss\", \"couldn\'\'t get \'\'max filedescriptors\'\'\", 682 strerror(errno)); 683 return -1; 684 } 685 686 if (use_rlimit && srv->srvconf.max_fds) { 687 /* set rlimits */ 688 689 rlim.rlim_cur = srv->srvconf.max_fds; 690 rlim.rlim_max = srv->srvconf.max_fds; 691 692 if (0 != setrlimit(RLIMIT_NOFILE, &rlim)) { 693 log_error_write(srv, __FILE__, __LINE__, 694 \"ss\", \"couldn\'\'t set \'\'max filedescriptors\'\'\", 695 strerror(errno)); 696 return -1; 697 } 698 } 700 /* #372: solaris need some fds extra for devpoll * 701 if (rlim.rlim_cur > 10) rlim.rlim_cur -= 10; 827 srv->max_fds = rlim.rlim_cur; 进程获取当前所配置的rlimit并保存到rlim中。如果配置设置了max_fds,就会覆盖当前任务所配置的。然后,max_fds以10递减,使用max_fds大小分配文件描述符数组。最终,系统可能给出多于max_fds个文件描述符,出现分段错误,导致崩溃。