Received: by 10.192.165.148 with SMTP id m20csp1725652imm; Thu, 26 Apr 2018 01:03:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx49MPGqua6DpSLv9sHLew8cau9pq8sQ7IIGKYyeO/OWVmM+bBR16W+UR/uO4lJmItYzYPc0a X-Received: by 10.98.17.220 with SMTP id 89mr19266378pfr.18.1524729790375; Thu, 26 Apr 2018 01:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524729790; cv=none; d=google.com; s=arc-20160816; b=WFrK6/EBn5zg1RrxW3RUa8m8XzpOFTKx7A54WANN3Fnsu1QoyTKlkCU/MhHO2qLW7x bsAA09mIfCD84UjGP196tjVxAxn/rE7nVRPlDDen75G8x308DAdt4UvdrStj3tQ8kWHg JrXNLaJkR+jTb+L8fc7z1FGlIHHPTK7emftdjnqcptLCS8tTPrSh6ehncDa57Jg4sSFb KbkxMgRhXQueZNaZrFTjg4LL2iO8QEMHKiNIW0q8RQ9uYNco1vy1gIf80DrE4vpLVxSi xqXu1IZkYplWl3lp6aSt0OFWhnXKSsh7Qj4ABEshhp5s3Rh8+efQcyluMYSttrkrs3Ly f9mg== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :dmarc-filter:arc-authentication-results; bh=mUqd8Wbq4hshrxvFX/5+q9mq9PSqOzdtnnYdepw6E58=; b=xBN4DSmwV631NjrKmPLQs8C626Ao/2OOKkOcqYJ+ND6mYZ1PCzYMhtKJEf+iuE+3/M dMMRDFC0jxoLs7pjCw2O/xGNuYmUqBdbmaoSHAFTDJm1MOwyTv/4hWPWa2b9PAtZD6oN RBLtj4wctlVrOxQC0J7WKFWWH2qG7x+AY1VyO5w77k3RpPMNwKmi8gnfL78KCKydYkbC MlYaZPbetmzDyZxjxKWyN7CNAGYDKbRI++UU5jkZ4inGMaQq97kQ+F5YKZlCBS8/DNbK NS5RPB2jxvZNKf+rXk9cyLNYY1voBwccHx6CGLF0IIwZlBcKt1i4DznDaTQsVazsg8qy K/AQ== ARC-Authentication-Results: i=1; mx.google.com; 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 f68si18260539pfb.30.2018.04.26.01.02.55; Thu, 26 Apr 2018 01:03:10 -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; 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 S1753884AbeDZIBu (ORCPT + 99 others); Thu, 26 Apr 2018 04:01:50 -0400 Received: from mail.kernel.org ([198.145.29.99]:33894 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751528AbeDZIBs (ORCPT ); Thu, 26 Apr 2018 04:01:48 -0400 Received: from devbox (NE2965lan1.rev.em-net.ne.jp [210.141.244.193]) (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 A254E21745; Thu, 26 Apr 2018 08:01:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A254E21745 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=mhiramat@kernel.org Date: Thu, 26 Apr 2018 17:01:44 +0900 From: Masami Hiramatsu To: Thomas Richter Cc: ananth@linux.vnet.ibm.com, anil.s.keshavamurthy@intel.com, davem@davemloft.net, akpm@linux-foundation.org, acme@kernel.org, rostedt@goodmis.org, brueckner@linux.vnet.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] kprobes: Fix random address output of blacklist file Message-Id: <20180426170144.56ff7de34c56902066a044cf@kernel.org> In-Reply-To: <20180426071959.82407-1-tmricht@linux.ibm.com> References: <20180426071959.82407-1-tmricht@linux.ibm.com> X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Apr 2018 09:19:59 +0200 Thomas Richter wrote: > File /sys/kernel/debug/kprobes/blacklist displays random addresses: > > [root@s8360046 linux]# cat /sys/kernel/debug/kprobes/blacklist > 0x0000000047149a90-0x00000000bfcb099a print_type_x8 > .... > > This breaks 'perf probe' which uses the blacklist file to prohibit > probes on certain functions by checking the address range. > > Fix this by printing the correct (unhashed) address. Yeah, but I'm not sure recent "%px" policy. I think if the user can dump kallsyms, this also can be dumped. But kallsyms seems different policy... Anyway, please check my series. https://patchwork.kernel.org/patch/10183629/ It uses to check the kallsyms policy function to check. Unfortunately, this is not merged. Anyway, I'll repost it (on the top of tip tree) > > The file mode is read all but this is not an issue as the file > hierarchy points out: > # ls -ld /sys/ /sys/kernel/ /sys/kernel/debug/ /sys/kernel/debug/kprobes/ > /sys/kernel/debug/kprobes/blacklist > dr-xr-xr-x 12 root root 0 Apr 19 07:56 /sys/ > drwxr-xr-x 8 root root 0 Apr 19 07:56 /sys/kernel/ > drwx------ 16 root root 0 Apr 19 06:56 /sys/kernel/debug/ > drwxr-xr-x 2 root root 0 Apr 19 06:56 /sys/kernel/debug/kprobes/ > -r--r--r-- 1 root root 0 Apr 19 06:56 /sys/kernel/debug/kprobes/blacklist > > Everything in and below /sys/kernel/debug is rwx to root only, > no group or others have access. > > Background: > Directory /sys/kernel/debug/kprobes is created by debugfs_create_dir() > which sets the mode bits to rwxr-xr-x. Maybe change that to use the > parent's directory mode bits instead? Good catch! Yes, it should be hardened. Anyway, that is out of this topic. I just change blacklist file mode bits in my series. Thank you, > > Fixes: ad67b74d2469 ("printk: hash addresses printed with %p") > Cc: # v4.15+ > Cc: > To: Ananth N Mavinakayanahalli > To: Anil S Keshavamurthy > To: David S Miller > To: Masami Hiramatsu > To: Andrew Morton > To: acme@kernel.org > To: Steven Rostedt > > Signed-off-by: Thomas Richter > --- > kernel/kprobes.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/kernel/kprobes.c b/kernel/kprobes.c > index 102160ff5c66..ea619021d901 100644 > --- a/kernel/kprobes.c > +++ b/kernel/kprobes.c > @@ -2428,7 +2428,7 @@ static int kprobe_blacklist_seq_show(struct seq_file *m, void *v) > struct kprobe_blacklist_entry *ent = > list_entry(v, struct kprobe_blacklist_entry, list); > > - seq_printf(m, "0x%p-0x%p\t%ps\n", (void *)ent->start_addr, > + seq_printf(m, "0x%px-0x%px\t%ps\n", (void *)ent->start_addr, > (void *)ent->end_addr, (void *)ent->start_addr); > return 0; > } > -- > 2.14.3 > -- Masami Hiramatsu