Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp377406imj; Sat, 16 Feb 2019 02:21:33 -0800 (PST) X-Google-Smtp-Source: AHgI3Ibzhq56czTHv8ZU+lH6MmnlhiYoTyrt1OpplzgtvOIQ0KRHRRUh9bia78yRrsRsiJmgf5fV X-Received: by 2002:a63:580f:: with SMTP id m15mr9533530pgb.342.1550312492998; Sat, 16 Feb 2019 02:21:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550312492; cv=none; d=google.com; s=arc-20160816; b=Xt8B8UXrbD7YeqVg6Y8yuOzNsybsN05SH1mwtEKGBxh3GC9K5Tk9zA9c9tHeuEFKwS Vl9BB+uS6fL9lShvroZTxIiOBqIdPrAuzubbI6e/MmJpIuvlNoGSAIBURrygeYt1/pRa +189kZUpRjxGm6rvrak5L3+J1z/Khf+KM4DhBm+YZtWFxG/uMcnnkZtdQ8GBnFhz3CSB cQOps7CXN5DVea3GgMEElPgaURhFt02D2+n+wroEQUP4Nvp1Aw8fBlFAesdhbjFWlbMz KwSX+bIW6sSUcJG6eSXJTkh/K2zctrrIqh7U32eKyejVidWmfVCr8Rhmm7TWdrdqeHTT /vNQ== 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=wEg+hn6oSi0lFDgLeTJbiXeqGb/VNPMmSyiaxSx7Hx4=; b=aRNqNqLzcN5BUoJCC0mGKQu7yge923QPWFWMAkrV9tUf3VfC5VEbsXP16CRiimBtDM QoudCvWpUt20BM9quQzOr4fE5xZFaC/HdrLi3DgjoAiu+fvHho+78L6NxnhCEvKAbBq3 Dkygq1ENRePIZvzj6F3XC0xHkvaPgOnrIter1d1ecckNFBLtrdZ7TcTm5Z2jJ45hRQDJ QgrsriNPSqGf7AK8qYpdZ7ppMisz2QW8BhIrPBEUbXBN1AbFLaff1hD0AwquWOGE7rJ1 7hRzJHRIHgqDWOd3J02dAqQFnBRAYCqNTaYCYj2wrkMQ3wEOXXgOcBMQeGUuQglOWbZL B/1Q== 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 z2si7897575pfl.179.2019.02.16.02.21.16; Sat, 16 Feb 2019 02:21:32 -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 S1732844AbfBPCIE convert rfc822-to-8bit (ORCPT + 99 others); Fri, 15 Feb 2019 21:08:04 -0500 Received: from mail.kernel.org ([198.145.29.99]:40750 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbfBPCIE (ORCPT ); Fri, 15 Feb 2019 21:08:04 -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 ACA19222A1; Sat, 16 Feb 2019 02:08:02 +0000 (UTC) Date: Fri, 15 Feb 2019 21:08:01 -0500 From: Steven Rostedt To: Andy Lutomirski Cc: Linus Torvalds , 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: <20190215210801.7f8c94cf@gandalf.local.home> In-Reply-To: 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> 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=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 On Fri, 15 Feb 2019 17:32:55 -0800 Andy Lutomirski wrote: > > I added you just because I wanted help getting the change log correct, > > as that's what Linus was complaining about. I kept using "kernel > > address" when the sample bug used for the patch was really a > > non-canonical address (as Linus said, it's just garbage. Neither kernel > > or user space). But I pointed out that this can also bug if the > > address is canonical and in the kernel address space. The old code > > didn't complain about non-canonical or kernel address faulting before > > commit 9da3f2b7405, which only talks about kernel address space > > faulting (which is why I only mentioned that in my messages). > > > > Would changing all the mention of "kernel address" to "non user space" > > be accurate? > > > > I think “kernel address” is right. It’s illegal to access anything that isn’t known to be a valid kernel address while in KERNEL_DS. But an non-canonical address is not a "kernel address", and that will cause a bug too. This patch came about because it was changed that if we do a uaccess on something other than a user space address and take a fault (either because it was a non-canonical address, or a kernel address), we BUG! Where before that one patch, it would just return a fault. > > The old __copy seems likely to have always been a bit bogus. > > BTW, what is this probe_mem_read() thing? Some minimal inspection suggests it’s a buggy reimplementation of probe_kernel_read(). Can you delete it and just use probe_kernel_read() directly? Well, the issue is that we have trace_probe_tmpl.h in that same directory, which does the work for kprobes and uprobes. The trace_kprobes.c defines all the functions for handling kprobes, and trace_uprobes.c does all the handling of uprobes, then they include trace_probe_tmpl.h which does the bulk of the work. In the uprobes case, we have: static nokprobe_inline int probe_mem_read(void *dest, void *src, size_t size) { void __user *vaddr = (void __force __user *)src; return copy_from_user(dest, vaddr, size) ? -EFAULT : 0; } Because that is adding probes on userspace code. -- Steve