Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp1546620ybm; Thu, 23 May 2019 02:57:36 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsh0U+/EpfzA35Ko7MVsM/b7DOXkn0peoevIyc4iINwnOROj6zpmanyEgAoK3v9UgnaO0l X-Received: by 2002:a65:4649:: with SMTP id k9mr97638872pgr.239.1558605456754; Thu, 23 May 2019 02:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558605456; cv=none; d=google.com; s=arc-20160816; b=FGpuVdfrzgbmG6hv1t2y0lDADNr8utHts/9l6PSDQS36tEfDRjaUouIOCXg+dR/qAP FJO6azFWxIHM6fyuHgPEnkfJwy4j8Obh2EBE8UhNOwTP2wcn2WjBJmaNA/ss52Hsg8Iu ATs7uU1dAIG3iteHQLvpUv2MHy6h6rB4qUnrjq/j6TwWJFlCyRgMF6Ct7tAFtwgeiWjA B84I/u9AMmFKUaJy9XHLwA9ZmHGFgisKh0cd1xDy/g4viQFFxR1Kn9CnwHW65bld1rtD NldwdAbnLLWP7ktFcdOajGm3lj106ZMBBTJj2wzzxtXaz71mxKRpb26CDBKmEG8AE5CZ XThQ== 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=XcnGRhVVyNL37UuM2RMXdYZmMPDHmNAhLUCRA5xcUDo=; b=jvAKniLrIiL+b8YSh6WJanlWUUS4kE0AQUaq5XwXOk0qYeM3HA49zXWhp/dk9MKuJl OK7JcqUDXqlPK2BUsJHmq9hCWLt7QCNdKtJQO+uz2HlfFrGiEtjHCdMIR0XADF1Guzih iTxQfzJMUBqJIknKLF7rzN7CaY+GAcTV9u3g0AfsFiNZBHkWJFfTzP1JZJXS+jtJ9htn gEpAkh3HduboDrKP1zlpo6EhovuKGX64i3j5/LBhPg5sIGvfpMWtfBLK1nIUspZ6JRO8 rpOs8CJanAbqvUQFCw3c/i/ihg/IFb9NPJnLPiGSkKEB+ILGGLxBNOftU2Y/+PzI20I/ Kz5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@brauner.io header.s=google header.b=O0wuggV6; 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 3si28288844pfp.288.2019.05.23.02.57.21; Thu, 23 May 2019 02:57:36 -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=@brauner.io header.s=google header.b=O0wuggV6; 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 S1730028AbfEWJzL (ORCPT + 99 others); Thu, 23 May 2019 05:55:11 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:40397 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726846AbfEWJzK (ORCPT ); Thu, 23 May 2019 05:55:10 -0400 Received: by mail-ed1-f65.google.com with SMTP id j12so8354488eds.7 for ; Thu, 23 May 2019 02:55:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brauner.io; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=XcnGRhVVyNL37UuM2RMXdYZmMPDHmNAhLUCRA5xcUDo=; b=O0wuggV6ZTRRY9IuFVi+Hy5ZffEWKgbDaxa4tUMjnr9ukzoVJ+6ESsFv482ScAF+lN mZJQMUGVUc4J6DhDCUH25aotoYsf10ISXjQ03OgcydZlHj6YMDwmwdTgHrQqfRbY0b2e +MkrirnkhnUODJSGZeiiTghbv1k678cPmDD5fU0dyiykv7ixjjepA8wUU/TvIq5ADMeM kIanjFRf+sWTGKkUkejAd32KCh2rj29VqwW4ask3xJXreRH1UwkrmEqpFdxwP5lfiJyz B7vkZAjE7n6GGVkd8y1t6z+9fq6lyZO7i9b0KYvFE/HJTlsRZElQrWIEP1p047EJSUyE oRWg== 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=XcnGRhVVyNL37UuM2RMXdYZmMPDHmNAhLUCRA5xcUDo=; b=KQDHN0YLV40ktTRj6RKBdv7f+hm1YME0KcIzOU0Mrmb88V8HnkP/4tNGh2r1UArBnq gVk/P+EPbqBjTYeoojS3d5WkZGFw+m2riXXrIpvMpW69V/oqaxyX/wiPj4gvU+FI6vg9 /Td20v/r3lYVYKP8+tgh98zWB3IBTZuASneRL1GfFtMgxWWuRyDmR2r8Cp14Xr7HFp7L zl8mrrigEXba5gw3Rlo0uvr8dm5ekul7b1Y45mVeH4coKTHXi6VyT7L82bW/IcfFOuPr bL/OHqB99ySzVZjEEhtA+tkYvgfl1f9DjvNwc6ehtoYFXA7q3lz+m8AcBpftxLwozSrq cWew== X-Gm-Message-State: APjAAAUsNlebc0isRn9UHVTVm957DTnRTK3Gyd01Eap/NTQrkcLzuzhR HAuNeW+rN6j+1aPyMwqKZCMkSA== X-Received: by 2002:a50:ad77:: with SMTP id z52mr95891367edc.174.1558605309242; Thu, 23 May 2019 02:55:09 -0700 (PDT) Received: from brauner.io (178-197-142-46.pool.kielnet.net. [46.142.197.178]) by smtp.gmail.com with ESMTPSA id o47sm7838488edc.37.2019.05.23.02.55.08 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 23 May 2019 02:55:08 -0700 (PDT) Date: Thu, 23 May 2019 11:55:07 +0200 From: Christian Brauner To: Amir Goldstein Cc: Jan Kara , linux-fsdevel , linux-kernel Subject: Re: [PATCH] fanotify: remove redundant capable(CAP_SYS_ADMIN)s Message-ID: <20190523095506.nyei5nogvv63lm4a@brauner.io> References: <20190522163150.16849-1-christian@brauner.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 22, 2019 at 11:00:22PM +0300, Amir Goldstein wrote: > On Wed, May 22, 2019 at 9:57 PM Christian Brauner wrote: > > > > On May 22, 2019 8:29:37 PM GMT+02:00, Amir Goldstein wrote: > > >On Wed, May 22, 2019 at 7:32 PM Christian Brauner > > > wrote: > > >> > > >> This removes two redundant capable(CAP_SYS_ADMIN) checks from > > >> fanotify_init(). > > >> fanotify_init() guards the whole syscall with capable(CAP_SYS_ADMIN) > > >at the > > >> beginning. So the other two capable(CAP_SYS_ADMIN) checks are not > > >needed. > > > > > >It's intentional: > > > > > >commit e7099d8a5a34d2876908a9fab4952dabdcfc5909 > > >Author: Eric Paris > > >Date: Thu Oct 28 17:21:57 2010 -0400 > > > > > > fanotify: limit the number of marks in a single fanotify group > > > > > >There is currently no limit on the number of marks a given fanotify > > >group > > >can have. Since fanotify is gated on CAP_SYS_ADMIN this was not seen > > >as > > >a serious DoS threat. This patch implements a default of 8192, the > > >same as > > >inotify to work towards removing the CAP_SYS_ADMIN gating and > > >eliminating > > > the default DoS'able status. > > > > > > Signed-off-by: Eric Paris > > > > > >There idea is to eventually remove the gated CAP_SYS_ADMIN. > > >There is no reason that fanotify could not be used by unprivileged > > >users > > >to setup inotify style watch on an inode or directories children, see: > > >https://patchwork.kernel.org/patch/10668299/ > > > > > >> > > >> Fixes: 5dd03f55fd2 ("fanotify: allow userspace to override max queue > > >depth") > > >> Fixes: ac7e22dcfaf ("fanotify: allow userspace to override max > > >marks") > > > > > >Fixes is used to tag bug fixes for stable. > > >There is no bug. > > > > > >Thanks, > > >Amir. > > > > Interesting. When do you think the gate can be removed? > > Nobody is working on this AFAIK. > What I posted was a simple POC, but I have no use case for this. > In the patchwork link above, Jan has listed the prerequisites for > removing the gate. > > One of the prerequisites is FAN_REPORT_FID, which is now merged. > When events gets reported with fid instead of fd, unprivileged user > (hopefully) cannot use fid for privilege escalation. > > > I was looking into switching from inotify to fanotify but since it's not usable from > > non-initial userns it's a no-no > > since we support nested workloads. > > One of Jan's questions was what is the benefit of using inotify-compatible > fanotify vs. using inotify. > So what was the reason you were looking into switching from inotify to fanotify? > Is it because of mount/filesystem watch? Because making those available for Yeah. Well, I would need to look but you could probably do it safely for filesystems mountable in user namespaces (which are few). Can you do a bind-mount and then place a watch on the bind-mount or is this superblock based? Thanks! Christian