bpf: Do not use ax register in interpreter on div/mod
authorDaniel Borkmann <daniel@iogearbox.net>
Fri, 24 Feb 2023 03:40:16 +0000 (03:40 +0000)
committerCosmin Tanislav <demonsingur@gmail.com>
Thu, 16 May 2024 07:58:25 +0000 (10:58 +0300)
commit0b5e2f59cd8d83d88934289c6cc7dfd27670094d
tree13ee9b1b8ba32a4e10a0f1909b46b12e99d99c68
parent9f567178ac18c9b9a5e216526bade3351e2f4177
bpf: Do not use ax register in interpreter on div/mod

Commit c348d806ed1d3075af52345344243824d72c4945 upstream.

Partially undo old commit 144cd91c4c2b ("bpf: move tmp variable into ax
register in interpreter"). The reason we need this here is because ax
register will be used for holding temporary state for div/mod instruction
which otherwise interpreter would corrupt. This will cause a small +8 byte
stack increase for interpreter, but with the gain that we can use it from
verifier rewrites as scratch register.

Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Reviewed-by: John Fastabend <john.fastabend@gmail.com>
[cascardo: This partial revert is needed in order to support using AX for
the following two commits, as there is no JMP32 on 4.19.y]
Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>
[edliaw: Removed redeclaration of tmp introduced by patch differences
between 4.14 and 4.19]
Signed-off-by: Edward Liaw <edliaw@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
kernel/bpf/core.c