Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp654698imp; Wed, 20 Feb 2019 06:50:12 -0800 (PST) X-Google-Smtp-Source: AHgI3IYLOC2zyC9koHZZNr8ikYhzeLdeh6hOFXumTVuPo/cxUZShllAn3VyKVxDaxxpbrwS37hbQ X-Received: by 2002:aa7:87c6:: with SMTP id i6mr34890076pfo.208.1550674212036; Wed, 20 Feb 2019 06:50:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550674212; cv=none; d=google.com; s=arc-20160816; b=tQqYJrAnxOvmjX7NV2AZChHQeqykJ1beQL7/YsoxkWU2V4pQPVCPGVQt+KCKo8ivEi q90tx1CcERvpB1UjC+f0RF27UAwN/3Su3Ylt42Hbb+/+53hSmCivxMzflpBIPKvArk+7 norLWDXHVtuXctYckNw9YdAqGYDiVOl1eeTsQQUs3UtLL/gufe0tPtVpb1CFzcWPitRa tA1vExnosqUUN8KtF60aTLiWHygAmJxXMHrwubMZ3Wwg30UK3PE7AG2AUx5Kxcn7tFiw DmhtOa9TAE3wHCJMyWtcOuYiR9YiEJwuXecQRTkpOzkx5VUlF0eHX7NOn9qukKnlfKhm COKg== 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=N8PneWwqKDqwr/u8FF11r5G6LLC8Pxic8fn7hP7oI9c=; b=qmbJ93/4ejGEkejAaMbmb5TyZIGXevzc3nH22HNS/AeOPyuP/1NGQFOYZ4CPkU55iJ 3XfP+RO7rxpVrWiD5UP3Ku2/UESv6jvy1vjkDema1oAWpcwmeJk+q25MZSXQaWhzeICE A+cvI0SuIXVerAHq22E+u1D52XFyKqrXQun9GiEdsCerajRcHyaxRV5LRQrCnmhwU0F1 kuM0jchiVSazw5luO/0B7A4wN+i9MoOTvvvZrp9VhJ9VPRY6Ec6CSjOUktXkZQBsiPx8 hiq59F281xYafjpfSBYnHbZf+G2Xbf2IvyjrOXEibrv9i1YhtMYaYwVUnqcYPYDUOxv7 gLBg== 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 b15si15891717plm.431.2019.02.20.06.49.56; Wed, 20 Feb 2019 06:50:12 -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 S1726900AbfBTOt3 (ORCPT + 99 others); Wed, 20 Feb 2019 09:49:29 -0500 Received: from mail.kernel.org ([198.145.29.99]:45712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726227AbfBTOt3 (ORCPT ); Wed, 20 Feb 2019 09:49: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 9A61C2146E; Wed, 20 Feb 2019 14:49:27 +0000 (UTC) Date: Wed, 20 Feb 2019 09:49:26 -0500 From: Steven Rostedt To: Masami Hiramatsu Cc: Linus Torvalds , Andy Lutomirski , Linux List Kernel Mailing , Ingo Molnar , Andrew Morton , stable , Changbin Du , Jann Horn , Kees Cook , Andy Lutomirski Subject: Re: [PATCH 1/2 v2] kprobe: Do not use uaccess functions to access kernel memory that can fault Message-ID: <20190220094926.0ab575b3@gandalf.local.home> In-Reply-To: <20190220171019.5e81a4946b56982f324f7c45@kernel.org> References: <20190215174712.372898450@goodmis.org> <20190215174945.557218316@goodmis.org> <20190215171539.4682f0b4@gandalf.local.home> <300C4516-A093-43AE-8707-1C42486807A4@amacapital.net> <20190215191949.04604191@gandalf.local.home> <20190219111802.1d6dbaa3@gandalf.local.home> <20190219140330.5dd9e876@gandalf.local.home> <20190220171019.5e81a4946b56982f324f7c45@kernel.org> 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 Wed, 20 Feb 2019 17:10:19 +0900 Masami Hiramatsu wrote: > Let me ensure what you want. So you want to access a "string" in user-space, > not a data structure? In that case, it is very easy to me. It is enough to > add a "ustring" type to kprobe events. For example, do_sys_opsn's path > variable is one example. That will be +0(+0(%si)):ustring, and fetcher > finally copy the string using strncpy_from_user() instead of > strncpy_from_unsafe(). (*) ustring would be good. > > But if you consider to access a field in a data-structure in user space, > it might need some more work (E.g. ioctl's parameter), becase if the __user > pointer to the data structure is on the memory, we have to dereference > the address inside kernel using probe_kernel_read(), but after getting > the data strucutre address, we have to dereference the address with copy_from_user(). > At this moment, we have no such strong syntax... > > To solve that, maybe we need to introduce something like "back reference" > of arguments in the event, e.g. > > p somewhere user_data=+0(%si) field_val=+8(\user_data):u32:user > > or > > p somewhere +0(%si) field_val=+8(\1):u32:user > > This ":user" additional suffix tells kprobe events to change fetching method > to fetch the data by copy_from_user(). What about just adding 'u' to the end of the offset? Say you have a data structure in kernel space that has a field in user space you want to reference? field_val=+8u(+0(%si)) Although, I would say having ways to access current parameters may also be a nice touch ;-) -- Steve