From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387450; b=vdtf62UZlHrT1Lal2P49xZe1o7fcEcgF7cGbEj9n8EOHuGJUaxU4WLL66xZcJxgOMQlr 3C6MYN+s1eWF5fPHt2NqiJjzzvilhKXTxEfJ+WQhEuK0kG5fuX6DpC+qlDHk4+cDRbFba I7W2XAJL0Y93rikdWFrcnJzdHcbU35Vbt6orzXgXhcLHjH9UrYsh2LBkYWKT+pnJLjY3J lzJFLxdiM/Udmct/ZRFFJ38JRvyvp5EuhcNGmrOLIAsyWERXk/76bJ8AgMWA68c8JzqGF AxThJegZiQ3UauM6iJJVsZvEdUF8RG6fMudcoXTVhdNiN2DJ4OU4y5La8u07DMjtnzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387450; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=eoEKLHd73ZZcTWQcPsKisagzcrCR2iz/0x13hWYOWwU=; b=TZWpMRXkG8jQ4S10YBB8X//2WmX8VimIabSzNOg94W2gOK2i7kDMmzWmXVwiYCmgi7Gl cNPDMFDgKe9F2TRY0v7okWfuL4YIRydP/O3D7G90319nyyeJ8RCBV+Or7ZbxrbxGSSaZk huZ/wo2VJNYthayEOikSEJCPffSxe1n8DXz1BWHgaJxr5ByvV07Zei8j3QxXvDUGqCa2j dFEdVSKEDS6yldVB678okJyYrUmuNPJuRRfajmcLfKOPjbrfGYwXkv/PJaNxc8xBeojcS iZVqLG3COzSORb3rfsUBSEblVXRMwHgai+I/y3m2+G5Jq0x3RAEWqovCDhty45GFaEw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="Q/ha6DuR"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF674606A33A; Fri, 4 Dec 2026 12:30:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Q/ha6DuR Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57C7D1F000C2; Fri, 4 Dec 2026 12:30:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796387450; bh=eoEKLHd73ZZcTWQcPsKisagzcrCR2iz/0x13hWYOWwU=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=Q/ha6DuRjCj2ORc1e74WjtjTFc62n+1K9F0X+hY98zApBxRR/E8Vm7BNOVKznJ1fr FEfme3u98XKExcpM/pfzraLOL6hTgbwQrn1cSFnXhZYiK+TUE83olW46vFTJQgtqMZ +hIePMQeufo8swPgFuHAPY/jBGuKH1jXqp6L0N3H3EVx3WcPPCYaYpJpMiVpw2BWGm CTP33VX9gjRLqh8dGWmkvvlCY96kr7AyN9C4WgHo1BknQD/Gtw1TwxkCpaD1ymhCr5 RnI1fiSvpcM9F9626gRiCSyd+S9abj7XpAbhyItCGLN3VsPr+46Ka25RPzYitzTdUT oVNnFLkpYUrgQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH 10/10] s390/perf: Recognize SAE guests Reply-To: sashiko-reviews@lists.linux.dev To: "Andreas Grapentin" Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-perf-users@vger.kernel.org, "Heiko Carstens" , "Vasily Gorbik" , "Alexander Gordeev" , "Christian Borntraeger" In-Reply-To: <20261204-host-irq-v1-10-a8387ee8a380@linux.ibm.com> References: <20261204-host-irq-v1-0-a8387ee8a380@linux.ibm.com> <20261204-host-irq-v1-10-a8387ee8a380@linux.ibm.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 12:30:49 +0000 X-Mailing-List: linux-perf-users@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] s390/perf: NULL dereference of sae_block() in perf_arch_instruction_pointer() -- commit 4b5d91e0d26617e654b0c5cf570e3076efc5d4a8 Author: Andreas Grapentin s390/perf: Recognize SAE guests This commit extends s390 perf guest detection to recognize ARM64 SAE guests alongside SIE guests, retrieving the guest instruction pointer and user/kernel mode from struct kvm_sae_block. > diff --git a/arch/s390/kernel/perf_event.c b/arch/s390/kernel/perf_event.c > index 606750bae508d..00464fbe33ead 100644 > --- a/arch/s390/kernel/perf_event.c > +++ b/arch/s390/kernel/perf_event.c [ ... ] > @@ -33,31 +34,64 @@ static struct kvm_s390_sie_block *sie_block(struct pt= _regs *regs) > return (struct kvm_s390_sie_block *)stack->sie_control_block; > } > =20 > -static bool is_in_guest(struct pt_regs *regs) > +static struct kvm_sae_block *sae_block(struct pt_regs *regs) > { > - if (user_mode(regs)) > - return false; > -#if IS_ENABLED(CONFIG_KVM) > - return instruction_pointer(regs) =3D=3D (unsigned long) &sie_exit; > -#else > - return false; > -#endif > + struct stack_frame *stack =3D (struct stack_frame *)regs->gprs[15]; > + > + if (!stack) > + return NULL; > + > + return (struct kvm_sae_block *)stack->sae_block; > } > =20 > -static unsigned long guest_is_user_mode(struct pt_regs *regs) > +enum guest_type { > + GUEST_TYPE_NONE =3D 0, > + GUEST_TYPE_SIE, > + GUEST_TYPE_SAE, > +}; > + > +static enum guest_type is_in_guest(struct pt_regs *regs) > { > - return sie_block(regs)->gpsw.mask & PSW_MASK_PSTATE; > +#if IS_ENABLED(CONFIG_KVM) > + if (user_mode(regs)) > + return GUEST_TYPE_NONE; > + if (instruction_pointer(regs) =3D=3D (unsigned long)&sie_exit) > + return GUEST_TYPE_SIE; > + if (instruction_pointer(regs) =3D=3D (unsigned long)&sae_exit) > + return GUEST_TYPE_SAE; > +#endif > + return GUEST_TYPE_NONE; > } [ ... ] > unsigned long perf_arch_instruction_pointer(struct pt_regs *regs) > { > - return is_in_guest(regs) ? instruction_pointer_guest(regs) > - : instruction_pointer(regs); > + switch (is_in_guest(regs)) { > + case GUEST_TYPE_SIE: > + return sie_block(regs)->gpsw.addr; > + case GUEST_TYPE_SAE: > + return sae_block(regs)->pc; > + default: > + return instruction_pointer(regs); > + } > } [Severity: High] Can sae_block(regs)->pc cause a NULL pointer dereference when called with synthetic pt_regs from CPU-MF sampling? In arch/s390/kernel/perf_cpum_sf.c, perf_push_sample() builds a zero-initialized pt_regs (leaving regs.gprs[15] =3D=3D 0) with the sampled instruction address and pstate in regs.psw, then calls perf_event_overflow() -> ... -> perf_arch_instruction_pointer(). Unlike perf_arch_misc_flags(), which checks !regs->gprs[15] before calling is_in_guest(), neither is_in_guest() nor perf_arch_instruction_pointer() guards against a zero stack pointer. When a supervisor-mode hardware sample lands on sae_exit, is_in_guest() returns GUEST_TYPE_SAE, sae_block() returns NULL, and sae_block(regs)->pc dereferences a NULL pointer. With relocated lowcore enabled, address 0 is unmapped and this crashes the host in hardirq context. Returning GUEST_TYPE_NONE from is_in_guest() when !regs->gprs[15] (or checking the returned block pointer for NULL) would prevent this and also close the same pre-existing hazard on the GUEST_TYPE_SIE path. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204-host-irq-v= 1-0-a8387ee8a380@linux.ibm.com?part=3D10