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 X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97B4BCA9EC9 for ; Fri, 1 Nov 2019 03:55:33 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 5D7A82083E for ; Fri, 1 Nov 2019 03:55:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QlDV4WMe"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="DGvNnz+G" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5D7A82083E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ULhpxiQ5s6W7/vZ6/C4cS+CrxtehzKBnHhKLl6Jqji8=; b=QlDV4WMex8N+1W KVhn//C5jImU9nkJgVSSsA4B/Fz3lPQi9UuE3ViNz47P2tTkVqJuW5iIp44tFy5pB1748+QwD+rv6 nswX7OU1enQhASFrqG85GMnEIQ6CaBnFOV4JgpawHTwdHu0y8K5+6gBa0Ut3zeTXNFbxJJjTk63fg dHHUjk6MxKSVXeNqN/cEm9drcAk2iODc3c61xKTTAS9LhPr4DIOY/FR15C2OctWITAw4DZ+tYAcTX +uCew5EQVvG/ki6cEVwCt6ULPy4aUSqOaHJKXkAn2CoG+5vpnPmftpLqeCRqT12ormmWEvwksXixb CNCoRbdrMSUo4/wOM1Ig==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iQO28-00010G-LP; Fri, 01 Nov 2019 03:55:32 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iQO23-0000yp-QC for linux-arm-kernel@lists.infradead.org; Fri, 01 Nov 2019 03:55:29 +0000 Received: by mail-pf1-x441.google.com with SMTP id p26so6078067pfq.8 for ; Thu, 31 Oct 2019 20:55:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=YiqPN73/qfLoGFPAaCK046WeDsIyHq2v7vxAoPf2Hxg=; b=DGvNnz+GeHeNfKZ6f7YLJzc3HABEEC30I8/B/IBZTbAoWTqYDEBA+PWjh7ne14xEji PE2FdEWksdLdMt2PKYPe0QSMEXkBcV49KFClWQ42/xFPVspDKk4kFzSNVn/0QiVKU0Hk Z4vIKb88INGDp/qLR22O2YTnuCwiKgJmJAvqs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=YiqPN73/qfLoGFPAaCK046WeDsIyHq2v7vxAoPf2Hxg=; b=O3J+0QqzVilNx8muMIbcFo49dHGP5qw0MMK4DMngvqCewGVE2XjTsoDlVgTwSWvbFB 3jOPIYOn/IRmBoaZDPC61M3jVVJN9r/DZ5i/Kut3LMBmKetOhcIHDFdwRs0rMWV1CzfR swlNG/ZBAe6T1uGWZkSdpgY96h6xCmLJ6KENGXk2b9Xi/j99XoV58aMk23uzdNCKPzhX 7AhTzo48EUfh4xHQde5yoUinLN/LC6rCFrCkFHN10JO/r1kEdC5kak6gFU29tlxnTEM8 G7nCcHQ8vqNxq0ZNcyRdLYYICyxMMhQ83gMw9fb17QNxGAAFbgCxoItAdO9ZO7kLDRD1 oFsQ== X-Gm-Message-State: APjAAAVJMfW86LAtas4SHUfGERPSl9kqM40okJsu9eIW6UoVWzTPbig9 1YvWwn8nvo27qcGP+zarIfkjcg== X-Google-Smtp-Source: APXvYqxD7MNY1jVYOjRfhYGo3ogwiiuExle/jPXGM0/pINsljnFcAcPtUzMI8R27pVSvoSzQhhOLJg== X-Received: by 2002:a17:90a:f310:: with SMTP id ca16mr5852511pjb.20.1572580527358; Thu, 31 Oct 2019 20:55:27 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id 2sm4704403pfo.91.2019.10.31.20.55.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 31 Oct 2019 20:55:26 -0700 (PDT) Date: Thu, 31 Oct 2019 20:55:25 -0700 From: Kees Cook To: samitolvanen@google.com Subject: Re: [PATCH v3 08/17] kprobes: fix compilation without CONFIG_KRETPROBES Message-ID: <201910312055.B551A6CB4@keescook> References: <20191018161033.261971-1-samitolvanen@google.com> <20191031164637.48901-1-samitolvanen@google.com> <20191031164637.48901-9-samitolvanen@google.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191031164637.48901-9-samitolvanen@google.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191031_205527_846095_E1389BF5 X-CRM114-Status: GOOD ( 17.55 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , clang-built-linux@googlegroups.com, Ard Biesheuvel , Masahiro Yamada , Catalin Marinas , Jann Horn , Nick Desaulniers , linux-kernel@vger.kernel.org, Steven Rostedt , Miguel Ojeda , Masami Hiramatsu , kernel-hardening@lists.openwall.com, Laura Abbott , Will Deacon , Dave Martin , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Oct 31, 2019 at 09:46:28AM -0700, samitolvanen@google.com wrote: > kprobe_on_func_entry and arch_kprobe_on_func_entry need to be available > even if CONFIG_KRETPROBES is not selected. > > Signed-off-by: Sami Tolvanen FWIW: Reviewed-by: Kees Cook -Kees > Acked-by: Masami Hiramatsu > --- > kernel/kprobes.c | 38 +++++++++++++++++++------------------- > 1 file changed, 19 insertions(+), 19 deletions(-) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 53534aa258a6..b5e20a4669b8 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -1829,6 +1829,25 @@ unsigned long __weak arch_deref_entry_point(void *entry) > return (unsigned long)entry; > } > > +bool __weak arch_kprobe_on_func_entry(unsigned long offset) > +{ > + return !offset; > +} > + > +bool kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset) > +{ > + kprobe_opcode_t *kp_addr = _kprobe_addr(addr, sym, offset); > + > + if (IS_ERR(kp_addr)) > + return false; > + > + if (!kallsyms_lookup_size_offset((unsigned long)kp_addr, NULL, &offset) || > + !arch_kprobe_on_func_entry(offset)) > + return false; > + > + return true; > +} > + > #ifdef CONFIG_KRETPROBES > /* > * This kprobe pre_handler is registered with every kretprobe. When probe > @@ -1885,25 +1904,6 @@ static int pre_handler_kretprobe(struct kprobe *p, struct pt_regs *regs) > } > NOKPROBE_SYMBOL(pre_handler_kretprobe); > > -bool __weak arch_kprobe_on_func_entry(unsigned long offset) > -{ > - return !offset; > -} > - > -bool kprobe_on_func_entry(kprobe_opcode_t *addr, const char *sym, unsigned long offset) > -{ > - kprobe_opcode_t *kp_addr = _kprobe_addr(addr, sym, offset); > - > - if (IS_ERR(kp_addr)) > - return false; > - > - if (!kallsyms_lookup_size_offset((unsigned long)kp_addr, NULL, &offset) || > - !arch_kprobe_on_func_entry(offset)) > - return false; > - > - return true; > -} > - > int register_kretprobe(struct kretprobe *rp) > { > int ret = 0; > -- > 2.24.0.rc0.303.g954a862665-goog > -- Kees Cook _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel