From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757052AbbJ2Nxx (ORCPT ); Thu, 29 Oct 2015 09:53:53 -0400 Received: from pacujo.net ([83.150.83.132]:48461 "EHLO pacujo.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752293AbbJ2Nxu (ORCPT ); Thu, 29 Oct 2015 09:53:50 -0400 X-Greylist: delayed 1435 seconds by postgrey-1.27 at vger.kernel.org; Thu, 29 Oct 2015 09:53:50 EDT From: Marko Rauhamaa To: linux-kernel@vger.kernel.org Subject: fanotify and namespaces/bind mounts Date: Thu, 29 Oct 2015 15:29:53 +0200 Message-ID: <87y4elol9q.fsf@elektro.pacujo.net> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If I call fanotify_mark(... FAN_MARK_ADD | FAN_MARK_MOUNT ...), I get notifications on all files on the file system. Except I don't. If a process has mounted directories on the file system in a different namespace, the global namespace experiences file system events but no fanotify events are generated. A similar limitation applies to bind mounts. You can easily see this behavior in action. Do "man fanotify", and copy the example program to, say, example.c. Then, cc -o example example.c mkdir -p /mnt/xyz mount -o bind /root /mnt/xyz ./example /root The last command prints out fanotify events. It will display events for touch /root/xyzzy but nothing for touch /mnt/xyz/zyxxy or unshare -m touch /root/yxyyx Should the current situation be considered a bug in fanotify? Or is there another recommended way to monitor file system events categorigally? Marko