Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp5860253ybg; Tue, 22 Oct 2019 09:23:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxb1BZDctNTFQob/pTZUSBulhH+1HWIUf3F93beel7mtbSVL3PVgYSZdI4flSysVFicvH2L X-Received: by 2002:aa7:c959:: with SMTP id h25mr32177531edt.216.1571761438537; Tue, 22 Oct 2019 09:23:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571761438; cv=none; d=google.com; s=arc-20160816; b=FLAwngBu1K0HNi42V6+iaytVBlXnCIWc6hzJlmSpPFhCpQIjlxyzqOqrUkku4mAZ2n +iOfrWs9GFzHgcSlsli0A0UsiZgSFtx53+ZOB6jAChd3QOllntIvSPFXgP9SbsYOB/J7 j21E7BEi5p6Ujoi/q+hMc4ajj3f+9wWMhbm8TLSFtQI7ID1aWZWH5NdkJMjVwExl/cah QE4bA0vmof2+mronr46mbwc2Docqvga0VfNUt8L44oClV6xJ63gpweDisXckmWl0KNNM V36jc3IJfJRI1R26sp3p7YzVYZ7FRD+LjwHJEsUHEGQbL9Kw4XpH5NEnNfO/pTcDQns4 +6xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject:dkim-signature; bh=FHUjeSW+OQPq+sc+A88fJ+/QQEBkysWzrSaHp9k75do=; b=AtWrtMIJ+fQ+zLV8LF2SHxqYMBbxmxLZmMAk8rVCKWGqiaCKUMgQQEczFykcvuwS+7 i6UIC1TB8oDHhV4+FJsctg92xJ+AkKA8tJ0OTLFPxwtR7i3a+JCyEoguj8WZYzcgX4aq TVeoApoIrvZUiy+mnV62UZELRFpy4BO092d9XS/MNMeOAC1HdJ2Lj11JJlj69fnoy7tD EDSPP92qwlXV+Od8OOCAd13Rkz9DdFOuMV+BJsEOda66mXqtos3DgF5csmBfWCUvDbzo +x7MMTainMU2VMqauObxMuM+FWfg9zm4pJc60NZbsmGkm987HZM6X4PDEWh0itSwYh0N xrew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=OyejphQp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o19si6388020edz.97.2019.10.22.09.23.34; Tue, 22 Oct 2019 09:23:58 -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=@redhat.com header.s=mimecast20190719 header.b=OyejphQp; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387651AbfJVPmf (ORCPT + 99 others); Tue, 22 Oct 2019 11:42:35 -0400 Received: from us-smtp-1.mimecast.com ([205.139.110.61]:59388 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731277AbfJVPmf (ORCPT ); Tue, 22 Oct 2019 11:42:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1571758953; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FHUjeSW+OQPq+sc+A88fJ+/QQEBkysWzrSaHp9k75do=; b=OyejphQpYSsgzUWubEwFX7pAC6OWtaKD3dHlB+raYZdE7NmFwoupOBSF7dGO3XPChnAG2p QwSj5LMzFGX0RNnduOmekp6tRq4aXQ9j1sJKjrsEt1+01+BlYwA1zd6zhcpbN4WBhOF+Ec nEqpOsX6tysXEayKhtp+ZTdoy0kblIQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-212-duVXvBAvNBGY_2YeQmWhzA-1; Tue, 22 Oct 2019 11:42:30 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E6C001800DD0; Tue, 22 Oct 2019 15:42:28 +0000 (UTC) Received: from [10.10.123.180] (ovpn-123-180.rdu2.redhat.com [10.10.123.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id E64B560C5E; Tue, 22 Oct 2019 15:42:27 +0000 (UTC) Subject: Re: [PATCH] Add prctl support for controlling PF_MEMALLOC V2 To: Dave Chinner References: <20191021214137.8172-1-mchristi@redhat.com> <20191021225234.GC2642@dread.disaster.area> 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 From: Mike Christie Message-ID: <5DAF2363.2070204@redhat.com> Date: Tue, 22 Oct 2019 10:42:27 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20191021225234.GC2642@dread.disaster.area> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: duVXvBAvNBGY_2YeQmWhzA-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/21/2019 05:52 PM, Dave Chinner wrote: > 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. >=20 > I think this needs to describe the symptoms this results in. i.e. > that this can result in deadlocking the IO path. >=20 >> 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 >> --- >=20 > .... >> +=09case PR_SET_MEMALLOC: >> +=09=09if (!capable(CAP_SYS_ADMIN)) >> +=09=09=09return -EPERM; >=20 > 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? I think I misread a review comment last posting. I will use CAP_SYS_RESROUCE on the next resend if people do not have any objections. >=20 > Which-ever is selected, the use should be added to the list above > the definition of the capability in include/linux/capability.h... >=20 Will do. Thanks. > Otherwise looks fine to me. >=20 > Cheers, >=20 > Dave. >=20