Fix layer store Get locking
Fix layer store Get locking

Get was calling getReference without layerL held. This meant writes to
the references map could race. Such races are dangerous because they can
corrupt the map and crash the process.

Fixes #21616
Fixes #21674

Signed-off-by: Aaron Lehmann <8ecfc6017a87905413dcd7d63696a2a4c351b604@docker.com>

jzwlqx/denverdino.github.io,BenHall/docker,Syntaxide/docker,coreos/docker,jlebon/docker,laijs/docker,medallia/docker,inatatsu/docker,konstruktoid/docker-1,raja-sami-10p/moby,shin-/docker.github.io,jlebon/docker,gjaskiewicz/moby,anweiss/docker.github.io,mahak/docker,pyotr777/docker,ripcurld0/moby,rremer/moby,rhatdan/docker,ajaymdesai/docker,alexisbellido/docker.github.io,dsheets/moby,dims/docker,ibuildthecloud/docker,unclejack/docker,dmcgowan/docker,djs55/docker,qudongfang/docker,thaJeztah/docker,bdwill/docker.github.io,bearstech/moby,charleszheng44/moby,rhardih/docker,sanscontext/docker.github.io,jimjag/docker,kerneltime/docker,tklauser/docker,kunalkushwaha/docker,Ramzec/docker,yosifkit/docker,KingEmet/docker,HuKeping/docker,djs55/docker,cr7pt0gr4ph7/docker,mikedougherty/docker,willmtemple/docker,sarnautov/moby,lixiaobing1/docker,nalind/docker,londoncalling/docker.github.io,jwhonce/docker,13W/docker,yosifkit/docker,brahmaroutu/docker,rhatdan/docker,johnstep/docker.github.io,pecameron/docker,moul/docker,moul/docker,ColinHebert/docker,tophj-ibm/moby,rremer/moby,portworx/docker,q384566678/docker,jameszhan/docker,justyntemme/docker,TheBigBear/docker,BSWANG/denverdino.github.io,sdurrheimer/docker,yp-engineering/docker,lixiaobing10051267/docker,docker/docker,gnailuy/docker,jhorwit2/docker,mtesselH/docker,x1022as/docker,sanscontext/docker.github.io,flavio/docker,cyphar/docker,sdurrheimer/docker,sanscontext/docker.github.io,denverdino/denverdino.github.io,vdemeester/docker,xiekeyang/docker,dnephin/docker,POLJM242/docker,dccurtis/docker,rkazak/docker,PatrickLang/moby,asbjornenge/docker,sfsmithcha/docker,14rcole/docker,ffoysal/docker,sunyuan3/docker,alexisbellido/docker.github.io,nghiant2710/docker,mgoelzer/docker,crosbymichael/docker,srust/docker,asbjornenge/docker,nalind/docker,umerazad/docker,darrenstahlmsft/docker,dgageot/docker,imkin/moby,isubuz/docker,mixja/docker,rhardih/docker,AkihiroSuda/docker,hypriot/docker,darrenstahlmsft/moby,afein/docker,mixja/docker,mgoelzer/docker,liaoqingwei/docker,coolljt0725/docker,afein/docker,crosbymichael/docker,trebonian/docker,justincormack/docker,catinthesky/docker,jwhonce/docker,TrumanLing/docker,endophage/docker,joaofnfernandes/docker.github.io,anweiss/docker.github.io,tagomoris/docker,projectatomic/docker,13W/docker,thtanaka/docker,bdwill/docker.github.io,srust/docker,achanda/docker,djs55/docker,shubheksha/docker.github.io,joeuo/docker.github.io,darrenstahlmsft/docker,YuPengZTE/docker,michelvocks/docker,cpuguy83/docker,alexisbellido/docker.github.io,tophj-ibm/docker,JMesser81/docker,YujiOshima/docker,cyphar/docker,troy0820/docker.github.io,projectatomic/docker,shin-/docker.github.io,docker-zh/docker.github.io,dccurtis/docker,YuPengZTE/docker,x1022as/docker,docker/docker.github.io,catinthesky/docker,thaJeztah/docker.github.io,jzwlqx/denverdino.github.io,mohmost12/docker,srust/docker,moul/docker,moby/moby,docker/docker.github.io,dsau/docker,stainboy/docker,liaoqingwei/docker,HuKeping/docker,cr7pt0gr4ph7/docker,kolyshkin/moby,LuisBosquez/docker.github.io,catinthesky/docker,laijs/moby,fcrisciani/docker,jvanz/docker,prertik/docker,thtanaka/docker,unclejack/docker,rkazak/docker,tagomoris/docker,justyntemme/docker,coolljt0725/docker,geekylucas/docker,shishir-a412ed/docker,tmp6154/docker,shishir-a412ed/docker,scotttlin/docker,hqhq/moby,konstruktoid/docker-upstream,KarthikNayak/docker,mtanlee/docker,toli/docker,lixiaobing10051267/docker,yongtang/docker,ColinHebert/docker,tophj-ibm/docker,gdevillele/docker.github.io,shubheksha/docker.github.io,johnstep/moby-moby,tophj-ibm/moby,mikedougherty/docker,POLJM242/docker,sheimi/docker,ripcurld0/moby,denverdino/denverdino.github.io,paralin/docker,msabansal/docker,mtanlee/docker,inatatsu/docker,amatsus/docker,dongjoon-hyun/docker,madhanrm/docker,TheBigBear/docker,dims/docker,willmtemple/docker,shishir-a412ed/docker,cpuguy83/docker,alfred-landrum/docker,justyntemme/docker,mahak/docker,denverdino/docker.github.io,sarnautov/moby,moxiegirl/docker,BSWANG/denverdino.github.io,AkihiroSuda/docker,cyphar/docker,menglingwei/denverdino.github.io,asbjornenge/docker,bearstech/moby,nghiant2710/docker,HuKeping/docker,Mokolea/docker,HideoYamauchi/docker,gschaetz/moby,inatatsu/docker,mahak/docker,jlhawn/docker,darrenstahlmsft/moby,13W/docker,splunk/docker,umerazad/docker,sarnautov/moby,eskaaren/docker,allencloud/docker,jimjag/docker,phiroict/docker,dnephin/docker,shhsu/docker,kolyshkin/docker,unclejack/docker,wenchma/docker,Ramzec/docker,Tenk42/docker,sdurrheimer/docker,rillig/docker.github.io,johnstep/docker.github.io,dongjoon-hyun/docker,SvenDowideit/docker,mkumatag/docker,BenHall/docker,stainboy/docker,laijs/moby,bfirsh/docker,pyotr777/docker,tagomoris/docker,moxiegirl/docker,kojiromike/docker,yummypeng/docker,harche/docker,achanda/docker,xuxinkun/docker,dperny/docker,vdemeester/docker,Altiscale/docker,pecameron/docker,kojiromike/docker,sfsmithcha/docker,flavio/docker,haveatry/docker,michelvocks/docker,xuxinkun/docker,pyotr777/docker,Morsicus/docker,raja-sami-10p/moby,jongiddy/docker,thaJeztah/docker.github.io,anweiss/docker.github.io,maxamillion/docker,duglin/docker,nalind/docker,aduermael/docker.github.io,tkopczynski/docker,haveatry/docker,yp-engineering/docker,phiroict/docker,danix800/docker.github.io,joeuo/docker.github.io,ajaymdesai/docker,moby/moby,jthelin/docker,dccurtis/docker,yosifkit/docker,tonistiigi/docker,erikstmartin/docker,AkihiroSuda/docker,abhinavdahiya/docker,erikstmartin/docker,paralin/docker,tklauser/docker,nawawi/docker,BSWANG/denverdino.github.io,trebonian/docker,SvenDowideit/docker,mikebrow/docker,abhinavdahiya/docker,shhsu/docker,twaugh/docker,jzwlqx/denverdino.github.io,michael-holzheu/docker,konstruktoid/docker-upstream,allencloud/docker,lixiaobing10051267/docker,abhinavdahiya/docker,Mashimiao/docker,jongiddy/docker,scotttlin/docker,ffoysal/docker,moypray/docker,Syntaxide/docker,jimjag/docker,mtrmac/docker,moul/docker,TrumanLing/docker,gnailuy/docker,sfsmithcha/docker,kencochrane/docker,LuisBosquez/docker.github.io,danix800/docker.github.io,LaynePeng/docker,noironetworks/docker,13W/docker,jzwlqx/denverdino.github.io,pradipd/moby,ibuildthecloud/docker,joaofnfernandes/docker.github.io,johnstep/docker.github.io,endophage/docker,thaJeztah/docker.github.io,anweiss/docker.github.io,portworx/docker,pramodhkp/moby,Mashimiao/docker,trebonian/docker,gdevillele/docker.github.io,imkin/moby,nawawi/docker,TheBigBear/docker,pradipd/moby,whuwxl/docker,ndeloof/docker,icaoweiwei/docker,charleszheng44/moby,thaJeztah/docker,aduermael/docker.github.io,mtesselH/docker,DoraALin/docker,zhuguihua/docker,denverdino/docker.github.io,joeuo/docker.github.io,LuisBosquez/docker.github.io,YuPengZTE/docker,mtesselH/docker,YujiOshima/docker,kencochrane/docker,anujbahuguna/docker,nghiant2710/docker,rancher/docker,YujiOshima/docker,whuwxl/docker,darrenstahlmsft/docker,docker-zh/docker.github.io,Ramzec/docker,sanjeo/docker,endophage/docker,allencloud/docker,Mokolea/docker,jhorwit2/docker,paralin/docker,Mokolea/docker,londoncalling/docker.github.io,sanjeo/docker,cpuguy83/docker,jvanz/docker,anujbahuguna/docker,liaoqingwei/docker,darrenstahlmsft/moby,diogomonica/docker,trebonian/docker,Tenk42/docker,DoraALin/docker,thaJeztah/docker.github.io,docker/docker,mike1729/docker,michael-holzheu/docker,charleswhchan/docker,sterchelen/docker,JimGalasyn/docker.github.io,charleswhchan/docker,moby/moby,bearstech/moby,dsheets/moby,justincormack/docker,mahak/docker,BSWANG/denverdino.github.io,dgageot/docker,cloudflare/docker,konstruktoid/docker-upstream,Altiscale/docker,sunyuan3/docker,thtanaka/docker,wenchma/docker,shin-/docker.github.io,phiroict/docker,rhatdan/docker,KarthikNayak/docker,pramodhkp/moby,sunyuan3/docker,aduermael/docker.github.io,pramodhkp/moby,dperny/docker,twaugh/docker,joaofnfernandes/docker.github.io,Microsoft/docker,konstruktoid/docker-upstream,kojiromike/docker,jwhonce/docker,dmcgowan/docker,dnephin/docker,jlhawn/docker,alfred-landrum/docker,tophj-ibm/moby,charleszheng44/moby,brahmaroutu/docker,michael-holzheu/docker,diogomonica/docker,tmp6154/docker,mikebrow/docker,toli/docker,sean-jc/docker,containers/storage,rhatdan/storage,KingEmet/docker,thaJeztah/docker,mohmost12/docker,xiaods/docker,sean-jc/docker,Shopify/docker,noironetworks/docker,flavio/docker,michelvocks/docker,tklauser/docker,nalind/docker,londoncalling/docker.github.io,JimGalasyn/docker.github.io,akira-baruah/docker,achanda/docker,bfirsh/docker,mikebrow/docker,tianon/docker,vdemeester/docker,joaofnfernandes/docker.github.io,brahmaroutu/docker,mikedougherty/docker,docker/docker.github.io,miminar/docker,shubheksha/docker.github.io,q384566678/docker,estesp/docker,eskaaren/docker,joeuo/docker.github.io,sheimi/docker,thaJeztah/docker,jimjag/docker,imkin/moby,londoncalling/docker.github.io,gigidwan/docker,raja-sami-10p/moby,kunalkushwaha/docker,moby/moby,TrumanLing/docker,xiekeyang/docker,Syntaxide/docker,denverdino/docker.github.io,menglingwei/denverdino.github.io,x1022as/docker,bfirsh/docker,danyalKhaliq10p/moby,rhatdan/storage,stevvooe/docker,coolljt0725/docker,14rcole/docker,naveed-jamil-tenpearls/moby,jameszhan/docker,qudongfang/docker,geekylucas/docker,errordeveloper/docker,mike1729/docker,isubuz/docker,kolyshkin/docker,pradipd/moby,errordeveloper/docker,medallia/docker,pecameron/docker,resin-io/docker,Mokolea/docker,gigidwan/docker,gdevillele/docker.github.io,noxiouz/docker,maxamillion/docker,joeuo/docker.github.io,harche/docker,noironetworks/docker,troy0820/docker.github.io,gdevillele/docker.github.io,jvanz/docker,mixja/docker,JimGalasyn/docker.github.io,tonistiigi/docker,johnstep/moby-moby,cr7pt0gr4ph7/docker,nawawi/docker,estesp/docker,shin-/docker.github.io,yasiramin10p/moby,noxiouz/docker,coreos/docker,mohmost12/docker,akira-baruah/docker,kerneltime/docker,ibuildthecloud/docker,jhorwit2/docker,rillig/docker.github.io,erikstmartin/docker,resin-io/docker,denverdino/docker.github.io,danyalKhaliq10p/moby,jameszhan/docker,docker/docker,Shopify/docker,Microsoft/docker,alexisbellido/docker.github.io,xiaods/docker,rancher/docker,yasiramin10p/moby,ibuildthecloud/docker,yongtang/docker,rillig/docker.github.io,JMesser81/docker,estesp/docker,yongtang/docker,ibuildthecloud/docker,tmp6154/docker,menglingwei/denverdino.github.io,hqhq/moby,noxiouz/docker,erikh/docker,madhanrm/docker,dims/docker,medallia/docker,hypriot/docker,menglingwei/denverdino.github.io,Morsicus/docker,icaoweiwei/docker,bearstech/moby,hypriot/docker,kolyshkin/moby,konstruktoid/docker-1,gdevillele/docker.github.io,resin-io/docker,containers/storage,rremer/moby,whuwxl/docker,splunk/docker,errordeveloper/docker,OnePaaS/docker,bdwill/docker.github.io,troy0820/docker.github.io,phiroict/docker,bdwill/docker.github.io,miminar/docker,HideoYamauchi/docker,qudongfang/docker,bonczj/moby-json-file-logger,afein/docker,jlebon/docker,sterchelen/docker,moypray/docker,thaJeztah/docker.github.io,gschaetz/moby,yp-engineering/docker,msabansal/docker,danyalKhaliq10p/moby,runcom/docker,Shopify/docker,OnePaaS/docker,charleswhchan/docker,anujbahuguna/docker,danix800/docker.github.io,yummypeng/docker,denverdino/denverdino.github.io,containers/storage,sanscontext/docker.github.io,gschaetz/moby,alfred-landrum/docker,willmtemple/docker,dsheets/moby,mstanleyjones/docker,ColinHebert/docker,mtanlee/docker,runcom/docker,harche/docker,dperny/docker,tophj-ibm/docker,ffoysal/docker,moypray/docker,xiekeyang/docker,kencochrane/docker,zhuguihua/docker,erikh/docker,mkumatag/docker,isubuz/docker,gjaskiewicz/moby,wenchma/docker,portworx/docker,prertik/docker,icaoweiwei/docker,ajaymdesai/docker,londoncalling/docker.github.io,laijs/moby,twaugh/docker,geekylucas/docker,jlhawn/docker,toli/docker,yummypeng/docker,mtrmac/docker,erikh/docker,diogomonica/docker,gnailuy/docker,shhsu/docker,KingEmet/docker,Ramzec/docker,cloudflare/docker,rillig/docker.github.io,gjaskiewicz/moby,Altiscale/docker,coreos/docker,JimGalasyn/docker.github.io,sheimi/docker,aduermael/docker.github.io,cloudflare/docker,rancher/docker,mstanleyjones/docker,bluebreezecf/docker,shubheksha/docker.github.io,stevvooe/docker,LaynePeng/docker,mathewkoshy493/docker,ndeloof/docker,bluebreezecf/docker,tkopczynski/docker,justincormack/docker,yosifkit/docker,dsau/docker,bluebreezecf/docker,jongiddy/docker,kunalkushwaha/docker,LuisBosquez/docker.github.io,runcom/docker,duglin/docker,kerneltime/docker,xiaods/docker,flavio/docker,mtrmac/docker,ndeloof/docker,docker-zh/docker.github.io,crosbymichael/docker,maxamillion/docker,tkopczynski/docker,denverdino/denverdino.github.io,docker/docker.github.io,fcrisciani/docker,mkumatag/docker,troy0820/docker.github.io,JMesser81/docker,BenHall/docker,hqhq/moby,OnePaaS/docker,sanscontext/docker.github.io,docker-zh/docker.github.io,prertik/docker,HideoYamauchi/docker,gnailuy/docker,sanjeo/docker,moxiegirl/docker,Microsoft/docker,joaofnfernandes/docker.github.io,nawawi/docker,Tenk42/docker,PatrickLang/moby,docker-zh/docker.github.io,johnstep/docker.github.io,msabansal/docker,docker/docker.github.io,laijs/docker,haveatry/docker,gigidwan/docker,KarthikNayak/docker,jzwlqx/denverdino.github.io,amatsus/docker,sean-jc/docker,sterchelen/docker,bonczj/moby-json-file-logger,anweiss/docker.github.io,denverdino/denverdino.github.io,johnstep/docker.github.io,naveed-jamil-tenpearls/moby,LuisBosquez/docker.github.io,dongjoon-hyun/docker,dsau/docker,johnstep/moby-moby,lixiaobing1/docker,bdwill/docker.github.io,laijs/docker,rhatdan/storage,PatrickLang/moby,paralin/docker,konstruktoid/docker-1,JimGalasyn/docker.github.io,jthelin/docker,naveed-jamil-tenpearls/moby,stainboy/docker,mstanleyjones/docker,splunk/docker,madhanrm/docker,amatsus/docker,mike1729/docker,fcrisciani/docker,phiroict/docker,xuxinkun/docker,stevvooe/docker,medallia/docker,mgoelzer/docker,DoraALin/docker,SvenDowideit/docker,duglin/docker,yasiramin10p/moby,projectatomic/docker,danix800/docker.github.io,ripcurld0/moby,denverdino/docker.github.io,kolyshkin/moby,dmcgowan/docker,zhuguihua/docker,shin-/docker.github.io,shubheksha/docker.github.io,mathewkoshy493/docker,BSWANG/denverdino.github.io,rkazak/docker,menglingwei/denverdino.github.io,LaynePeng/docker,scotttlin/docker,13W/docker,Mashimiao/docker,umerazad/docker,q384566678/docker,miminar/docker,mathewkoshy493/docker,dgageot/docker,eskaaren/docker,AkihiroSuda/docker,Morsicus/docker,tonistiigi/docker,lixiaobing1/docker,alexisbellido/docker.github.io,cpuguy83/docker,bonczj/moby-json-file-logger,tianon/docker