Skip to content

Commit 40c76f2

Browse files
kgodara912Kshitiz GodaraKanishk-Bansal
authored
Patch luajit for CVE-2024-25177[HIGH] (#14436)
Co-authored-by: Kshitiz Godara <kgodara@microsoft.com> Co-authored-by: Kanishk Bansal <103916909+Kanishk-Bansal@users.noreply.github.com>
1 parent 76e22e5 commit 40c76f2

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

SPECS/luajit/CVE-2024-25177.patch

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 3c4209f69e4f0f3810b9acfde263569ef7c0a197 Mon Sep 17 00:00:00 2001
2+
From: Mike Pall <mike>
3+
Date: Tue, 23 Jan 2024 18:58:52 +0100
4+
Subject: [PATCH] Fix unsinking of IR_FSTORE for NULL metatable.
5+
6+
Reported by pwnhacker0x18. #1147
7+
8+
Upstream reference:
9+
https://github.com/LuaJIT/LuaJIT/commit/85b4fed0b0353dd78c8c875c2f562d522a2b310f
10+
---
11+
src/lj_snap.c | 11 ++++++++---
12+
1 file changed, 8 insertions(+), 3 deletions(-)
13+
14+
diff --git a/src/lj_snap.c b/src/lj_snap.c
15+
index 4140fdb..d2c454c 100644
16+
--- a/src/lj_snap.c
17+
+++ b/src/lj_snap.c
18+
@@ -453,6 +453,7 @@ static TRef snap_replay_const(jit_State *J, IRIns *ir)
19+
case IR_KNUM: case IR_KINT64:
20+
return lj_ir_k64(J, (IROp)ir->o, ir_k64(ir)->u64);
21+
case IR_KPTR: return lj_ir_kptr(J, ir_kptr(ir)); /* Continuation. */
22+
+ case IR_KNULL: return lj_ir_knull(J, irt_type(ir->t));
23+
default: lj_assertJ(0, "bad IR constant op %d", ir->o); return TREF_NIL;
24+
}
25+
}
26+
@@ -882,9 +883,13 @@ static void snap_unsink(jit_State *J, GCtrace *T, ExitState *ex,
27+
if (irk->o == IR_FREF) {
28+
lj_assertJ(irk->op2 == IRFL_TAB_META,
29+
"sunk store with bad field %d", irk->op2);
30+
- snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, &tmp);
31+
- /* NOBARRIER: The table is new (marked white). */
32+
- setgcref(t->metatable, obj2gco(tabV(&tmp)));
33+
+ if (T->ir[irs->op2].o == IR_KNULL) {
34+
+ setgcrefnull(t->metatable);
35+
+ } else {
36+
+ snap_restoreval(J, T, ex, snapno, rfilt, irs->op2, &tmp);
37+
+ /* NOBARRIER: The table is new (marked white). */
38+
+ setgcref(t->metatable, obj2gco(tabV(&tmp)));
39+
+ }
40+
} else {
41+
irk = &T->ir[irk->op2];
42+
if (irk->o == IR_KSLOT) irk = &T->ir[irk->op1];
43+
--
44+
2.45.4
45+

SPECS/luajit/luajit.signatures.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"Signatures": {
3-
"LuaJIT-2.1.0-beta3.tar.gz": "1ad2e34b111c802f9d0cdf019e986909123237a28c746b21295b63c9e785d9c3"
3+
"LuaJIT-2.1.0-beta3_v1.tar.gz": "409f7fe570d3c16558e594421c47bdd130238323c9d6fd6c83dedd2aaeb082a8"
44
}
5-
}
5+
}

SPECS/luajit/luajit.spec

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,23 @@ Name: luajit
55
Version: 2.1.0
66
%global apiver %(v=%{version}; echo ${v%.${v#[0-9].[0-9].}})
77
%global srcver %{version}%{?rctag:-%{rctag}}
8-
Release: 27%{?dist}
8+
Release: 28%{?dist}
99
License: MIT
1010
Vendor: Microsoft Corporation
1111
Distribution: Mariner
1212
URL: https://luajit.org/
13-
Source0: https://luajit.org/download/LuaJIT-%{srcver}.tar.gz
13+
Source0: https://github.com/LuaJIT/LuaJIT/archive/refs/tags/v2.1.0-beta3.tar.gz#/LuaJIT-%{srcver}_v1.tar.gz
1414

1515
# Patches from https://github.com/LuaJit/LuaJIT.git
1616
# Generated from v2.1 branch against the 2.1.0-beta3 tag using
1717
# git diff v2.1.0-beta3..v2.1 > luajit-2.1-update.patch
18-
Patch0: luajit-2.1-update.patch
18+
Patch0: luajit-2.1-update.patch
1919
# Patches from https://github.com/cryptomilk/LuaJIT/commits/v2.1-fedora
2020
# git format-patch --stdout -l1 --no-renames v2.1..v2.1-fedora > luajit-2.1-fedora.patch
21-
Patch1: luajit-2.1-fedora.patch
21+
Patch1: luajit-2.1-fedora.patch
2222
Patch2: CVE-2024-25178.patch
2323
Patch3: CVE-2024-25176.patch
24+
Patch4: CVE-2024-25177.patch
2425

2526
BuildRequires: gcc
2627
BuildRequires: make
@@ -96,6 +97,9 @@ make check || true
9697
%{_libdir}/pkgconfig/%{name}.pc
9798

9899
%changelog
100+
* Tue Aug 05 2025 Kshitiz Godara <kgodara@microsoft.com> - 2.1.0-28
101+
- Patch for CVE-2024-25177
102+
99103
* Thu Jul 17 2025 Azure Linux Security Servicing Account <azurelinux-security@microsoft.com> - 2.1.0-27
100104
- Patch for CVE-2024-25178, CVE-2024-25176
101105

cgmanifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12572,7 +12572,7 @@
1257212572
"other": {
1257312573
"name": "luajit",
1257412574
"version": "2.1.0",
12575-
"downloadUrl": "https://luajit.org/download/LuaJIT-2.1.0-beta3.tar.gz"
12575+
"downloadUrl": "https://github.com/LuaJIT/LuaJIT/archive/refs/tags/v2.1.0-beta3.tar.gz"
1257612576
}
1257712577
}
1257812578
},

0 commit comments

Comments
 (0)