Please ignore this patch and the next one shadow stack patch as well. These patches are my prototype before lsfmmbpf conference. Alexei has suggested a better approach which I will implement and post soon. On 6/4/24 10:55 AM, Yonghong Song wrote:
Try to add 3rd argument to bpf program where the 3rd argument is the frame pointer to bpf program stack. There are a few issues here: - Currently, only main bpf program is using shadow stack. other sub programs (static or global) still use stack. It is POSSIBLE to a hidden register to pass frame pointer (derived from main program) to those static or global functions. - But tail call and ext programs are not working now we we do not know at jit time what programs will be used in tail call and ext. It is possible to do some jit during text_poke time. But that will need additional stack allocation at jit time and that will be complicated. - For xdp program, need to patch jit for xdp dispatcher. Signed-off-by: Yonghong Song <yonghong.song@xxxxxxxxx> --- arch/x86/net/bpf_jit_comp.c | 105 +++++++++++++++++++++++++++++------- include/linux/bpf-cgroup.h | 9 ++-- include/linux/bpf.h | 29 ++++++---- include/linux/filter.h | 25 +++++++-- kernel/bpf/cgroup.c | 9 ++-- kernel/bpf/core.c | 36 +++++++++++-- kernel/bpf/offload.c | 3 +- 7 files changed, 173 insertions(+), 43 deletions(-)
[...]