Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1019349ybe; Wed, 4 Sep 2019 11:14:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqzqkSqG6ZQxS4gdFtlteIdBi6LYBObrZ68fLbwtxCN1CfOJgqesxZpNyxTY5JU9AfjAkn6S X-Received: by 2002:a65:4044:: with SMTP id h4mr1193832pgp.164.1567620843466; Wed, 04 Sep 2019 11:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567620843; cv=none; d=google.com; s=arc-20160816; b=OXqUflqlq+h3B3cKdlXQyedwbGG1yknM0L4kBNbHgLBS6bQz8HYsPRPCTSmL3HUYNo NAK7/oWxRRUxpvlE3OL2yxuBfhg4RLXxxZOPN6uqWCh7zN/zCjyCNv8Yc86SOJJQui63 H/jqC9ZihWBETVZFIsMdIZOlupC3sosWLUUk8TI50IFY9Dtugj+BQpb3BBtgCFLtM38L +4qndfl7/WBKt5hEbpcUxvsyDu00fW/TMwKlegaG3FafUeUyHdQqNJ86flx798jljlif 1BNsFkEYxbb/wtIaxO8IUP6dm9YWtTdeUZDlUUG1sn//B53R08w9coInRuoW6zO19hqA BKJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pGMC3k22YaMREYzDcZnhvLZlYtNtNDhj5cwnz2KKdak=; b=YnTLo1tgCnDM77moSanCC1Pwo0G6Pgaq2LYzYBGzKxJny6bwIhoag+jU+XQPMfpfok RSw5M5BiO9ZzqQn5l/0XgzR1Tm2nVjVceRwTjAPgzeBYtNlyXtO7wo7mC6l/ORwONRbM CUz2qH55mX82vVqbZuar9JuJRAvWNnacjTXkvxOBnjgkltdL5H/ibcp8r3KkiPV3EeEw OmW3OtyW+N/s9ugOKWWcRT1DMxU5eSoEP+GnEz928MrGzpH8nL11IsvD+NpTsujdpX4N jvOminN14SSFhNqItm3aA/NVxWAWBKuc8DmEmNeXMMk9PBYWxc9u26pz8NWcjjpOU3J2 dPXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rGPIEYxc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 33si8646037plf.111.2019.09.04.11.13.47; Wed, 04 Sep 2019 11:14:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rGPIEYxc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390464AbfIDSMS (ORCPT + 99 others); Wed, 4 Sep 2019 14:12:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:56612 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389518AbfIDSMR (ORCPT ); Wed, 4 Sep 2019 14:12:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 492052087E; Wed, 4 Sep 2019 18:12:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1567620736; bh=DY4pztnOnG55fll5TNj3UuR3nsDwFvM6cxZfKneEtnU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rGPIEYxcHh8z10yWDl+iPe6GPeRmd1wdPOWVYNfcyEdqlUsMliRh4+lhmM/e1fYu3 9jcc0BIfGftFIVF1DRbbnLqTdEGD5SB7LNlw61Zm9j4QNNlSF4j+5qBR06bDtqEQJF hKo3vusKgLbWxK+Qdb6NbWS6fp++Zb1hiA2ZCPMA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "Naveen N. Rao" , "Steven Rostedt (VMware)" Subject: [PATCH 5.2 076/143] ftrace: Check for successful allocation of hash Date: Wed, 4 Sep 2019 19:53:39 +0200 Message-Id: <20190904175317.028334513@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190904175314.206239922@linuxfoundation.org> References: <20190904175314.206239922@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Naveen N. Rao commit 5b0022dd32b7c2e15edf1827ba80aa1407edf9ff upstream. In register_ftrace_function_probe(), we are not checking the return value of alloc_and_copy_ftrace_hash(). The subsequent call to ftrace_match_records() may end up dereferencing the same. Add a check to ensure this doesn't happen. Link: http://lkml.kernel.org/r/26e92574f25ad23e7cafa3cf5f7a819de1832cbe.1562249521.git.naveen.n.rao@linux.vnet.ibm.com Cc: stable@vger.kernel.org Fixes: 1ec3a81a0cf42 ("ftrace: Have each function probe use its own ftrace_ops") Signed-off-by: Naveen N. Rao Signed-off-by: Steven Rostedt (VMware) Signed-off-by: Greg Kroah-Hartman --- kernel/trace/ftrace.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c @@ -4330,6 +4330,11 @@ register_ftrace_function_probe(char *glo old_hash = *orig_hash; hash = alloc_and_copy_ftrace_hash(FTRACE_HASH_DEFAULT_BITS, old_hash); + if (!hash) { + ret = -ENOMEM; + goto out; + } + ret = ftrace_match_records(hash, glob, strlen(glob)); /* Nothing found? */