Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3553016imm; Fri, 19 Oct 2018 12:33:46 -0700 (PDT) X-Google-Smtp-Source: ACcGV62Hr1+TxqnE4mcd2Aq5OZLJ9MIfkAecT8ctlqDwZRTqagp72AKzQ4HnILjYSrH/VBAec/Gb X-Received: by 2002:a17:902:720b:: with SMTP id ba11-v6mr34815772plb.199.1539977626107; Fri, 19 Oct 2018 12:33:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539977626; cv=none; d=google.com; s=arc-20160816; b=ahHe2lRRVaZjv9gosSJ76Kv7l7EK7zxX6k5Ghc8m5tzTIJWkdiLTrYoR7P1CYbiHYF WG3pMvf/Llw2GpgcPx9IKGAe7LFnwkklUVsbKCrCYc/vc7bxz9Q1j8usMf4TeEiSmEyz L7sQOm5umBIeF9g2WPqRGf3PIZKWIldmmVrgeiGx4aEnMc1KkFnnbMb/K+oyImxyZXKn EE0/xQ/DrVAsGgq7KgPz65ilHH9M30JqX+HBZYP/Lopk3vIYc/r9fz02dXbAnEmUFt6V jX+bwiWPgqNWsYnkj5CxDom9SMqQpwPIrsxvEGQyVYxhXQ/US+IhnFk+BMHpSBrqpOF2 gwyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Te2xcDjP2AI1m4qQ1Kf1q0A8KLC0u4osR3z/f5hltaE=; b=pjlh1EsMiT+mfDvCOxhm8J2W9ZwfmtcXkJTRBNwFtdveSjHtx+Rgg51d0pZ03tQPH1 Z5T4tvtcZOYag/XgSjAZj+hK1YQ4AhdKSmHY8ersKW5IMDiHwb6qmTcZ52TqaFu10SOA Pbb3BvvV50tMpWCdF0N+/5TU9wrNt29B+dBAqRm0UCDea/9F2UnJNgMA4fCYEjJMtw/w /yxIfIZAj3HhbFevtsq/GtrvK1xgywE3no1inP6dcgywRN5oe6BPC/o6X8LoJqPkmXfB 8c2wFs6luVUtNC/M2RhgXVCNBcllSse+Br2sezNBLDLYo+MAcpqrFegXVUq4vBhyXFbw DdsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Pehw5mzF; 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 91-v6si5487523ply.48.2018.10.19.12.33.31; Fri, 19 Oct 2018 12:33:46 -0700 (PDT) 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; dkim=pass header.i=@joelfernandes.org header.s=google header.b=Pehw5mzF; 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 S1727989AbeJTDjr (ORCPT + 99 others); Fri, 19 Oct 2018 23:39:47 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:39400 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727772AbeJTDjr (ORCPT ); Fri, 19 Oct 2018 23:39:47 -0400 Received: by mail-pl1-f194.google.com with SMTP id e67-v6so7293022plb.6 for ; Fri, 19 Oct 2018 12:32:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=joelfernandes.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=Te2xcDjP2AI1m4qQ1Kf1q0A8KLC0u4osR3z/f5hltaE=; b=Pehw5mzF3JGpD2gy+62/zEf6gKRP5zqgiaXRAJATzJWPjwlIW2XrVfildiWYLQUZwf Q+DZcDBeczGtlCupoJI4AHJJ9eJbLqgJVbJ2Ru+bgNvY9eEeaBHAAkFT1D2mw5d5x/1Y 8v42b04IsTLrKhyENn8SDzUp4AYXmLciN654M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=Te2xcDjP2AI1m4qQ1Kf1q0A8KLC0u4osR3z/f5hltaE=; b=ua/R6Ug/R90XcOZNnPfa7DBDGVCMEnecwZgyBYzQfW0JDkeq4o4TxAPi5gn/I1EShc PGTlecv0COINuNIMlP8PKhhvGabHd4jmz0tOmqbcGoyAFaAdKGJ6OrGE+PcyJVtIXGD7 2+BtaHJlslzmgl6DxbUIwvsXbyEUEMIlNkflhQpN2uP4AD8CzMF+wuLQuxHyy2AglFkx cxNMnEq114QftyGGUETqc28nwDDX4gMIpTUxYAQuAywAxFDy31btFrdcO+GL4E+lLKl/ KNosKr6Et/uAaYTwkZUHWGvk5N7BmLVKYW/5XOqPNjPkRkUFf2YwI3n7GVTk2MJCWJPW hXfA== X-Gm-Message-State: ABuFfohzMxWtfpoiLeBQ336vmlS8JXeAwwiufyZ1A+zHNoNMjs8OK+Ir h1juTA7EyTMXz8s6Sb7c5N+dgw== X-Received: by 2002:a17:902:a618:: with SMTP id u24-v6mr35016617plq.77.1539977539643; Fri, 19 Oct 2018 12:32:19 -0700 (PDT) Received: from localhost ([2620:0:1000:1601:3aef:314f:b9ea:889f]) by smtp.gmail.com with ESMTPSA id p17-v6sm41955176pfk.186.2018.10.19.12.32.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 19 Oct 2018 12:32:18 -0700 (PDT) Date: Fri, 19 Oct 2018 12:32:17 -0700 From: Joel Fernandes To: valdis.kletnieks@vt.edu Cc: LKML , kernel-team , John Reck , John Stultz , Todd Kjos , Greg Kroah-Hartman , Christoph Hellwig , Al Viro , Andrew Morton , Daniel Colascione , "J. Bruce Fields" , Jeff Layton , linux-fsdevel@vger.kernel.org, linux-kselftest , linux-mm , marcandre.lureau@redhat.com, Mike Kravetz , Minchan Kim , Shuah Khan , Thomas Gleixner Subject: Re: [PATCH v3 1/2] mm: Add an F_SEAL_FUTURE_WRITE seal to memfd Message-ID: <20181019193217.GA181176@joelaf.mtv.corp.google.com> References: <20181018065908.254389-1-joel@joelfernandes.org> <42922.1539970322@turing-police.cc.vt.edu> <118792.1539974951@turing-police.cc.vt.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <118792.1539974951@turing-police.cc.vt.edu> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 19, 2018 at 02:49:11PM -0400, valdis.kletnieks@vt.edu wrote: > On Fri, 19 Oct 2018 10:57:31 -0700, Joel Fernandes said: > > On Fri, Oct 19, 2018 at 10:32 AM, wrote: > > > What is supposed to happen if some other process has an already existing R/W > > > mmap of the region? (For that matter, the test program doesn't seem to > > > actually test that the existing mmap region remains writable?) > > > Why would it not remain writable? We don't change anything in the > > mapping that prevents it from being writable, in the patch. > > OK, if the meaning here is "if another process races and gets its own R/W mmap > before we seal our mmap, it's OK". Seems like somewhat shaky security-wise - a > possibly malicious process can fail to get a R/W map because we just sealed it, > but if it had done the attempt a few milliseconds earlier it would have its own > R/W mmap to do as it pleases... > > On the other hand, decades of trying have proven that trying to do any sort > of revoke() is a lot harder to do than it looks... > No it is not a security issue. The issue you bring up can happen even with the existing F_SEAL_WRITE where someone else races to mmap it. And if someone else could race and do an mmap on the memfd, then they somehow goes the fd at which point that is a security issue anyway. That is the whole point of memfd, that it can be securely sent over IPC to another process. Also, before sending it to the receiving/racing process, the memfd would have already been sealed with the F_SEAL_FUTURE_WRITE so there is no question of a race on the receiving side. - Joel