From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E7C8C433EF for ; Fri, 22 Apr 2022 13:05:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239002AbiDVNIY (ORCPT ); Fri, 22 Apr 2022 09:08:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1447644AbiDVNIW (ORCPT ); Fri, 22 Apr 2022 09:08:22 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90ED815723 for ; Fri, 22 Apr 2022 06:05:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 2F47462059 for ; Fri, 22 Apr 2022 13:05:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C83AEC385A4; Fri, 22 Apr 2022 13:05:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1650632727; bh=eUal7i5cPw1ZeMVcYOseKjROzRLE63K2tn8pZ1n5gn0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=DtqGjmsYXRyo86eD50LhMnDqGVSv2zX24xbNbZaNpYI9pzgUqr8IzItd+CGu/PaN8 DICkPPLSj9RET7/qSColQsgbRFIzW3/f2wOz4UaeRSbZgH4S+R6aqLJ6tpAyWstkON CKJ1kupQMv0EKPo3XtSqxV75Fxprj9fGgNs9ptuNGDWqb3lz/tDcYfv6JP49z3icJN 80aFFk+z0ap08i2PSrzby/XIiU1ZiB/RBqpJRHPcedAGXRO2dN/Om5lAToF39Zza+q 5uQKI2QdvZVQqsGm80H6c59pE4JJgH5LW1FiiW5KcTWKlTXllYcq3TNzN5/0dhlbLt VF2S0J6Y892JQ== Date: Fri, 22 Apr 2022 22:05:23 +0900 From: Masami Hiramatsu To: Adam Zabrocki , Steven Rostedt Cc: "Naveen N. Rao" , Anil S Keshavamurthy , "David S. Miller" , linux-kernel@vger.kernel.org, Solar Designer Subject: Re: [PATCH] x86/kprobes: Fix KRETPROBES when CONFIG_KRETPROBE_ON_RETHOOK is set Message-Id: <20220422220523.bbad0538ef69b81cc7befe2a@kernel.org> In-Reply-To: <20220415181006.GA14021@pi3.com.pl> References: <20220415180723.GA13921@pi3.com.pl> <20220415181006.GA14021@pi3.com.pl> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steve, Can you pick this fix to urgent branch? Or Should I ask bpf people? On Fri, 15 Apr 2022 20:10:06 +0200 Adam Zabrocki wrote: > [PATCH] x86/kprobes: Fix KRETPROBES when CONFIG_KRETPROBE_ON_RETHOOK is set > > The recent kernel change "kprobes: Use rethook for kretprobe if possible", > introduced a potential NULL pointer dereference bug in the KRETPROBE > mechanism. The official Kprobes documentation defines that "Any or all > handlers can be NULL". Unfortunately, there is a missing return handler > verification to fulfill these requirements and can result in a NULL pointer > dereference bug. > > This patch adds such verification in kretprobe_rethook_handler() function. > Acked-by: Masami Hiramatsu Thank you, > Fixes: 73f9b911faa7 ("kprobes: Use rethook for kretprobe if possible") > Signed-off-by: Adam Zabrocki > --- > kernel/kprobes.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index dbe57df2e199..dd58c0be9ce2 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -2126,7 +2126,7 @@ static void kretprobe_rethook_handler(struct rethook_node *rh, void *data, > struct kprobe_ctlblk *kcb; > > /* The data must NOT be null. This means rethook data structure is broken. */ > - if (WARN_ON_ONCE(!data)) > + if (WARN_ON_ONCE(!data) || !rp->handler) > return; > > __this_cpu_write(current_kprobe, &rp->kp); > > -- > pi3 (pi3ki31ny) - pi3 (at) itsec pl > http://pi3.com.pl > -- Masami Hiramatsu