From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5AE29C433EF for ; Mon, 13 Dec 2021 21:17:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4D7A6B0071; Mon, 13 Dec 2021 16:17:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BFCD46B0073; Mon, 13 Dec 2021 16:17:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9DE46B0074; Mon, 13 Dec 2021 16:17:04 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay028.a.hostedemail.com [64.99.140.28]) by kanga.kvack.org (Postfix) with ESMTP id 997B06B0071 for ; Mon, 13 Dec 2021 16:17:04 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 658871202B0 for ; Mon, 13 Dec 2021 21:16:54 +0000 (UTC) X-FDA: 78914030748.05.866482A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf10.hostedemail.com (Postfix) with ESMTP id 9D80DC0010 for ; Mon, 13 Dec 2021 21:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=+oXlu81/pzMeMxFRDIwBJ0v+cxjFnt//6x6F6HOoz78=; b=KHOC4D3vl9Dn44+uRqxpWFJJkQ LH7RpKmZrJr8HD7j4c8mLIkbNUyFCs3LNQMhJwah/MQ80h7VEm+MeRnbukoYhAfsHjQ2T+B6yx94w qDR71S9o9juKgz52uQGFTDYMafRBRL78E95RrMhZardAysJaOgaWdw1SYn19ybkE4M8a17uUIL7+D cXaKfbyvb1N9JbYGe526FoLo87tsekaQPV4uhO+Sf6ruw0qciuhdhT7MuJGXpWKQSGgHCosg7i5PY J/JtI7pyITVAFEKXnvCQQrO0TpCzGw9wUs+rtdQB06WMbCOjUg4TWN6eJaxECZhSbuTCgVNb05qVU QKbb8UpA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mwsgg-00DA7y-QU; Mon, 13 Dec 2021 21:16:46 +0000 Date: Mon, 13 Dec 2021 21:16:46 +0000 From: Matthew Wilcox To: Kees Cook Cc: William Kucharski , "linux-mm@kvack.org" , Thomas Gleixner , "linux-hardening@vger.kernel.org" Subject: Re: [PATCH v3 0/3] Assorted improvements to usercopy Message-ID: References: <20211213142703.3066590-1-willy@infradead.org> <196BFB9E-9A72-48B1-863E-021DE0B162A7@oracle.com> <202112131246.4BBFBA69A@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202112131246.4BBFBA69A@keescook> X-Stat-Signature: 3tt6jsk13fzu8g3hpq4ujw96feypmhf4 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=KHOC4D3v; spf=none (imf10.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 9D80DC0010 X-HE-Tag: 1639430210-926899 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Dec 13, 2021 at 12:47:58PM -0800, Kees Cook wrote: > On Mon, Dec 13, 2021 at 08:27:42PM +0000, Matthew Wilcox wrote: > > On Mon, Dec 13, 2021 at 07:18:57PM +0000, William Kucharski wrote: > > > I like these, but a quick question: > > > > > > Since the usercopy_abort() calls are all because the offset exceeds the page > > > size, is there a reason why you don't specifically state that via the detail > > > parameter rather than just supply a NULL pointer? > > > > Hmm ... I'd defer to Kees on this, because I'm not familiar with > > usercopy_abort() usage, but the only places which use the detail > > parameter today are slab/slub, which use it to pass the name of > > the slab. I think the user is supposed to infer that we overran the > > end of the page based on the offset & length values. > > I agree that leaving it NULL is best here. The "detail" is really about > adding more information about which thing it was, which for slab makes > sense, but most other stuff there isn't really anything to quickly > distinguish one from another (i.e. vmap is all vmap). There _is_ a bit more information in the vmap case (not in the kmap or compound page case). You can see it in /proc/vmallocinfo. We could pass it in like this? if (is_vmalloc_addr(ptr)) { struct vm_struct *vm = find_vm_area(ptr); + char sym[100]; unsigned long offset; if (!vm) { .. + if (vm->caller) + snprintf(sym, sizeof(sym), "%pS", vm->caller); offset = ptr - vm->addr; if (offset + n > vm->size) - usercopy_abort("vmalloc", NULL, to_user, offset, n); + usercopy_abort("vmalloc", vm->caller ? sym : NULL, + to_user, offset, n); return;