Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4857489ybg; Mon, 21 Oct 2019 15:53:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUN7cBX9mjCi84OdNcy+DqKr9x94QBdEQ7QYjs7K/1l9numFT36GUXm+HVULKrH1+lloe7 X-Received: by 2002:a17:906:6a54:: with SMTP id n20mr24677103ejs.30.1571698390904; Mon, 21 Oct 2019 15:53:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571698390; cv=none; d=google.com; s=arc-20160816; b=D0KZL0/2mQimihdDCzePWpDJ4nC9F2faoR+CEntCatUA3Apch+Oh/di/4xh1OVecQt kX5Be9uNHyzC1f9/G9Ptv49UQeLRBtrHj4jVNNRsczmaNv9bAs3R0yWtO6l45Yaa94qq WqfHII+ws8UMVrB8T7pO5p53M1ft1UGuWcH503m6dnEGFHzy0A9RoNEoBy7F/qRcMzzH lpxUe13KlsBCSdHY9Br46DMg2WoG0Keak3vbrIESMlHzyo8Hj8D0ihIEkapTRuOAcY1x sk6J88pd8oYKbopAHnG+aNiPVdMX15KrIxZk8P/dx9TaAwFvLYA+mGQNOqbamwtO7SEl DElg== 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; bh=8pfPmK01hGKWnKev0rgPtaanEO/fjVUHlZ/xnowlIM8=; b=EXZpiGEhmn6zcdNqYCoTLIsckmvV8dXS4avLw9LUVaWZwGr1xKWylog1gBaAxACe0m wllNvpWY51hhdOR3q5nfwBt+IqsjJLOFfR3fHZ2tSQwtMw8xhPy+NGwkBRm/wt8xsY+A wUGaBebY4I45uecCpidi5Gbc8j0/OvnZKECs+byd2U5em4MyrrGx6pXbc4oudJfCeFtq llRbsVYHedhcgi3Xj4khg++QwV2nZI8XKeuaJ8B+O5XoFsGBWEjqRBiOBpjwCRPIrrjf hCJVdVgOqYKSKe37c3QhS/gouJJWl1n8ZP/DN3z7dGfrblct6Ch2SBSszDiMKkMBxsol cNmQ== 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 s7si10993758edd.290.2019.10.21.15.52.47; Mon, 21 Oct 2019 15:53:10 -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; 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 S1730480AbfJUWwl (ORCPT + 99 others); Mon, 21 Oct 2019 18:52:41 -0400 Received: from mail105.syd.optusnet.com.au ([211.29.132.249]:56174 "EHLO mail105.syd.optusnet.com.au" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730399AbfJUWwl (ORCPT ); Mon, 21 Oct 2019 18:52:41 -0400 Received: from dread.disaster.area (pa49-180-40-48.pa.nsw.optusnet.com.au [49.180.40.48]) by mail105.syd.optusnet.com.au (Postfix) with ESMTPS id 0202A363692; Tue, 22 Oct 2019 09:52:35 +1100 (AEDT) Received: from dave by dread.disaster.area with local (Exim 4.92.3) (envelope-from ) id 1iMgXS-00074h-TR; Tue, 22 Oct 2019 09:52:34 +1100 Date: Tue, 22 Oct 2019 09:52:34 +1100 From: Dave Chinner To: Mike Christie Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, martin@urbackup.org, Damien.LeMoal@wdc.com Subject: Re: [PATCH] Add prctl support for controlling PF_MEMALLOC V2 Message-ID: <20191021225234.GC2642@dread.disaster.area> References: <20191021214137.8172-1-mchristi@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191021214137.8172-1-mchristi@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=G6BsK5s5 c=1 sm=1 tr=0 a=y881pOMu+B+mZdf5UrsJdA==:117 a=y881pOMu+B+mZdf5UrsJdA==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=kj9zAlcOel0A:10 a=XobE76Q3jBoA:10 a=20KFwNOVAAAA:8 a=7-415B0cAAAA:8 a=rSlL4X6sGr0P-yuullEA:9 a=CjuIK1q_8ugA:10 a=biEYGPWJfzWAr4FL6Ov7:22 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 21, 2019 at 04:41:37PM -0500, Mike Christie wrote: > There are several storage drivers like dm-multipath, iscsi, tcmu-runner, > amd nbd that have userspace components that can run in the IO path. For > example, iscsi and nbd's userspace deamons may need to recreate a socket > and/or send IO on it, and dm-multipath's daemon multipathd may need to > send IO to figure out the state of paths and re-set them up. > > In the kernel these drivers have access to GFP_NOIO/GFP_NOFS and the > memalloc_*_save/restore functions to control the allocation behavior, > but for userspace we would end up hitting a allocation that ended up > writing data back to the same device we are trying to allocate for. I think this needs to describe the symptoms this results in. i.e. that this can result in deadlocking the IO path. > This patch allows the userspace deamon to set the PF_MEMALLOC* flags > with prctl during their initialization so later allocations cannot > calling back into them. > > Signed-off-by: Mike Christie > --- .... > + case PR_SET_MEMALLOC: > + if (!capable(CAP_SYS_ADMIN)) > + return -EPERM; Wouldn't CAP_SYS_RAWIO (because it's required by kernel IO path drivers) or CAP_SYS_RESOURCE (controlling memory allocation behaviour) be more appropriate here? Which-ever is selected, the use should be added to the list above the definition of the capability in include/linux/capability.h... Otherwise looks fine to me. Cheers, Dave. -- Dave Chinner david@fromorbit.com