LinuxÄÚºËSCTPÐÒéÎó²îÆÊÎöÓ븴ÏÖ
Ðû²¼Ê±¼ä 2019-05-30LinuxÄÚºË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£©¹¦Ð§ÌṩÕâЩÊÕÒæµÄ£¬ÕâÁ½ÖÖ¹¦Ð§¾ù¿ÉÌá¸ß¿ÉÓÃÐÔ¡£

Îó²îÔÀí
Îó²î²¹¶¡´úÂëÈçÏ£¬²¹¶¡´úÂ뽫list_for_each_entry»»³ÉÁËlist_for_each_entry_safe¡£
ºê½ç˵list_for_each_entry_safeÖÐÌí¼ÓÁËÒ»¸ön£¬¸ÃnÓÃÀ´´æ·ÅposÖ¸ÏòµÄ½ÚµãµÄÏÂÒ»¸ö½ÚµãλÖá£Ê¹Óøúê¿ÉÒÔ¶ÔÁ´±í¾ÙÐÐɾ³ý²Ù×÷¡£
ÐÐ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