arch/arm64/kernel/probes/uprobes.c

Source file repositories/reference/linux-study-clean/arch/arm64/kernel/probes/uprobes.c

File Facts

System
Linux kernel
Corpus path
arch/arm64/kernel/probes/uprobes.c
Extension
.c
Size
5510 bytes
Lines
227
Domain
Architecture Layer
Bucket
arch/arm64
Inferred role
Architecture Layer: implementation source
Status
source implementation candidate

Why This File Exists

CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.

Dependency Surface

Detected Declarations

Annotated Snippet

if (err) {
			force_sig(SIGSEGV);
			goto out;
		}

		/*
		 * If the LR and GCS return addr don't match, then some kind of PAC
		 * signing or control flow occurred since entering the probed function.
		 * Likely because the user is attempting to retprobe on an instruction
		 * that isn't a function boundary or inside a leaf function. Explicitly
		 * abort this retprobe because it will generate a GCS exception.
		 */
		if (gcs_ret_vaddr != orig_ret_vaddr) {
			orig_ret_vaddr = -1;
			goto out;
		}

		put_user_gcs(trampoline_vaddr, (__force unsigned long __user *)gcspr, &err);
		if (err) {
			force_sig(SIGSEGV);
			goto out;
		}
	}

	/* Replace the return addr with trampoline addr */
	procedure_link_pointer_set(regs, trampoline_vaddr);

out:
	return orig_ret_vaddr;
}

int arch_uprobe_exception_notify(struct notifier_block *self,
				 unsigned long val, void *data)
{
	return NOTIFY_DONE;
}

int uprobe_brk_handler(struct pt_regs *regs,
				     unsigned long esr)
{
	if (uprobe_pre_sstep_notifier(regs))
		return DBG_HOOK_HANDLED;

	return DBG_HOOK_ERROR;
}

int uprobe_single_step_handler(struct pt_regs *regs,
				      unsigned long esr)
{
	struct uprobe_task *utask = current->utask;

	WARN_ON(utask && (instruction_pointer(regs) != utask->xol_vaddr + 4));
	if (uprobe_post_sstep_notifier(regs))
		return DBG_HOOK_HANDLED;

	return DBG_HOOK_ERROR;
}

Annotation

Implementation Notes