Received: by 2002:a25:b323:0:0:0:0:0 with SMTP id l35csp1176757ybj; Fri, 20 Sep 2019 06:24:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwO+dUTc33PzNBZgAm+blhWLwC6YrZ8hu/jDZlBPpEBCR/jgzBozLad5zJY2zOndVBbsCJH X-Received: by 2002:a17:906:7798:: with SMTP id s24mr19468410ejm.211.1568985841673; Fri, 20 Sep 2019 06:24:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568985841; cv=none; d=google.com; s=arc-20160816; b=V0TfCKn38cBLYJCAOnOcq5tG0p02+wRAiDfMlAJQcYW+VzEEUs6zAqdK3FviaAhh5T IbX6Q/WZWt/I56hh3sofXqfkzgkgG+2DP5Ktk8+hDa5n1kEo6L7x/9fl8JNk2HQj7lUA jf7gku7EdCt3SXY9r1etvJVD41lMQpjHNO8THVNACTW69ePjsabLKA1QEr4qpMCoyy++ Akoke24kyxIxvKDSNlKf6ciskxBcYax1qDHe/gvBq+3eCD98+acXdQ8FDQ/Mvn+7PSEC X4TcYq2HXJDHkJRCH3bbzDltIdkSSFf4W7FWcvQ7HNfhw8nPmsS/J3A/mDbm528Ge1cw 6A2A== 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=ut+84WiQf/sZxMGGC2cTMIReN8zT3GHGmq/qu/XE7uA=; b=suoo90qI9slo+mFvO6Qt0Injcq2HLWb4+XkxxvgID24bIAMc3IIMQxcEdBJFFK3kP9 j0ZQUVrBUwgTT3j7IbWVhrISZFwANtW9rXH3r56gLyelb5+AZV1UChpCdCEzCNJelXV3 bNh3khyWCBzJ3sWMPbluR0cI2aek4JyClvhr50B4u7AwwKasQd/0IrUzoD+M6lpH0r10 e/ViiYZtQg6pyluspB5bK1CvF3UT7Y9J4wtqCvL5oGaFUYpe6DLxbd1285DeAn2PEdR0 VIYlcqwfK0Fpb1Zdq22b0CPJ4yEdZdFQG6cNKgmplF4AzEB1LekKK70eGKnCgMrNxoTa u2aQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wIWaTN6W; 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 b12si1047332eja.185.2019.09.20.06.23.38; Fri, 20 Sep 2019 06:24:01 -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=wIWaTN6W; 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 S2406491AbfISWRg (ORCPT + 99 others); Thu, 19 Sep 2019 18:17:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:58736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406465AbfISWRe (ORCPT ); Thu, 19 Sep 2019 18:17:34 -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 298B621920; Thu, 19 Sep 2019 22:17:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568931452; bh=74nf5UnRKvBiWWXFw3xnxICQuYxH0BWLfryXXrsDYPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wIWaTN6WubEgiSqpZCT2ADr2mk78+YpLI3hFTx0ZmcWCbN0SoGRnCZJsD86hQe2rf HwYnfSaAQr7M6UlJoHfTMpeSSl/G2yCKd3yFXzSkuagbkdjSf7NfZQKaoAYf6L5is5 i2yBJnk+GKz/Jh48CVut/kwp5T3MjZhp3vp2JQE4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Masami Hiramatsu , Arnaldo Carvalho de Melo , Peter Zijlstra , Will Deacon , Catalin Marinas , Marc Zyngier , Sasha Levin Subject: [PATCH 4.14 34/59] kallsyms: Dont let kallsyms_lookup_size_offset() fail on retrieving the first symbol Date: Fri, 20 Sep 2019 00:03:49 +0200 Message-Id: <20190919214806.003059718@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190919214755.852282682@linuxfoundation.org> References: <20190919214755.852282682@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: Marc Zyngier [ Upstream commit 2a1a3fa0f29270583f0e6e3100d609e09697add1 ] An arm64 kernel configured with CONFIG_KPROBES=y CONFIG_KALLSYMS=y # CONFIG_KALLSYMS_ALL is not set CONFIG_KALLSYMS_BASE_RELATIVE=y reports the following kprobe failure: [ 0.032677] kprobes: failed to populate blacklist: -22 [ 0.033376] Please take care of using kprobes. It appears that kprobe fails to retrieve the symbol at address 0xffff000010081000, despite this symbol being in System.map: ffff000010081000 T __exception_text_start This symbol is part of the first group of aliases in the kallsyms_offsets array (symbol names generated using ugly hacks in scripts/kallsyms.c): kallsyms_offsets: .long 0x1000 // do_undefinstr .long 0x1000 // efi_header_end .long 0x1000 // _stext .long 0x1000 // __exception_text_start .long 0x12b0 // do_cp15instr Looking at the implementation of get_symbol_pos(), it returns the lowest index for aliasing symbols. In this case, it return 0. But kallsyms_lookup_size_offset() considers 0 as a failure, which is obviously wrong (there is definitely a valid symbol living there). In turn, the kprobe blacklisting stops abruptly, hence the original error. A CONFIG_KALLSYMS_ALL kernel wouldn't fail as there is always some random symbols at the beginning of this array, which are never looked up via kallsyms_lookup_size_offset. Fix it by considering that get_symbol_pos() is always successful (which is consistent with the other uses of this function). Fixes: ffc5089196446 ("[PATCH] Create kallsyms_lookup_size_offset()") Reviewed-by: Masami Hiramatsu Cc: Arnaldo Carvalho de Melo Cc: Peter Zijlstra Cc: Will Deacon Cc: Catalin Marinas Signed-off-by: Marc Zyngier Signed-off-by: Will Deacon Signed-off-by: Sasha Levin --- kernel/kallsyms.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 127e7cfafa552..3e1b66366ac23 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c @@ -296,8 +296,10 @@ int kallsyms_lookup_size_offset(unsigned long addr, unsigned long *symbolsize, { char namebuf[KSYM_NAME_LEN]; - if (is_ksym_addr(addr)) - return !!get_symbol_pos(addr, symbolsize, offset); + if (is_ksym_addr(addr)) { + get_symbol_pos(addr, symbolsize, offset); + return 1; + } return !!module_address_lookup(addr, symbolsize, offset, NULL, namebuf) || !!__bpf_address_lookup(addr, symbolsize, offset, namebuf); } -- 2.20.1