In the Linux kernel, the following vulnerability has been resolved:
x86/MCE/AMD: Fix memory leak when thresholdcreatebank() fails
In mcethresholdcreatedevice(), if thresholdcreatebank() fails, the previously allocated threshold banks array @bp will be leaked because the call to mcethresholdremovedevice() will not free it.
This happens because mcethresholdremovedevice() fetches the pointer through the thresholdbanks per-CPU variable but bp is written there only after the bank creation is successful, and not before, when thresholdcreatebank() fails.
Add a helper which unwinds all the bank creation work previously done and pass into it the previously allocated threshold banks array for freeing.
[ bp: Massage. ]
[
{
"id": "CVE-2022-49549-07edc6be",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Line",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c"
},
"digest": {
"line_hashes": [
"98865187850246403594217387134457242572",
"220500634659700670900345318586710686494",
"32396130149229949277459664283369032324",
"129235138131256035279001934137652067374",
"71895436812835490876473009377663664496",
"307754191927717226077314384042422907130",
"164244904082721218879848330700957632265",
"331098942051249851830744378284498887195",
"273326007964054498324616075715160172676",
"229347368821456143251178312906799399619",
"238739231928532082113053900871141745626",
"145586822091903320296059980379640192617",
"242901364224294792752817937710837152601",
"200323716473515582835233269117231101540",
"328069189620479232663549944267544045229",
"32525972324408775302262888955998224502",
"233573369716280333167622442838265028002",
"217703139503395137815656086205449045721",
"54683191847825533208805552969470786093",
"243968537903120855237584826648371962651",
"313930157053015999058878407718174198464",
"282503508093702763332430824091456033615",
"255503118194588309039742331020016560059",
"158572846677813196321988215329322140143",
"247663668690355698474957400885572903695",
"176228870425705424720200444952518699547",
"51656744509040908257010276911845323069",
"196329885499182592979874845197918860724"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e5f28623ceb103e13fc3d7bd45edf9818b227fd0"
},
{
"id": "CVE-2022-49549-146a754d",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_create_device"
},
"digest": {
"function_hash": "286436873832572405640431805242475339441",
"length": 661.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b4acb8e7f1594607bc9017ef0aacb40b24a003d6"
},
{
"id": "CVE-2022-49549-299b9e08",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_remove_device"
},
"digest": {
"function_hash": "259628308252731732372610212240595543055",
"length": 350.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b4acb8e7f1594607bc9017ef0aacb40b24a003d6"
},
{
"id": "CVE-2022-49549-441623ac",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_remove_device"
},
"digest": {
"function_hash": "259628308252731732372610212240595543055",
"length": 350.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cc0dd4456f9573bf8af9b4d8754433918e809e1e"
},
{
"id": "CVE-2022-49549-53139f1e",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_create_device"
},
"digest": {
"function_hash": "286436873832572405640431805242475339441",
"length": 661.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9708f1956eeb70c86943e0bc62fa3b0101b59616"
},
{
"id": "CVE-2022-49549-67e8c9e7",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_create_device"
},
"digest": {
"function_hash": "286436873832572405640431805242475339441",
"length": 661.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@396b8e7ab2a99ddac57d3522b3da5e58cb608d37"
},
{
"id": "CVE-2022-49549-7551b5f3",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Line",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c"
},
"digest": {
"line_hashes": [
"98865187850246403594217387134457242572",
"220500634659700670900345318586710686494",
"32396130149229949277459664283369032324",
"129235138131256035279001934137652067374",
"71895436812835490876473009377663664496",
"307754191927717226077314384042422907130",
"164244904082721218879848330700957632265",
"331098942051249851830744378284498887195",
"273326007964054498324616075715160172676",
"229347368821456143251178312906799399619",
"238739231928532082113053900871141745626",
"145586822091903320296059980379640192617",
"242901364224294792752817937710837152601",
"200323716473515582835233269117231101540",
"328069189620479232663549944267544045229",
"32525972324408775302262888955998224502",
"233573369716280333167622442838265028002",
"217703139503395137815656086205449045721",
"54683191847825533208805552969470786093",
"243968537903120855237584826648371962651",
"313930157053015999058878407718174198464",
"282503508093702763332430824091456033615",
"255503118194588309039742331020016560059",
"158572846677813196321988215329322140143",
"247663668690355698474957400885572903695",
"176228870425705424720200444952518699547",
"51656744509040908257010276911845323069",
"196329885499182592979874845197918860724"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@396b8e7ab2a99ddac57d3522b3da5e58cb608d37"
},
{
"id": "CVE-2022-49549-75bb9293",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Line",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c"
},
"digest": {
"line_hashes": [
"98865187850246403594217387134457242572",
"220500634659700670900345318586710686494",
"32396130149229949277459664283369032324",
"129235138131256035279001934137652067374",
"71895436812835490876473009377663664496",
"307754191927717226077314384042422907130",
"164244904082721218879848330700957632265",
"331098942051249851830744378284498887195",
"273326007964054498324616075715160172676",
"229347368821456143251178312906799399619",
"238739231928532082113053900871141745626",
"145586822091903320296059980379640192617",
"242901364224294792752817937710837152601",
"200323716473515582835233269117231101540",
"328069189620479232663549944267544045229",
"32525972324408775302262888955998224502",
"233573369716280333167622442838265028002",
"217703139503395137815656086205449045721",
"54683191847825533208805552969470786093",
"243968537903120855237584826648371962651",
"313930157053015999058878407718174198464",
"282503508093702763332430824091456033615",
"255503118194588309039742331020016560059",
"158572846677813196321988215329322140143",
"247663668690355698474957400885572903695",
"176228870425705424720200444952518699547",
"51656744509040908257010276911845323069",
"196329885499182592979874845197918860724"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cc0dd4456f9573bf8af9b4d8754433918e809e1e"
},
{
"id": "CVE-2022-49549-7d1af586",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_remove_device"
},
"digest": {
"function_hash": "259628308252731732372610212240595543055",
"length": 350.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e5f28623ceb103e13fc3d7bd45edf9818b227fd0"
},
{
"id": "CVE-2022-49549-8bdd6877",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Line",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c"
},
"digest": {
"line_hashes": [
"98865187850246403594217387134457242572",
"220500634659700670900345318586710686494",
"32396130149229949277459664283369032324",
"129235138131256035279001934137652067374",
"71895436812835490876473009377663664496",
"307754191927717226077314384042422907130",
"164244904082721218879848330700957632265",
"331098942051249851830744378284498887195",
"273326007964054498324616075715160172676",
"229347368821456143251178312906799399619",
"238739231928532082113053900871141745626",
"145586822091903320296059980379640192617",
"242901364224294792752817937710837152601",
"200323716473515582835233269117231101540",
"328069189620479232663549944267544045229",
"32525972324408775302262888955998224502",
"233573369716280333167622442838265028002",
"217703139503395137815656086205449045721",
"54683191847825533208805552969470786093",
"243968537903120855237584826648371962651",
"313930157053015999058878407718174198464",
"282503508093702763332430824091456033615",
"255503118194588309039742331020016560059",
"158572846677813196321988215329322140143",
"247663668690355698474957400885572903695",
"176228870425705424720200444952518699547",
"51656744509040908257010276911845323069",
"196329885499182592979874845197918860724"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@b4acb8e7f1594607bc9017ef0aacb40b24a003d6"
},
{
"id": "CVE-2022-49549-9f5d987d",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_create_device"
},
"digest": {
"function_hash": "286436873832572405640431805242475339441",
"length": 661.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@cc0dd4456f9573bf8af9b4d8754433918e809e1e"
},
{
"id": "CVE-2022-49549-a272234a",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Line",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c"
},
"digest": {
"line_hashes": [
"98865187850246403594217387134457242572",
"220500634659700670900345318586710686494",
"32396130149229949277459664283369032324",
"129235138131256035279001934137652067374",
"71895436812835490876473009377663664496",
"307754191927717226077314384042422907130",
"164244904082721218879848330700957632265",
"331098942051249851830744378284498887195",
"273326007964054498324616075715160172676",
"229347368821456143251178312906799399619",
"238739231928532082113053900871141745626",
"145586822091903320296059980379640192617",
"242901364224294792752817937710837152601",
"200323716473515582835233269117231101540",
"328069189620479232663549944267544045229",
"32525972324408775302262888955998224502",
"233573369716280333167622442838265028002",
"217703139503395137815656086205449045721",
"54683191847825533208805552969470786093",
"243968537903120855237584826648371962651",
"313930157053015999058878407718174198464",
"282503508093702763332430824091456033615",
"255503118194588309039742331020016560059",
"158572846677813196321988215329322140143",
"247663668690355698474957400885572903695",
"176228870425705424720200444952518699547",
"51656744509040908257010276911845323069",
"196329885499182592979874845197918860724"
],
"threshold": 0.9
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9708f1956eeb70c86943e0bc62fa3b0101b59616"
},
{
"id": "CVE-2022-49549-bebc8f17",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_remove_device"
},
"digest": {
"function_hash": "259628308252731732372610212240595543055",
"length": 350.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@396b8e7ab2a99ddac57d3522b3da5e58cb608d37"
},
{
"id": "CVE-2022-49549-dd705481",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_remove_device"
},
"digest": {
"function_hash": "259628308252731732372610212240595543055",
"length": 350.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@9708f1956eeb70c86943e0bc62fa3b0101b59616"
},
{
"id": "CVE-2022-49549-ff5cabe7",
"deprecated": false,
"signature_version": "v1",
"signature_type": "Function",
"target": {
"file": "arch/x86/kernel/cpu/mce/amd.c",
"function": "mce_threshold_create_device"
},
"digest": {
"function_hash": "286436873832572405640431805242475339441",
"length": 661.0
},
"source": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git@e5f28623ceb103e13fc3d7bd45edf9818b227fd0"
}
]