"value":"In the Linux kernel, the following vulnerability has been resolved:\n\nmaple_tree: correct tree corruption on spanning store\n\nPatch series \"maple_tree: correct tree corruption on spanning store\", v3.\n\nThere has been a nasty yet subtle maple tree corruption bug that appears\nto have been in existence since the inception of the algorithm.\n\nThis bug seems far more likely to happen since commit f8d112a4e657\n(\"mm/mmap: avoid zeroing vma tree in mmap_region()\"),whichisthepoint\natwhichreportsstartedtobesubmittedconcerningthisbug.\n\nWeweremadedefinitelyawareofthebugthankstothekindeffortsof\nBertKarwatzkiwhohelpedenormouslyinmybeingabletotrackthisdown\nandidentifythecauseofit.\n\nThebugariseswhenanattemptismadetoperformaspanningstoreacross\ntwoleafnodes,wheretherightleafnodeistherightmostchildofthe\nsharedparent,ANDthestorecompletelyconsumestheright-modenode.\n\nThisresultsinmas_wr_spanning_store()mitakenlyduplicatingthenewand\nexistingentriesatthemaximumpivotwithintherange,andthusmaple\ntreecorruption.\n\nThefixpatchcorrectsthisbydetectingthisscenarioanddisallowingthe\nmistakenduplicatecopy.\n\nThefixpatchcommitmessagegoesintogreatdetailastohowthisoccurs.\n\nThisseriesalsoincludesatestwhichreliablyreproducestheissue,and\nassertsthatthefixworkscorrectly.\n\nBerthaskindlytestedthefixandconfirmeditresolvedhisissues.Also\nMikhailGavrilovkindlyreportedwhatappearstobepreciselythesame\nbug,whichthisfixshouldalsoresolve.\n\n\nThispatch(of2):\n\nTherehasbeenasubtlebugpresentinthemapletreeimplementationfrom\nitsinception.\n\nThisarisesfromhowstoresareperformed-whenastoreoccurs,itwill\noverwriteoverlappingrangesandadjustthetreeasnecessaryto\naccommodatethis.\n\nArangemayalwaysultimatelyspantwoleafnodes.Inthisinstancewe\nwalkthetwoleafnodes,determinewhichelementsarenotoverwrittento\ntheleftandtotherightofthestartandendoftherangesrespectively\nandthenrebalancethetreetocontaintheseentriesandthenewly\ninsertedone.\n\nThiskindofstoreisdubbeda'spanningstore'andisimplementedby\nmas_wr_spanning_store().\n\nInordertoreachthisstage,mas_store_gfp()invokes\nmas_wr_preallocate(),mas_wr_store_type()andmas_wr_walk()inturnto\nwalkthetreeandupdatetheobject(mas)totraversetothelocation\nwherethewriteshouldbeperformed,determiningitsstoretype.\n\nWhenaspanningstoreisrequired,thisfunctionreturnsfalsestoppingat\ntheparentnodewhichcontainsthetargetrange,andmas_wr_store_type()\nmarksthemas->store_typeaswr_spanning_storetodenotethisfact.\n\nWhenwegotoperformthestoreinmas_wr_spanning_store(),wefirst\ndeterminetheelementsAFTERtheENDoftherangewewishtostore(that\nis,totherightoftheentrytobeinserted)-wedothisbywalkingto\ntheNEXTpivotinthetree(i.e.r_mas.last+1),startingatthenodewe\nhavejustdeterminedcontainstherangeoverwhichweintendtowrite.\n\nWethenturnourattentiontotheentriestotheleftoftheentryweare\ninserting,whosestateisrepresentedbyl_mas,andcopytheseintoa'big\nnode',whichisaspecialnodewhichcontainsenoughslotstocontaintwo\nleafnode'sworthofdata.\n\nWethencopytheentrywewishtostoreimmediatelyafterthis-thecopy\nandtheinsertionofthenewentryisperformedbymas_store_b_node().\n\nAfterthiswecopytheelementstotherightoftheendoftherangewhich\nweareinserting,ifwehavenotexceededthelengthofthenode(i.e.\nr_mas.offset<=r_mas.end).\n\nHereinliesthebug-underveryspecificcircumstances,thislogiccan\nbreakandcorruptthemapletree.\n\nConsiderthefollowingtree:\n\nHeight\n0RootNode\n/\\\npivot=0xffff/\\pivot=ULONG_MAX\n