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 70CD8C433EF for ; Mon, 13 Dec 2021 23:47:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 981BC6B0071; Mon, 13 Dec 2021 18:47:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 930426B0072; Mon, 13 Dec 2021 18:47:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F8416B0074; Mon, 13 Dec 2021 18:47:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0101.hostedemail.com [216.40.44.101]) by kanga.kvack.org (Postfix) with ESMTP id 72F976B0071 for ; Mon, 13 Dec 2021 18:47:46 -0500 (EST) Received: from smtpin08.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3BCB4886D6 for ; Mon, 13 Dec 2021 23:47:36 +0000 (UTC) X-FDA: 78914410512.08.B70B664 Received: from mail-pj1-f45.google.com (mail-pj1-f45.google.com [209.85.216.45]) by imf18.hostedemail.com (Postfix) with ESMTP id 11B171C0005 for ; Mon, 13 Dec 2021 23:47:32 +0000 (UTC) Received: by mail-pj1-f45.google.com with SMTP id k6-20020a17090a7f0600b001ad9d73b20bso14642636pjl.3 for ; Mon, 13 Dec 2021 15:47:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4NeqGUpgiKq/CSr5Hrjt+fDUe8zcECnhuKEw/ldsDPE=; b=VPOaPOHF8pzjwCuZV9F8FCY96Xb+4T2npLrgyUAeo+BHoeXWJJQO8A+x59hPRT1GVO AHHTFBDm0TfSXFVH607lkqWs+QCU7GibwKI5CIoMw2JaII0/EOPR8SWFX1x9blwwRz28 s1KxS6KbZXlrAUJ9ezMe+NUAXgDt7WM/FC4wY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4NeqGUpgiKq/CSr5Hrjt+fDUe8zcECnhuKEw/ldsDPE=; b=7i+YG4yD76rNz5pyABmOQHZopYa/ALi8O2PBjTasi9NGikgiWTr2oQu8gtmTzQqAJA CegxZVLjfIRS840NnsvKgsEtFAwV+9Q6kHa/rwZcpuIjTMvHVHmEI1Forl1wt0NR7iNN YABcvhjEaFXIyru8T68QdVoKG59gqjshlQt7kzknKHM63C5qmBkWKWCMlSvIPpB6byAy 39L8mN+RfHAfIuE4qqfSAGkVyYBQo1EPXy2QrKjXF/gC/jnNOwC+LSWd8y+4BCfTfp/P 2SBcYQv4f455AOeClmZ22B8DLwj6KonjfxXR5NNteU/q1m3lzNkDJmF2exM6tr/EVWVK BhIw== X-Gm-Message-State: AOAM5315TEqNZ7Q9eLQYVtzL2KFYD4WKu2ExBYL9muJPSKyXuggElmV0 SySZLOwzEJCTMCNXoVCaVkt0+Q== X-Google-Smtp-Source: ABdhPJw4LBum7QxKEAfLtz15sLW0IDQvjLum2jXNjRXPttp3DiE1QYsg4QQYDo1ft0yFMFh7Laihew== X-Received: by 2002:a17:902:748c:b0:141:c45e:c612 with SMTP id h12-20020a170902748c00b00141c45ec612mr1388757pll.73.1639439254777; Mon, 13 Dec 2021 15:47:34 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id f8sm13724338pfv.135.2021.12.13.15.47.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Dec 2021 15:47:34 -0800 (PST) Date: Mon, 13 Dec 2021 15:47:33 -0800 From: Kees Cook To: Matthew Wilcox 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: <202112131544.86E9D533@keescook> 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: X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 11B171C0005 X-Stat-Signature: six5zqjjz7ucncrohwfz7jfz9xdajibf Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=VPOaPOHF; spf=pass (imf18.hostedemail.com: domain of keescook@chromium.org designates 209.85.216.45 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-HE-Tag: 1639439252-345764 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 09:16:46PM +0000, Matthew Wilcox wrote: > 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); That is interesting, but I think we don't want to do it here; adding to stack or making an allocation for this (even though it's slow-path) doesn't seem like a good idea as far as keeping code size down. -Kees > return; > -- Kees Cook