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 88AE1C43334 for ; Mon, 13 Jun 2022 17:02:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 04F7B8D01AA; Mon, 13 Jun 2022 13:02:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F1B058D01A1; Mon, 13 Jun 2022 13:02:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D939B8D01AA; Mon, 13 Jun 2022 13:02:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C5CCE8D01A1 for ; Mon, 13 Jun 2022 13:02:38 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 8FFD020CF1 for ; Mon, 13 Jun 2022 17:02:38 +0000 (UTC) X-FDA: 79573831596.12.F968577 Received: from mail-lj1-f175.google.com (mail-lj1-f175.google.com [209.85.208.175]) by imf29.hostedemail.com (Postfix) with ESMTP id C0E37120125 for ; Mon, 13 Jun 2022 17:02:17 +0000 (UTC) Received: by mail-lj1-f175.google.com with SMTP id y29so6878399ljd.7 for ; Mon, 13 Jun 2022 10:02:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=yfGsHgTqXo2d2GQmMxeXU0MsupjrY03/0LNxbvUvY5k=; b=PTqmv1Rff4/u8PNMDJAFwPNTt/5z/Yd1tNaTzaMgWPEdKwvXq/0qQlmsdH8R/+Fmu3 iVCaK10kW3BJklmWvCfu9lCBf0Dmr0MMQ3ioVCJ9B2zQMQ+yZBiM7uv6fR1B/p/gc1Z8 wlRpwIxfCDL7TFr787Kl95BPVznpXN5y7fM0DAV2msSRq+OeBHUdODW2wheHrpOoZx8o sntr+kU0aqc2U/woOpiUAjjffQJiKYCtQAz7gQ7mbpgTGMPEgZESIl7K5gAWsBntntTc YD+CGYdI+Bv8ax+Z0aEW6u04cEw7uLStL/dE1ikWOLZPdVCGjUnKCC3nf4e65f4RruA0 4Lhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=yfGsHgTqXo2d2GQmMxeXU0MsupjrY03/0LNxbvUvY5k=; b=i4FYhHSeA3/VBPg3SToqbL0PGzK4p91oC7JOLNmy4t9gm9sl/MPmU2mtOj7QkipxWN nQVtvX7PCEJdocHRJlWY75Uqd8+Ac5Wb4zqz5RQF3+VmAMC5IimG3wbwUn/zbRmzWu/M CcIpd6jqIsisuSJkbuQl+kz8TAP2ljq5nr0Yj1+jhU5HVukP7Fzmm9epAtKe1G7GWqcV Y998ABltCUNhlapOxFxcZlVHphNEfn2W2SIyxZY/SMTcK64RKxuW0a278Sae1OHgejm4 uVXwtNM62//ym8PMuKW2HpW/j2dBMHsX9ryCCtGFvtVN3wH/IrlSnvsg6VYhgDNfbxIE PYgQ== X-Gm-Message-State: AJIora+WA+fL+6jSsxSUJDa2p+011gdojd44m/g82mRWUjaQErEQp80y HidpHEp4sCCkSa8Y4UXbrOA= X-Google-Smtp-Source: AGRyM1st0iUnFw0lkjmtyIHGuku7+0N/gd9mCYdoK+ebmldXBzMn84liFV7aXOwHQ34oA/5CQqh8Zg== X-Received: by 2002:a2e:8851:0:b0:259:1503:56cf with SMTP id z17-20020a2e8851000000b00259150356cfmr6314ljj.272.1655139734445; Mon, 13 Jun 2022 10:02:14 -0700 (PDT) Received: from pc638.lan ([155.137.26.201]) by smtp.gmail.com with ESMTPSA id t20-20020a056512069400b004795311530asm1045996lfe.209.2022.06.13.10.02.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Jun 2022 10:02:13 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Mon, 13 Jun 2022 19:02:10 +0200 To: Matthew Wilcox Cc: Kees Cook , linux-mm@kvack.org, Uladzislau Rezki , Zorro Lang , linux-xfs@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH 1/3] usercopy: Handle vm_map_ram() areas Message-ID: References: <20220612213227.3881769-1-willy@infradead.org> <20220612213227.3881769-2-willy@infradead.org> <202206130922.A218C4E3E8@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1655139738; a=rsa-sha256; cv=none; b=f1lcCPV24hQNrGWtnZQDHyN+ocVHckUZV+kOAhnLMfwbfBrR2DOntws4beG7X0BmxIPmEG 8lkHCfjXhkg42f2cZc90sWZDXLoKxLulmkb7Qbib3t600DPtVSJ/0OkWv2bQFi4vR8wDXP oFK89ZNm78L1zxc/YqSeFj1zFvfAvmA= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PTqmv1Rf; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.175 as permitted sender) smtp.mailfrom=urezki@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1655139738; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=yfGsHgTqXo2d2GQmMxeXU0MsupjrY03/0LNxbvUvY5k=; b=33OYxK8bvpgWDKRKIXCLEzLaIZ8qzZE1GGHkr/k61dNtSaJVGYKTHJUBuyTj0kjwwuAKiT kZJpQ6LWitCHbYv9gxTWF/PTSWxJ7UfncYEw6UXLytNnjPprKMjwo/Z0OD14/9ZyuTMlTr 9B+7h4GOOIAfAV2XNeliLY5DNGOjHpk= X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: C0E37120125 X-Stat-Signature: geajmq41u7iu8re3cnqfjmpdeb9qqxyu Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PTqmv1Rf; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of urezki@gmail.com designates 209.85.208.175 as permitted sender) smtp.mailfrom=urezki@gmail.com X-Rspam-User: X-HE-Tag: 1655139737-676862 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, Jun 13, 2022 at 05:44:35PM +0100, Matthew Wilcox wrote: > On Mon, Jun 13, 2022 at 09:23:15AM -0700, Kees Cook wrote: > > On Sun, Jun 12, 2022 at 10:32:25PM +0100, Matthew Wilcox (Oracle) wrote: > > > vmalloc does not allocate a vm_struct for vm_map_ram() areas. That causes > > > us to deny usercopies from those areas. This affects XFS which uses > > > vm_map_ram() for its directories. > > > > > > Fix this by calling find_vmap_area() instead of find_vm_area(). > > > > Thanks for the fixes! > > > > > [...] > > > + /* XXX: We should also abort for free vmap_areas */ > > > > What's needed to detect this? > > I'm not entirely sure. I only just learned of the existence of this > struct ;-) > > /* > * The following two variables can be packed, because > * a vmap_area object can be either: > * 1) in "free" tree (root is free_vmap_area_root) > * 2) or "busy" tree (root is vmap_area_root) > */ > union { > unsigned long subtree_max_size; /* in "free" tree */ > struct vm_struct *vm; /* in "busy" tree */ > }; > > Hmm. Actually, we only search vmap_area_root, so I suppose it can't > be a free area. So this XXX can be removed, as we'll get NULL back > if we've got a pointer to a free area. Ulad, do I have this right? > Yep, we find here only allocated areas which bind to the "vmap_area_root" tree, so it can not be a freed area. So we will not get a pointer to the free area :) -- Uladzislau Rezki