LinuxÄÚºËSCTPЭÒéÎó²îÆÊÎöÓ븴ÏÖ

Ðû²¼Ê±¼ä 2019-05-30
Îó²îÅä¾°


LinuxÄÚºËSCTPЭÒéʵÏÖÖб£´æÒ»¸öÇå¾²Îó²îCVE-2019-8956£¨CNVD-2019-06182¡¢CNNVD-201902-823£©£¬¿ÉÒÔµ¼Ö¾ܾø·þÎñ¡£¸ÃÎó²î±£´æÓÚnet/sctp/socket.cÖеÄsctp_sendmsg()º¯Êý£¬¸Ãº¯ÊýÔÚ´¦Öóͷ£SENDALL±ê¼Ç²Ù×÷Àú³Ìʱ±£´æuse-after-freeÎó²î¡£


SCTPЭÒé¼ò½é


Á÷¿ØÖÆ´«ÊäЭÒ飨Stream Control Transmission Protocol£¬SCTP£©ÊÇÒ»ÖÖ¿É¿¿µÄ´«ÊäЭÒ飬ËüÔÚÁ½¸ö¶ËµãÖ®¼äÌṩÎȹ̡¢ÓÐÐòµÄÊý¾Ýת´ï·þÎñ£¨ºÜÊÇÀàËÆÓÚ TCP£©£¬²¢ÇÒ¿ÉÒÔ±£»¤Êý¾ÝÐÂÎŽçÏߣ¨ÀýÈç UDP£©¡£ÓëTCPºÍ UDP²î±ð£¬SCTP ÊÇͨ¹ý¶àËÞÖ÷£¨Multi-homing£©ºÍ¶àÁ÷£¨Multi-streaming£©¹¦Ð§ÌṩÕâЩÊÕÒæµÄ£¬ÕâÁ½ÖÖ¹¦Ð§¾ù¿ÉÌá¸ß¿ÉÓÃÐÔ¡£


¶àËÞÖ÷£¨Multi-homing£©ÎªÓ¦ÓóÌÐòÌṩÁË±È TCP ¸ü¸ßµÄ¿ÉÓÃÐÔ¡£¶àËÞÖ÷Ö÷»ú¾ÍÊÇһ̨¾ßÓжà¸öÍøÂç½Ó¿ÚµÄÖ÷»ú£¬Òò´Ë¿ÉÒÔͨ¹ý¶à¸ö IP µØµãÀ´»á¼ûÕą̂Ö÷»ú¡£ÔÚ TCP ÖУ¬ÅþÁ¬£¨connection£© ÊÇÖ¸Á½¸ö¶ËµãÖ®¼äµÄÒ»¸öͨµÀ£¨ÔÚÕâÖÖÇéÐÎÏ£¬¾ÍÊÇÁ½Ì¨Ö÷»úµÄÍøÂç½Ó¿ÚÖ®¼äµÄÒ»¸öÌ×½Ó×Ö£©¡£SCTP ÒýÈëÁË¡°ÍŽᣨassociation£©¡±µÄ¿´·¨£¬ËüÒ²ÊDZ£´æÓÚÁ½Ì¨Ö÷»úÖ®¼ä£¬µ«¿ÉÒÔʹÓÃÿ̨Ö÷»úÉϵĶà¸ö½Ó¿Ú¾ÙÐÐЭ×÷¡£

ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


Îó²îÔ­Àí


Îó²î²¹¶¡´úÂëÈçÏ£¬²¹¶¡´úÂ뽫list_for_each_entry»»³ÉÁËlist_for_each_entry_safe¡£


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ºê½ç˵list_for_each_entry¹¦Ð§ÊDZéÀúep->asocsÁ´±íÖеÄasoc½Úµã¡£ºê½ç˵list_for_each_entryºÍlist_for_each_entry_safeÈçÏÂËùʾ£º


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ºê½ç˵list_for_each_entry_safeÖÐÌí¼ÓÁËÒ»¸ön£¬¸ÃnÓÃÀ´´æ·ÅposÖ¸ÏòµÄ½ÚµãµÄÏÂÒ»¸ö½ÚµãλÖá£Ê¹Óøúê¿ÉÒÔ¶ÔÁ´±í¾ÙÐÐɾ³ý²Ù×÷¡£


ÏÂÃæÁÙsctp_sendmsgº¯ÊýŲÓÃÁ´¾ÙÐÐÆÊÎö¡£sctp_sendmsgÊÇ»ùÓÚSCTPЭÒéµÄsendmsgÀàÐͺ¯Êý£¬ÓÃÓÚ·¢ËÍSCTPÊý¾Ý°ü¡£Òªº¦ÊµÏÖÈçÏ£º


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ÐÐ2038£¬´ÓmsgÖÐÆÊÎö³ösinfo£»ÐÐ2043£¬»ñÈ¡µ½sflags¡£


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ÐÐ2055£¬ÅжÏsflagsÊÇ·ñΪSCTP_SENDALL¡£ÈôÊDZ£´æ£¬½øÈëlist_for_each_entryÑ­»·ÖУ¬ÒÀ´Î±éÀúep->asocsÁ´±í¡£ÕâÀïµÄasocs¾ÍÊÇ´æ·Å¶à¸öassociationÅþÁ¬µÄÁ´±í¡£SCTP_SENDALL±ê¼Ç´ú±íÏòasocsÁ´±íÖеÄËùÓÐassociationÅþÁ¬·¢ËÍÊý¾Ý°ü¡£ÒÔÊÇasocsÁ´±íÖÐÖÁÉÙÒª±£´æÒ»¸öassociation½Úµã¡£½øÈësctp_sendmsg_check_sflagsº¯Êýºó£¬¸Ãº¯ÊýʵÏÖÈçÏ£º


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


Ê×ÏÈ£¬¼ì²éasocÊÇ·ñ´¦ÓÚCLOSED״̬£¬¼ì²éasocÊÇ·ñ´¦ÓÚ¼àÌý״̬£¬¼ì²éasocÊÇ·ñshutdown¡£


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


½ÓÏÂÀ´£¬¼ì²ésflagsÊÇ·ñΪSCTP_ABORT£¬Æ¾Ö¤rfcÎĵµ¿ÉÖªABORTµÄÓ÷¨ÒÔ¼°ABORTÖ¸ÁîµÄÊý¾Ý°üÃûÌá£SCTP_ABORT±ê¼Ç´ú±íÖÐÖ¹Ò»¸öassociationÅþÁ¬£¬Õâ¸öÒ²Êǵ¼ÖÂÎó²îµÄÒªº¦¡£


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ÐÐ1863£¬sctp_make_abort_user½á¹¹ABORTÖ¸ÁîµÄchunk£»ÐÐ1868£¬Å²ÓÃsctp_primitive_ABORT·¢ËÍÖÐÖ¹Ò»¸öassociationµÄchunk¡£


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ͨ¹ýµ÷ÊÔ¿É֪ŲÓÃsctp_sf_do_9_1_prm_abortº¯Êý¾ÙÐÐABORT²Ù×÷£¬¸Ãº¯Êý½«»á¾ÙÐÐÈçϲÙ×÷£º


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


Ìí¼ÓÒ»Ìõɾ³ýasocµÄcommands£¬È»ºó·µ»ØSCTP_DISPOSITION_ABORT¡£Õý³£·µ»Ø£¬¼ÌÐøÆÊÎö£¬·µ»Øµ½sctp_do_smº¯ÊýÖС£


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ÐÐ1188Õý³£·µ»Øºó£¬ÐÐ1191ŲÓÃsctp_side_effectsº¯Êýƾ֤״̬»ú¶ÔÓ¦µÄ״̬¾ÙÐвÙ×÷¡£


ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ÐÐ1246£¬½«asocÖÿÕ£¬ABORT±ê¼Ç´ú±íÖÐÖ¹Ò»¸öassociation²Ù×÷¿¢Ê¡£´Ósctp_sendmsg_check_sflagsº¯Êý·µ»Øµ½sctp_sendmsgº¯ÊýÖУ¬ºêlist_for_each_entryÑ­»·ÖбéÀú»ñÈ¡µÚÒ»¸öasoc½Úµãʱ£¬½øÈësctp_sendmsg_check_sflagsº¯Êý½«µÚÒ»¸öasocÖÿÕ£¬È»ºóÔÙ¾ÙÐбéÀúºóÃæ½Úµãʱ£¬¾Í±¬·¢ÁËÁãµØµãÒýÓõ¼ÖÂÎó²î±¬·¢¡£


Îó²î¸´ÏÖ


½«sflagsÉèÖóÉSENDALL | ABORT£¬°ü¹Ü½øÈëlist_for_each_entryÑ­»·ºÍsctp_sendmsg_check_sflags()º¯Êý¼´¿É¡£ÔÚ4.20ÄÚºËÏÂÑéÖ¤ÈçÏ¡£ÓÉÓÚ¸ÃÎó²îÊÇNULL-PTR deref£¬¼´ÊÇÁãµØµã½âÒýÓã¬ÎÞ·¨½øÒ»²½Ê¹Óá£

ÓÅ·¢¹ú¼Ê¡¤ËæÓŶø¶¯Ò»´¥¼´·¢


ÐÞ¸´½¨Òé


¸ÃÎó²îÓ°ÏìLinux Kernel 4.19.xºÍ4.20.x£¬½¨Òé¸üе½version 4.20.8 »ò4.19.21¡£²¹¶¡Á´½ÓÈçÏ£ºhttps://git.kernel.org/linus/ba59fb0273076637f0add4311faa990a5eec27c0