In the Linux kernel, the following vulnerability has been resolved:
bpf: support non-r10 register spill/fill to/from stack in precision tracking
Use instruction (jump) history to record instructions that performed register spill/fill to/from stack, regardless if this was done through read-only r10 register, or any other register after copying r10 into it and potentially adjusting offset.
To make this work reliably, we push extra per-instruction flags into instruction history, encoding stack slot index (spi) and stack frame number in extra 10 bit flags we take away from prev_idx in instruction history. We don't touch idx field for maximum performance, as it's checked most frequently during backtracking.
This change removes basically the last remaining practical limitation of precision backtracking logic in BPF verifier. It fixes known deficiencies, but also opens up new opportunities to reduce number of verified states, explored in the subsequent patches.
There are only three differences in selftests' BPF object files according to veristat, all in the positive direction (less states).
File Program Insns (A) Insns (B) Insns (DIFF) States (A) States (B) States (DIFF)
testclsredirectdynptr.bpf.linked3.o clsredirect 2987 2864 -123 (-4.12%) 240 231 -9 (-3.75%) xdpsynproxykern.bpf.linked3.o syncookietc 82848 82661 -187 (-0.23%) 5107 5073 -34 (-0.67%) xdpsynproxykern.bpf.linked3.o syncookiexdp 85116 84964 -152 (-0.18%) 5162 5130 -32 (-0.62%)
Note, I avoided renaming jmphistory to more generic insnhist to minimize number of lines changed and potential merge conflicts between bpf and bpf-next trees.
Notice also curhistentry pointer reset to NULL at the beginning of instruction verification loop. This pointer avoids the problem of relying on last jump history entry's insnidx to determine whether we already have entry for current instruction or not. It can happen that we added jump history entry because current instruction isjmp_point(), but also we need to add instruction flags for stack access. In this case, we don't want to entries, so we need to reuse last added entry, if it is present.
Relying on insn_idx comparison has the same ambiguity problem as the one that was fixed recently in [0], so we avoid that.
[0] https://patchwork.kernel.org/project/netdevbpf/patch/20231110002638.4168352-3-andrii@kernel.org/
{
"cna_assigner": "Linux",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2023/52xxx/CVE-2023-52920.json"
}"https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2023-52920.json"
[
{
"id": "CVE-2023-52920-016cfc71",
"target": {
"function": "is_state_visited",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "299976458141597650380229796797986801166",
"length": 4950.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-026d101d",
"target": {
"function": "insn_stack_access_flags",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "306814996007008787064513923648638035378",
"length": 124.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-22c84b57",
"target": {
"file": "include/linux/bpf_verifier.h"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@41f6f64e6999a837048b1bd13a2f8742964eca6b",
"digest": {
"threshold": 0.9,
"line_hashes": [
"140532139050873191162410417543524739355",
"3484782133674882389076157257172997432",
"82358485641326839397213286016888028880",
"213997158198050984373504230134193214671",
"139721840325461942693362309463837940542",
"137964998661683468112508237355748128481",
"21199936090538613024297946944443686135",
"41012687593203527984931594375469264216",
"117798292647725610175386971588108271287",
"131834012581594985514076247897888705499",
"5795991495982744276085770634940407680",
"72528700585962672706385901968667636745",
"122777423581856316724647034700329516465",
"278074286726677412403816897685143496876",
"91074783226935790473271609347025531915"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-52920-406fe649",
"target": {
"function": "do_check",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@41f6f64e6999a837048b1bd13a2f8742964eca6b",
"digest": {
"function_hash": "169105039887119522910636596743693383349",
"length": 7842.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-43509913",
"target": {
"function": "bt_is_slot_set",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "10328667752267271871201838881406676343",
"length": 117.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-4c3bba95",
"target": {
"function": "__mark_chain_precision",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "338957161489719404792972901045014355550",
"length": 3761.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-4d217c26",
"target": {
"function": "check_stack_write_fixed_off",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@ecc2aeeaa08a355d84d3ca9c3d2512399a194f29",
"digest": {
"function_hash": "51790541305876894504910622158170434253",
"length": 2659.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-4d7ae642",
"target": {
"function": "insn_stack_access_frameno",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "239072133674844321216022696949831280581",
"length": 78.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-50ab7ff4",
"target": {
"file": "tools/testing/selftests/bpf/progs/verifier_subprog_precision.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"threshold": 0.9,
"line_hashes": [
"10547149265620956432059237712282531994",
"299237588692627442256881215538880571654",
"121683151768837353058715541144469681607",
"270056369557930048901352836204321002267",
"183255313607736220876739360029981324934",
"31310476136250666245955313480429085933",
"197608254799678991986977818394719974953",
"337817407349546465556389107639594172347",
"6231872468577386307735159295924280752",
"328833408206882893339369474436289795411",
"76989564326485387407355241912475820423",
"17317507024282289160213663639434697746",
"72027613218039100168999621779507037236",
"320269358579585516002663136067013304498",
"45396886281007816422248981536895463871",
"34707032999762336388468726785792243905",
"210003916082003383209700377050530192584",
"274272856829164182857880393766897735924",
"274707469185108058246116363023586647514",
"236280938405348821291203012933457772532",
"270087038159440230465033146386637309905"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-52920-554c9be2",
"target": {
"function": "backtrack_insn",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "318831636299082244872120040667120509108",
"length": 5013.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-705c5438",
"target": {
"function": "check_stack_write_fixed_off",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@41f6f64e6999a837048b1bd13a2f8742964eca6b",
"digest": {
"function_hash": "137438487940574202321642154342745166893",
"length": 2766.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-86f707d6",
"target": {
"function": "backtrack_insn",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@41f6f64e6999a837048b1bd13a2f8742964eca6b",
"digest": {
"function_hash": "297100524911509667375802228924106613938",
"length": 4778.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-8ddd4bda",
"target": {
"function": "get_jmp_hist_entry",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "41356590849001313430770392704717314016",
"length": 203.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-8e02e8db",
"target": {
"function": "bt_is_frame_slot_set",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "285883630310623906332694960478233351050",
"length": 139.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-8e32941e",
"target": {
"function": "is_state_visited",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@41f6f64e6999a837048b1bd13a2f8742964eca6b",
"digest": {
"function_hash": "227752843535807636837508176970367606208",
"length": 4872.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-9127194e",
"target": {
"file": "tools/testing/selftests/bpf/verifier/precise.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"threshold": 0.9,
"line_hashes": [
"283507062745254716050779800522459279243",
"50509274575637547348598012596283845111",
"232766213742760663081627762138868072872",
"198302346538439651100918624280140953782",
"295305856811287026158849181195170879646",
"133965324547098557974429686927964222223",
"317507966042438901818642907202535850268",
"219259013177157046042507534001269850066",
"126031678972101392117176262918044271496",
"78742998195326214708407104814690605056",
"206927905472333898382419995332568160318",
"3760154429661632239424439008948654455",
"60585565299221510434519379907508590989",
"73804845183761959991807038384424684024",
"216991698889870847361928215928885067093",
"182574845668235303407407697228599616223",
"43844238085931251300975991190500500621",
"52895361206469584051414128923406687006",
"108500228432065231065112727499840397781"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-52920-9f079f14",
"target": {
"file": "include/linux/bpf_verifier.h"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"threshold": 0.9,
"line_hashes": [
"192909504703736310961068532952345258119",
"42246903500315681290555153306902848939",
"200824040226876447549900206947679815078",
"304542660123835223091911339784171437695",
"223628627672751672104136552955462674369",
"76707228284769280772307157748143675359",
"3428409499166637939455043870201784547",
"113331454795366517033680453295979995556",
"264938394849592641538511410456307902990",
"309358101984430420133210347279199567412",
"21538473288454811250680175416594179948",
"130160963018577962849298538796846492794",
"172053625339750562684565452768069798817",
"222281251089247728250750384102215797042",
"116874498929515102080903428603330639468",
"21199936090538613024297946944443686135",
"261019566859385677091295510161457639505",
"284528462970261732553942723791098996722",
"178232140568756179156341650378736185307",
"69237771562425562759921919199487819720",
"339079997331260663425473745146924356913",
"252196846407342714297176614414911593136",
"93537778751342865781950348323455655764",
"210989374273102458684208658552780958661"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-52920-a2e98aa5",
"target": {
"function": "copy_verifier_state",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "23518830588609602154301661119267857911",
"length": 1403.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-be99071f",
"target": {
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"threshold": 0.9,
"line_hashes": [
"90221370873292630744337253846010944773",
"190871220955677066225469020820725868228",
"336517196412906526520141638837195769780",
"298394526903529050772818519845002870816",
"324989002708629452933998448000632292436",
"123911663349287209973728202806004469852",
"296889943823653828303692123415258971120",
"163750645571321044421303047101982288493",
"83421875788429827439878518217628146072",
"194691896089133649614435537036503183211",
"66472154137060275596365186862789013550",
"241737821082696184618467833103008151834",
"314311883599493514345218328087419838287",
"20876198382283000651297741156342401680",
"292942210246634335378080766247287755067",
"232873253368157596235210255245713715841",
"73441995823308648119403403378848592979",
"29693822699442111211495481595593647400",
"141428225697867723662703369532293707237",
"274589272044978766723707828920778856819",
"278506866796805019765404930439276380507",
"267290497128162955974862246911527597689",
"200854882195276566960071068282112626222",
"8688954091280720185431155570575323788",
"170516157561060060786258684149614662462",
"158694174166878629219287479547577017581",
"243462222497075845083865999670081654108",
"70710719857967207648351266280627950654",
"49804141111795553210738605035920932609",
"30354334775776301441714549635577189870",
"65295143281820240450370634191594191400",
"317345178437489448491883283703583204178",
"260646352873101927945006101432238979558",
"92454091061473374495431708692933924715",
"172191154882240977352669273220683203458",
"113659296096059974743624702122023652002",
"285979261125057241764595886168252773461",
"44508125289036417408037675208177765621",
"329981465964485657021277497681034301404",
"179825198149267690560360108398598551517",
"5999380586204924386527411442171841378",
"124445628887903533253238663025797883308",
"54630220148725046090588951338801465012",
"316210995107634656098667179012577037096",
"165681805205054242320189476035187770646",
"270169579157372771654179597505323480554",
"37475695505810058238938884891301897010",
"297599634296662862837256966229879575660",
"56292270971518640421123488474775596179",
"31072084967188066096776749757212154848",
"270498077910662756087327568553667460556",
"194303944925856119086181447415515173772",
"223970155397866040902293795458316353528",
"44754250033435213091330906085304558184",
"280240192499102263179929005636606133508",
"290785137521504932261873400011752612128",
"111222244024700047722459135070307335240",
"290238400623662487071888679773825791999",
"79145675980255468627999092394260287137",
"199837845939785828047485935555147647232",
"209322917021286024198880044651548799017",
"315840033382246663005052650940714104537",
"185870705146219685892138736347912405842",
"238307385768716579304683877549284739501",
"267412933340471508018754257140903873471",
"106035077579975932211215111787013971172",
"43868515524913602189793198270278330194",
"276045074819799443022024946923797810887",
"9880935109708144674829787096474574027",
"77120529137535413172128503150404365554",
"311439085421104632372443933314786018278",
"190213912908489821734826155337211538077",
"203133193479753091093192437701178962005",
"333593351353585799600617266708656365057",
"304461831629545496017312864968164053083",
"114592840045452370373906989283283239795",
"154081310995177181973588354940043962667",
"109852839579108145759437282603778086764",
"90978916420437631711987032505003408103",
"170025409981212106105239145828475752825",
"89610760661771535808842942736285449241",
"180140177737523143423039162399603879045",
"56180965700548112030101554044074394936",
"35037919470367714406341343964727065334",
"246574994029719161648104131548709595782",
"150409983387130514160928192979739978084",
"273992937351238573050128681761435787448",
"170025409981212106105239145828475752825",
"217025619861384601540675536270718686531",
"157549190222339266514088372553297052954",
"191777432604674953752706164564361729966",
"31250360794506955855029223919803221263",
"297922445955184375247639252244780681377",
"7480507868912214428867076725788698848",
"218771478213613872818360932582247585958",
"288486909054537786661316809129324434314",
"30066805946914962218597002436180238521",
"304971660658916775661215635796185447501",
"132330059065460660640163684821744073191",
"234022635080702353779325391354356295617",
"134134717204741853558135387908948340745",
"158237205362588436773738531905402296578",
"218771478213613872818360932582247585958",
"288486909054537786661316809129324434314",
"199440018177215305450026113802131188836",
"43717122407729170635334652933786595748",
"288134173381004260093140869900092936914",
"321890314775501528924882536342745109952",
"208307979590697552254654293714502297968",
"222907120807490471117403184113143374526",
"21392373451822933580489995939661017703",
"289959247190785680534611312496273744459",
"168038211416539876310736859339135580791",
"326944235326599263593892037207364311632",
"206418878483765475589397691182661030163",
"155498731846870272984745106400894971866",
"124172913113747199841033421219452651889",
"28644088085628721158101588659502428676",
"72958951278467290491881383670579965990",
"337510425519614117252998338272203108948",
"40981027507115863672676925344608478907",
"246481769804973782967131350621577180675",
"58751343121776469887955290460538863579",
"333453990007159272166379999996644330722",
"312257708547027120838206523470990572245",
"44973904435809659116084467422019462567",
"154171318088859487775197543648947633456",
"124112025572927037205678111761953541089",
"229433935405314099397822777115608486791",
"119792657518172181840515762346315585713",
"193252396012922979627830821697040543974",
"86397256813596950862626282350703328187",
"131094220065503627553998380224258210033",
"266699352017543853716714359491853713007",
"154236774331942054170835084851284472298",
"268205647516942270103060293538955408502",
"1077441525787131939939972256441124510",
"183060091755179059613993051320134566636",
"30197443924223859398814978081679126849",
"186814496799023926122331530725041288201",
"233143242546346576402735892496001397486",
"239246144339721815827409195522792944847",
"332089637567125054368059331233489110980",
"66424758950749398046107273162310767122",
"314776701699239982269878699345515502362",
"235765044709586793418909518505230728265",
"183187834988804729525855146584130169523",
"48424026965173090421023719857065244309",
"29144091771168306908206539730066198734",
"278783913077933072733358685657405860346",
"336691937281360284606902772405551956669",
"77784451058871904442024876639815768599",
"167769664832445935748065066233344432059",
"146805189791218463550389574965795888787",
"332012794884909338107826072736995451716",
"142142867672662309139809306941423144461",
"340106984887739547229231356155095738047",
"274061706173448582800370975803360095874",
"192465321444691437798088678662582225523",
"44152641176781142891209725604477027994",
"332089637567125054368059331233489110980",
"66424758950749398046107273162310767122",
"314776701699239982269878699345515502362",
"90821157903960253411921992513443754901",
"66387418162116967352357217944516388344",
"213637199355543533077451480379048848613",
"109759860439517632126431721677061719349",
"327731246370167621813518442475581040958",
"30823181356425744407886214088379540442",
"183702947729262111767764097919811665904",
"278076050371484417187837383481208420251",
"147192824318127492488770392696255680970",
"125524315909087560044368028875411085492",
"83653151363792217510865066421296037873",
"337118017502545234113710131772483431212",
"190452153552690526658729230356658483392",
"110064869055214975553627552318690722189",
"201252462358831539440892812487631965895",
"223367003904556567578011865936164499061",
"98694743398501121148679695100565155875",
"16590108329222034188655487185974313559"
]
},
"signature_type": "Line"
},
{
"id": "CVE-2023-52920-e1d3ed8c",
"target": {
"function": "check_stack_read_fixed_off",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "155904300367452973090187928223181306861",
"length": 2445.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-f0f43f95",
"target": {
"function": "check_stack_write_fixed_off",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "198259437612742541125468453373835413930",
"length": 2725.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-f6178ae2",
"target": {
"function": "push_jmp_history",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "212554111687811634788366121929753351474",
"length": 870.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-f9ba6a3c",
"target": {
"function": "do_check",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "236737726864680322291276166307058616914",
"length": 7628.0
},
"signature_type": "Function"
},
{
"id": "CVE-2023-52920-ff3fe62c",
"target": {
"function": "insn_stack_access_spi",
"file": "kernel/bpf/verifier.c"
},
"signature_version": "v1",
"deprecated": false,
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@199f0452873741fa4b8d4d88958e929030b2f92b",
"digest": {
"function_hash": "111494875535071295376272914882695405561",
"length": 98.0
},
"signature_type": "Function"
}
]