Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5105665imu; Tue, 15 Jan 2019 11:17:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN4bHkOHM5HUNHV77W+e9klyX5D7B4mvhWRqadOeA0B1uwjYVApK3Mc/6y8a+OgO0ESc/ANc X-Received: by 2002:a63:3507:: with SMTP id c7mr5133157pga.315.1547579836296; Tue, 15 Jan 2019 11:17:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547579836; cv=none; d=google.com; s=arc-20160816; b=jxMvlEgF/z5j1l7rLyXzScUqWbRfjAFOYZ9lJ9AocbnVqFdcjl2pD5KTBDEgLrOA6x klj5JRlu9UinavxhJlrCFuHM6rK5QMkpuz6B/029XV9JKRHRD04q1wXysEvB/cRLQgnB +OAkVXHRqcJLge5c+uKUtM3jjj84c8VYE3kJxfo83Q2p2VyyuUEadfzaiiRlhkpi5tSl 6kIljijk4i78K0jGcDAhZ7yB3k1wpHREI0Hhjn1V2oIL7TMqiD0qa/2k3qActSIM3kSb wAmaMLKUhkPluTrSCWj0MFJrRJz2DHO/2a8cO069kkosf+Q7JJrX33PPmbxeUZA7ng3r 9CYw== 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; bh=6tJ5qaKVDKtHresBkmuZOQ9jeAS4A0mwHZR34zsucyg=; b=BeTNM1TBEIx5lmetVl+IUQKxkVFgdTXO3h0Xlkf2jQPaz4zsdSsoPAaAVssBdPQii/ htSB3JhbI3ZlfbVGldeHN0F5mDCc/FHPpS/kLfTdKiL/CdKVDevhvY6LwVavex5QAyZl hr1Q1iQl3IMoZgD+65Q3nQ683EX4xqMPKu/N1/s9awfDHAkYITsngKLY5lCgJ9FRuM5o KBdwezCZrLpgwKG71I7Z7kq+AQO265HxqZ8pQBFDzweMZ/ldfBvuR++IvLCRmDQ1jqcO Z2GXAw112TK7oz9fxLhEOLxnQsQu2nKsVE9zVrkF2vOYxiYed9uEBbg0j8GV6SSJswmq 0H4Q== 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 d4si4077369pla.58.2019.01.15.11.16.59; Tue, 15 Jan 2019 11:17:16 -0800 (PST) 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 S1729820AbfAOQda (ORCPT + 99 others); Tue, 15 Jan 2019 11:33:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:50438 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729647AbfAOQd3 (ORCPT ); Tue, 15 Jan 2019 11:33:29 -0500 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (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 538CE20657; Tue, 15 Jan 2019 16:33:28 +0000 (UTC) Date: Tue, 15 Jan 2019 11:33:26 -0500 From: Steven Rostedt To: Andrea Righi Cc: Masami Hiramatsu , Ingo Molnar , linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH v2] tracing/kprobes: fix NULL pointer dereference in trace_kprobe_create() Message-ID: <20190115113326.6a683f94@gandalf.local.home> In-Reply-To: <20190111060113.GA22841@xps-13> References: <20190111060113.GA22841@xps-13> X-Mailer: Claws Mail 3.16.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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 11 Jan 2019 07:01:13 +0100 Andrea Righi wrote: > It is possible to trigger a NULL pointer dereference by writing an > incorrectly formatted string to krpobe_events (trying to create a > kretprobe omitting the symbol). > > Example: > > echo "r:event_1 " >> /sys/kernel/debug/tracing/kprobe_events > > That triggers this: > > BUG: unable to handle kernel NULL pointer dereference at 0000000000000000 > #PF error: [normal kernel read fault] > PGD 0 P4D 0 > Oops: 0000 [#1] SMP PTI > CPU: 6 PID: 1757 Comm: bash Not tainted 5.0.0-rc1+ #125 > Hardware name: Dell Inc. XPS 13 9370/0F6P3V, BIOS 1.5.1 08/09/2018 > RIP: 0010:kstrtoull+0x2/0x20 > Code: 28 00 00 00 75 17 48 83 c4 18 5b 41 5c 5d c3 b8 ea ff ff ff eb e1 b8 de ff ff ff eb da e8 d6 36 bb ff 66 0f 1f 44 00 00 31 c0 <80> 3f 2b 55 48 89 e5 0f 94 c0 48 01 c7 e8 5c ff ff ff 5d c3 66 2e > RSP: 0018:ffffb5d482e57cb8 EFLAGS: 00010246 > RAX: 0000000000000000 RBX: 0000000000000001 RCX: ffffffff82b12720 > RDX: ffffb5d482e57cf8 RSI: 0000000000000000 RDI: 0000000000000000 > RBP: ffffb5d482e57d70 R08: ffffa0c05e5a7080 R09: ffffa0c05e003980 > R10: 0000000000000000 R11: 0000000040000000 R12: ffffa0c04fe87b08 > R13: 0000000000000001 R14: 000000000000000b R15: ffffa0c058d749e1 > FS: 00007f137c7f7740(0000) GS:ffffa0c05e580000(0000) knlGS:0000000000000000 > CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 > CR2: 0000000000000000 CR3: 0000000497d46004 CR4: 00000000003606e0 > Call Trace: > ? trace_kprobe_create+0xb6/0x840 > ? _cond_resched+0x19/0x40 > ? _cond_resched+0x19/0x40 > ? __kmalloc+0x62/0x210 > ? argv_split+0x8f/0x140 > ? trace_kprobe_create+0x840/0x840 > ? trace_kprobe_create+0x840/0x840 > create_or_delete_trace_kprobe+0x11/0x30 > trace_run_command+0x50/0x90 > trace_parse_run_command+0xc1/0x160 > probes_write+0x10/0x20 > __vfs_write+0x3a/0x1b0 > ? apparmor_file_permission+0x1a/0x20 > ? security_file_permission+0x31/0xf0 > ? _cond_resched+0x19/0x40 > vfs_write+0xb1/0x1a0 > ksys_write+0x55/0xc0 > __x64_sys_write+0x1a/0x20 > do_syscall_64+0x5a/0x120 > entry_SYSCALL_64_after_hwframe+0x44/0xa9 > > Fix by doing the proper argument checks in trace_kprobe_create(). > > Link: https://lore.kernel.org/lkml/20190111095108.b79a2ee026185cbd62365977@kernel.org > Fixes: 6212dd29683e ("tracing/kprobes: Use dyn_event framework for kprobe events") > Cc: stable@vger.kernel.org Dropping the stable tag because it appears that the Fixes commit went into 5.0-rc1, which there's no stable kernel for. -- Steve > Signed-off-by: Andrea Righi > Signed-off-by: Masami Hiramatsu > ---