GoboLinux Downloads Documentation Community Recipes Screenshots

GoboLinux Recipe & Package Search Tool

71 versions of Linux.

ProgramAgeSizeByWWWSummary
Linux 4.13.2-r1 851  88794 Luca...
The Linux Kernel.
Linux 4.9.16-r3 1022  100651 Luca...
The Linux Kernel.
Linux 4.9.4-r5 1078  99374 Luca...
The Linux Kernel.
Linux 4.8.2-r2 1144  89394 Luca...
The Linux Kernel.
Linux 4.7.4-r1 1214  82767 Luca...
The Linux Kernel.
view entry at GitHub | download recipe.bz2 file
01-gobohide.patch
Recipe
Resources/BuildDependencies
Resources/BuildInformation
Resources/Dependencies
Resources/Description
cell/02-memcpy-cell.patch
cell/Recipe
cell/dot-config
i686/Recipe
i686/dot-config
ppc/Recipe
ppc/dot-config
x86_64/Recipe
x86_64/dot-config
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/compat.c linux-4.7/fs/compat.c
--- linux-4.7.orig/fs/compat.c	2016-07-24 19:23:50.000000000 +0000
+++ linux-4.7/fs/compat.c	2016-08-20 20:10:15.772599428 +0000
@@ -48,6 +48,7 @@
 #include <linux/slab.h>
 #include <linux/pagemap.h>
 #include <linux/aio.h>
+#include <linux/gobohide.h>
 
 #include <asm/uaccess.h>
 #include <asm/mmu_context.h>
@@ -844,6 +845,7 @@ struct compat_readdir_callback {
 	struct dir_context ctx;
 	struct compat_old_linux_dirent __user *dirent;
 	int result;
+	struct dentry *dentry;
 };
 
 static int compat_fillonedir(struct dir_context *ctx, const char *name,
@@ -893,6 +895,7 @@ COMPAT_SYSCALL_DEFINE3(old_readdir, unsi
 	if (!f.file)
 		return -EBADF;
 
+	buf.dentry = f.file->f_path.dentry;
 	error = iterate_dir(f.file, &buf.ctx);
 	if (buf.result)
 		error = buf.result;
@@ -914,6 +917,7 @@ struct compat_getdents_callback {
 	struct compat_linux_dirent __user *previous;
 	int count;
 	int error;
+	struct dentry *dentry;
 };
 
 static int compat_filldir(struct dir_context *ctx, const char *name, int namlen,
@@ -923,6 +927,7 @@ static int compat_filldir(struct dir_con
 	struct compat_getdents_callback *buf =
 		container_of(ctx, struct compat_getdents_callback, ctx);
 	compat_ulong_t d_ino;
+	struct hide *hidden;
 	int reclen = ALIGN(offsetof(struct compat_linux_dirent, d_name) +
 		namlen + 2, sizeof(compat_long_t));
 
@@ -936,12 +941,22 @@ static int compat_filldir(struct dir_con
 	}
 	dirent = buf->previous;
 	if (dirent) {
+		hidden = gobohide_get(d_ino, name, namlen, buf->dentry);
+		if (hidden) {
+			gobohide_put(hidden);
+			return 0;
+		}
 		if (signal_pending(current))
 			return -EINTR;
 		if (__put_user(offset, &dirent->d_off))
 			goto efault;
 	}
 	dirent = buf->current_dir;
+	hidden = gobohide_get(d_ino, name, namlen, buf->dentry);
+	if (hidden) {
+		gobohide_put(hidden);
+		return 0;
+	}
 	if (__put_user(d_ino, &dirent->d_ino))
 		goto efault;
 	if (__put_user(reclen, &dirent->d_reclen))
@@ -981,6 +996,7 @@ COMPAT_SYSCALL_DEFINE3(getdents, unsigne
 	if (!f.file)
 		return -EBADF;
 
+	buf.dentry = f.file->f_path.dentry;
 	error = iterate_dir(f.file, &buf.ctx);
 	if (error >= 0)
 		error = buf.error;
@@ -1003,6 +1019,7 @@ struct compat_getdents_callback64 {
 	struct linux_dirent64 __user *previous;
 	int count;
 	int error;
+	struct dentry *dentry;
 };
 
 static int compat_filldir64(struct dir_context *ctx, const char *name,
@@ -1010,6 +1027,7 @@ static int compat_filldir64(struct dir_c
 			    unsigned int d_type)
 {
 	struct linux_dirent64 __user *dirent;
+	struct hide *hidden;
 	struct compat_getdents_callback64 *buf =
 		container_of(ctx, struct compat_getdents_callback64, ctx);
 	int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1,
@@ -1022,12 +1040,22 @@ static int compat_filldir64(struct dir_c
 	dirent = buf->previous;
 
 	if (dirent) {
+		hidden = gobohide_get(ino, name, namlen, buf->dentry);
+		if (hidden) {
+			gobohide_put(hidden);
+			return 0;
+		}
 		if (signal_pending(current))
 			return -EINTR;
 		if (__put_user_unaligned(offset, &dirent->d_off))
 			goto efault;
 	}
 	dirent = buf->current_dir;
+	hidden = gobohide_get(ino, name, namlen, buf->dentry);
+	if (hidden) {
+		gobohide_put(hidden);
+		return 0;
+	}
 	if (__put_user_unaligned(ino, &dirent->d_ino))
 		goto efault;
 	off = 0;
@@ -1070,6 +1098,7 @@ COMPAT_SYSCALL_DEFINE3(getdents64, unsig
 	if (!f.file)
 		return -EBADF;
 
+	buf.dentry = f.file->f_path.dentry;
 	error = iterate_dir(f.file, &buf.ctx);
 	if (error >= 0)
 		error = buf.error;
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/compat_ioctl.c linux-4.7/fs/compat_ioctl.c
--- linux-4.7.orig/fs/compat_ioctl.c	2016-07-24 19:23:50.000000000 +0000
+++ linux-4.7/fs/compat_ioctl.c	2016-08-20 20:10:15.772599428 +0000
@@ -57,6 +57,7 @@
 #include <linux/i2c-dev.h>
 #include <linux/atalk.h>
 #include <linux/gfp.h>
+#include <linux/gobohide.h>
 
 #include "internal.h"
 
@@ -910,6 +911,7 @@ COMPATIBLE_IOCTL(FIONCLEX)
 COMPATIBLE_IOCTL(FIOASYNC)
 COMPATIBLE_IOCTL(FIONBIO)
 COMPATIBLE_IOCTL(FIONREAD)  /* This is also TIOCINQ */
+COMPATIBLE_IOCTL(FIGOBOHIDE)
 COMPATIBLE_IOCTL(FS_IOC_FIEMAP)
 /* 0x00 */
 COMPATIBLE_IOCTL(FIBMAP)
@@ -1557,6 +1559,7 @@ COMPAT_SYSCALL_DEFINE3(ioctl, unsigned i
 	case FIONBIO:
 	case FIOASYNC:
 	case FIOQSIZE:
+	case FIGOBOHIDE:
 		break;
 
 #if defined(CONFIG_IA64) || defined(CONFIG_X86_64)
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/gobohide.c linux-4.7/fs/gobohide.c
--- linux-4.7.orig/fs/gobohide.c	1970-01-01 00:00:00.000000000 +0000
+++ linux-4.7/fs/gobohide.c	2016-09-19 18:05:54.619610601 +0000
@@ -0,0 +1,516 @@
+/*
+ * Copyright (C) 2002-2011 GoboLinux.org
+ *
+ * These modifications are released under the GNU General Public License
+ * version 2 or later, incorporated herein by reference.
+ * Modifications/features/bug fixes based on or derived from this code
+ * fall under the GPL and must retain the authorship, copyright and license
+ * notice.  This file is not a complete program and may only be used when
+ * the entire operating system is licensed under the GPL.
+ *
+ * See the file COPYING in this distribution for more information.
+ *
+ * Author: Felipe W Damasio <felipewd@gmail.com>.
+ * Original idea: Lucas C. Villa Real <lucasvr@gobolinux.org>
+ *
+ * Changes:
+ * 12-Sep-2011 - Lucas C. Villa Real
+ *               Take the superblock into account when comparing the dentries
+ *               in order to allow mount points to be hidden.
+ *
+ * 03-Sep-2011 - Lucas C. Villa Real
+ *               Security updates. Thanks to Dan Rosenberg for his code review.
+ *
+ * 18-May-2007 - Lucas C. Villa Real
+ *               Added support to unionfs.
+ *
+ * 04-Jul-2006 - Lucas C. Villa Real
+ *               Added GoboHide support to all filesystems through the VFS.
+ *
+ * 21-Feb-2004 - Lucas C. Villa Real
+ *               Added an extra check for the inode's VFS root, so that
+ *               the same inode number on different partitions don't get
+ *               hidden mistakenly.
+ *
+ * 11-Nov-2003 - Lucas C. Villa Real
+ *               Removed the spinlocks from gobolinux_show_hidden(), since
+ *               we were already working with list_for_each_safe(), which
+ *               iterates safely against removal of list entries.
+ *
+ * 05-May-2003 - Felipe W Damasio
+ *               Using read-write locks instead of spinlocks,
+ *               improving quite a bit read operations
+ *               (allow concurrent readers, but only a single writer)
+ *
+ * 28-Apr-2003 - Lucas C. Villa Real
+ *               Centralized checks for UID on gobolinux/fs/ioctl.c.
+ *               Fixed get_free_page() to work on 64-bit archs as well.
+ *
+ * 12-Apr-2003 - Lucas C. Villa Real
+ *               Removed support for UID's different than 0 hide inodes.
+ *
+ * 24-Mar-2003 - Lucas C. Villa Real
+ *               Modified struct hide and calls so we have pathnames related
+ *               to the "real" root dir and not the the mount point.
+ *
+ * 17-Mar-2003 - Lucas C. Villa Real
+ *               Added support for full pathname, rather than dealing only
+ *               with inode numbers.
+ *
+ * 10-Jan-2003 - Lucas C. Villa Real
+ *               Added statistics.
+ */
+#include <linux/fs.h>
+#include <linux/namei.h>
+#include <linux/sched.h>
+#include <linux/mm.h>
+#include <linux/slab.h>
+#include <linux/file.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/gobohide.h>
+#include <linux/spinlock.h>
+#include <linux/proc_fs.h>
+#include <linux/stat.h>
+#include <linux/mount.h>
+#include <linux/path.h>
+#include <linux/xattr.h> /* overlayfs dependency */
+#include "overlayfs/overlayfs.h"
+#include "mount.h"
+
+#include <asm/uaccess.h>
+
+#define GOBOHIDE_INODE_EQUALS(p,i) \
+	(d_inode((p)->dentry)->i_ino == i || \
+	(d_inode((p)->dentry)->i_sb->s_magic == OVERLAYFS_SUPER_MAGIC))
+
+static LIST_HEAD(gobohide_inode_list);
+static int gobohide_inode_list_size = 0;
+static DEFINE_RWLOCK(gobohide_inode_rwlock);
+
+static int gobohide_resolve_path(struct hide *entry);
+static int gobohide_remove_unlocked(struct hide *entry, int remove);
+static int gobohide_inode_add(ino_t ino, const char *pathname);
+static int gobohide_inode_del(ino_t ino, const char *pathname);
+static int gobohide_count_hidden(struct gobohide_user __user *uhide);
+static int gobohide_get_hidden(int count, struct gobohide_user __user *uhide);
+static struct hide *gobohide_get_unlocked(ino_t i_ino, const char *filename,
+	int namelen, struct dentry *parent);
+
+/**
+ * gobohide_fs_ioctl - Handle fs-related ioctls
+ * @inode: inode number being added/removed from the hide-list
+ * @hide: structure containing the user's request
+ */
+int gobohide_fs_ioctl(struct inode *inode, unsigned long arg)
+{
+	struct gobohide_user __user *uhide = (struct gobohide_user __user *) arg;
+	struct gobohide_user hide;
+	struct user_namespace *ns = current_user_ns();
+	const struct cred *cred = current_cred();
+	kuid_t root_uid = make_kuid(ns, 0);
+	int error = 0;
+
+	if (copy_from_user(&hide, uhide, sizeof(struct gobohide_user)))
+		return -EFAULT;
+
+	/* We only support symbolic links and directories */
+	if (hide.inode && !S_ISREG(inode->i_mode) && !S_ISDIR(inode->i_mode))
+		return -EINVAL;
+
+	/* We only allow process with admin privileges
+	 * to use the fs-related gobo ioctls
+	 */
+	if (!uid_eq(cred->uid, root_uid) && !uid_eq(cred->euid, root_uid))
+		return -EPERM;
+
+	switch (hide.operation) {
+		case GOBOHIDE_HIDEINODE:
+			error = gobohide_inode_add(hide.inode, hide.pathname);
+			break;
+		case GOBOHIDE_UNHIDEINODE:
+			error = gobohide_inode_del(hide.inode, hide.pathname);
+			break;
+		case GOBOHIDE_COUNTHIDDEN:
+			error = gobohide_count_hidden(uhide);
+			break;
+		case GOBOHIDE_GETHIDDEN:
+			error = gobohide_get_hidden(hide.stats.hidden_inodes, uhide);
+			break;
+		default:
+			return -EOPNOTSUPP;
+	}
+
+	return error;
+}
+
+/**
+ * gobohide_resolve_path - Resolves the pathname of a given dentry
+ * @entry: structure holding the dentry structure and the destination buffer.
+ *
+ * After the structure has been used, its member 'page' must be returned with
+ * a call to free_page().
+ */
+static int gobohide_resolve_path(struct hide *entry)
+{
+	int len, ret;
+	struct file *filp = entry->filp;
+	struct path path = { .mnt = filp->f_path.mnt, .dentry = filp->f_path.dentry };
+
+	entry->page = __get_free_page(GFP_USER);
+	if (! entry->page)
+		return -ENOMEM;
+
+	entry->pathname = d_path(&path, (char *) entry->page, PAGE_SIZE);
+	if (IS_ERR(entry->pathname)) {
+		ret = PTR_ERR(entry->pathname);
+		entry->pathname = NULL;
+		free_page(entry->page);
+		entry->page = 0;
+		return ret;
+	}
+
+	len = PAGE_SIZE + entry->page - (unsigned long) entry->pathname;
+	return len < PATH_MAX ? len : PATH_MAX;
+}
+
+/**
+ * gobohide_count_hidden - Counts how many inodes are hidden.
+ * @hide: the structure containing a pointer to store the number of inodes
+ *        hidden.
+ */
+static int gobohide_count_hidden(struct gobohide_user __user *uhide)
+{
+	struct gobohide_stats __user *stats = &uhide->stats;
+	unsigned long flags;
+	int num, ret;
+
+	read_lock_irqsave(&gobohide_inode_rwlock, flags);
+	num = gobohide_inode_list_size;
+	read_unlock_irqrestore(&gobohide_inode_rwlock, flags);
+
+	ret = put_user(num, &stats->hidden_inodes);
+	if (ret)
+		return -EFAULT;
+
+	return 0;
+}
+
+/**
+ * gobohide_get_hidden - Get the currently hidden inodes. The uhide structure
+ *        has been already verified and validated by the caller, so we're safe
+ *        to invoke copy_to_user to members of that structure.
+ *
+ * @count: maximum number of entries to copy to the user-provided buffer.
+ * @hide: the structure containing a pointer to a previous-allocated array
+ *        of no more than @hide->stats.hidden_inodes elements of unsigned long.
+ *
+ * This array is filled with the directories being hidden.
+ */
+static int gobohide_get_hidden(int count, struct gobohide_user __user *uhide)
+{
+	struct gobohide_stats __user *stats = &uhide->stats;
+	struct hide *entry, *next, **array;
+	int i, copied_entries = 0, ret = 0;
+	unsigned long flags;
+	size_t len;
+
+	array = kmalloc(sizeof(struct hide *) * count, GFP_KERNEL);
+	if (! array)
+		return -ENOMEM;
+
+	/* Since copy_to_user may sleep data can't be copied with the lock held */
+	write_lock_irqsave(&gobohide_inode_rwlock, flags);
+	if (gobohide_inode_list_size) {
+		list_for_each_entry_safe(entry, next, &gobohide_inode_list, head) {
+			if (entry && (copied_entries < count)) {
+				/* Don't let the entry go away */
+				entry->refcount++;
+				array[copied_entries++] = entry;
+			} else
+				break;
+		}
+	}
+	write_unlock_irqrestore(&gobohide_inode_rwlock, flags);
+
+	/* Write the list of entries to user memory */
+	for (i=0; i<copied_entries; ++i) {
+		entry = array[i];
+		len = strlen(entry->pathname);
+		if (ret == 0 && copy_to_user(stats->hidden_list[i],
+			entry->pathname,len)) {
+			/* Don't break out so that all entries are put() back */
+			ret = -EFAULT;
+		}
+		gobohide_put(entry);
+	}
+
+	/* Update filled_size with the number of entries which were copied */
+	if (ret == 0 && put_user(copied_entries, &stats->filled_size))
+		ret = -EFAULT;
+
+	kfree(array);
+	return ret;
+}
+
+ino_t gobohide_lower_inode_nr(struct dentry *dentry)
+{
+	struct inode *inode = d_inode(dentry);
+	if (inode->i_sb && inode->i_sb->s_magic == OVERLAYFS_SUPER_MAGIC) {
+		struct dentry *lower = ovl_dentry_real(dentry);
+		if (lower && d_inode(lower))
+			inode = d_inode(lower);
+	}
+	return inode->i_ino;
+}
+
+/**
+ * gobohide_inode_add - Add the inode to the "must hide" list
+ * @ino: inode to be added
+ * @pathname: the pathname associated with @ino
+ */
+static int gobohide_inode_add(ino_t ino, const char *pathname)
+{
+	int len, ret;
+	struct path *path;
+	struct hide *entry, *old;
+	struct dentry *dentry;
+	unsigned long flags;
+
+	entry = kmalloc(sizeof(struct hide), GFP_KERNEL);
+	if (!entry)
+		return -ENOMEM;
+
+	entry->refcount = 1;
+	entry->unlinked = 0;
+
+	path = &entry->path;
+	ret = user_lpath(pathname, path);
+	if (ret)
+		goto out_free;
+	else if (! GOBOHIDE_INODE_EQUALS(path, ino)) {
+		ret = -ENOENT;
+		goto out_path_put;
+	}
+
+	entry->filp = dentry_open(path, O_NOFOLLOW|O_PATH, current_cred());
+	if (IS_ERR(entry->filp)) {
+		printk(KERN_INFO "dentry_open(%s) failed\n", pathname);
+		ret = PTR_ERR(entry->filp);
+		goto out_path_put;
+	}
+
+	len = gobohide_resolve_path(entry);
+	if (len < 0) {
+		printk(KERN_INFO "gobohide_resolve_path(%s) failed\n", pathname);
+		ret = len;
+		goto out_fput;
+	}
+
+	dentry = entry->filp->f_path.dentry;
+	if (! dentry) {
+		ret = -ENOENT;
+		goto out_free_page;
+	}
+
+	/* Get updated inode number */
+	entry->i_ino = gobohide_lower_inode_nr(dentry);
+
+	write_lock_irqsave(&gobohide_inode_rwlock, flags);
+	old = gobohide_get_unlocked(entry->i_ino, dentry->d_name.name,
+		dentry->d_name.len+1, dentry->d_parent);
+
+	if (old) {
+		write_unlock_irqrestore(&gobohide_inode_rwlock, flags);
+		ret = -EEXIST;
+		goto out_free_page;
+	}
+
+	gobohide_inode_list_size++;
+	list_add(&entry->head, &gobohide_inode_list);
+	write_unlock_irqrestore(&gobohide_inode_rwlock, flags);
+
+	return 0;
+
+out_free_page:
+	free_page(entry->page);
+out_fput:
+	fput(entry->filp);
+out_path_put:
+	path_put(path);
+out_free:
+	kfree(entry);
+	return ret;
+}
+
+/**
+ * gobohide_inode_del - Remove the inode from the "must hide" list
+ * @ino: inode to be removed
+ */
+static int gobohide_inode_del(ino_t ino, const char *pathname)
+{
+	int len, ret;
+	struct path *path;
+	unsigned long flags;
+	struct hide n, *entry, *aux;
+
+	path = &n.path;
+	ret = user_lpath(pathname, path);
+	if (ret)
+		return ret;
+	else if (! GOBOHIDE_INODE_EQUALS(path, ino)) {
+		ret = -ENOENT;
+		goto out_path_put;
+	}
+
+	n.filp = dentry_open(path, O_NOFOLLOW|O_PATH, current_cred());
+	if (IS_ERR(n.filp)) {
+		ret = PTR_ERR(n.filp);
+		goto out_path_put;
+	}
+
+	len = gobohide_resolve_path(&n);
+	if (len < 0) {
+		ret = len;
+		goto out_fput;
+	}
+
+	/* Get updated inode number */
+	ino = gobohide_lower_inode_nr(n.filp->f_path.dentry);
+
+	write_lock_irqsave(&gobohide_inode_rwlock, flags);
+	if (gobohide_inode_list_size) {
+		list_for_each_entry_safe(entry, aux, &gobohide_inode_list, head) {
+			struct file *filp = entry->filp;
+			struct dentry *filp_dentry = filp->f_path.dentry;
+			struct mount *mnt = real_mount(filp->f_path.mnt)->mnt_parent;
+			struct dentry *mnt_dentry = mnt->mnt_mountpoint;
+			ino_t mnt_ino = mnt_dentry->d_inode->i_ino;
+
+			if ((entry->i_ino == ino && path->dentry->d_sb == filp_dentry->d_sb) ||
+				(mnt_ino == ino && path->dentry->d_sb == mnt_dentry->d_sb)) {
+				gobohide_remove_unlocked(entry, 1);
+				break;
+			}
+		}
+	}
+	write_unlock_irqrestore(&gobohide_inode_rwlock, flags);
+
+	free_page(n.page);
+	ret = 0;
+
+out_fput:
+	fput(n.filp);
+out_path_put:
+	path_put(path);
+	return ret;
+}
+
+/**
+ * gobohide_remove - Effectively removes the inode from the inode_list.
+ * @hide: struct hide to be removed
+ */
+int gobohide_remove(struct hide *entry)
+{
+	unsigned long flags;
+	int ret;
+
+	write_lock_irqsave(&gobohide_inode_rwlock, flags);
+	ret = gobohide_remove_unlocked(entry, 1);
+	write_unlock_irqrestore(&gobohide_inode_rwlock, flags);
+
+	return ret;
+}
+
+static int gobohide_remove_unlocked(struct hide *entry, int remove)
+{
+	if (remove && ! entry->unlinked) {
+		/* Remove from the linked list */
+		entry->unlinked = true;
+		list_del(&entry->head);
+		gobohide_inode_list_size--;
+	}
+	if (--entry->refcount == 0) {
+		free_page(entry->page);
+		fput(entry->filp);
+		path_put(&entry->path);
+		kfree(entry);
+	}
+	return 0;
+}
+
+/**
+ * gobohide_get - Get the struct hide associated to the given inode. The inode
+ *  is verified to exist in the "must hide" list through the comparison of the
+ *  inode number and the superblock.
+ *
+ * @ino: inode being readdir'd
+ * @filename: inode's filename
+ * @namelen: inodes's filename length in bytes
+ * @parent: the parent dentry for the given inode.
+ *
+ * If the inode number is in the inode_list, returns a pointer to its entry
+ * in the inode_list or NULL if it isn't there. The returned entry must be
+ * released with gobohide_put().
+ */
+struct hide *gobohide_get(ino_t ino, const char *filename, int namelen,
+	struct dentry *parent)
+{
+	unsigned long flags;
+	struct hide *entry;
+
+	write_lock_irqsave(&gobohide_inode_rwlock, flags);
+	entry = gobohide_get_unlocked(ino, filename, namelen, parent);
+	write_unlock_irqrestore(&gobohide_inode_rwlock, flags);
+
+	return entry;
+}
+
+static struct hide *gobohide_get_unlocked(ino_t ino, const char *filename,
+	int namelen, struct dentry *parent)
+{
+	struct hide *entry = NULL;
+
+	if (! ino || ! gobohide_inode_list_size)
+		return NULL;
+
+	list_for_each_entry(entry, &gobohide_inode_list, head) {
+		struct file *filp = entry->filp;
+		struct dentry *filp_dentry = filp->f_path.dentry;
+		struct mount *mnt = real_mount(filp->f_path.mnt);
+		struct dentry *mnt_dentry = mnt->mnt_mountpoint;
+		ino_t mnt_ino = mnt_dentry->d_inode->i_ino;
+
+		if ((entry->i_ino == ino && parent->d_sb == filp_dentry->d_sb) || 
+			(mnt_ino == ino && parent->d_sb == mnt_dentry->d_sb)) {
+			/* Increment the reference count and return the object */
+			entry->refcount++;
+			return entry;
+		}
+	}
+
+	return NULL;
+}
+
+/*
+ * Return an entry obtained from the gobohide_inode_list with gobohide_get().
+ * @param entry Entry obtained from gobohide_get().
+ */
+int gobohide_put(struct hide *entry)
+{
+	unsigned long flags;
+	int ret = -EINVAL;
+
+	if (entry) {
+		write_lock_irqsave(&gobohide_inode_rwlock, flags);
+		ret = gobohide_remove_unlocked(entry, 0);
+		write_unlock_irqrestore(&gobohide_inode_rwlock, flags);
+	}
+
+	return ret;
+}
+
+EXPORT_SYMBOL(gobohide_get);
+EXPORT_SYMBOL(gobohide_put);
+EXPORT_SYMBOL(gobohide_remove);
+EXPORT_SYMBOL(gobohide_fs_ioctl);
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/ioctl.c linux-4.7/fs/ioctl.c
--- linux-4.7.orig/fs/ioctl.c	2016-07-24 19:23:50.000000000 +0000
+++ linux-4.7/fs/ioctl.c	2016-08-20 20:10:15.776599428 +0000
@@ -15,6 +15,7 @@
 #include <linux/writeback.h>
 #include <linux/buffer_head.h>
 #include <linux/falloc.h>
+#include <linux/gobohide.h>
 #include "internal.h"
 
 #include <asm/ioctls.h>
@@ -667,6 +668,10 @@ int do_vfs_ioctl(struct file *filp, unsi
 	case FIDEDUPERANGE:
 		return ioctl_file_dedupe_range(filp, argp);
 
+	case FIGOBOHIDE:
+		error = arg ? gobohide_fs_ioctl(inode, arg) : -EINVAL;
+		break;
+
 	default:
 		if (S_ISREG(inode->i_mode))
 			error = file_ioctl(filp, cmd, arg);
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/Kconfig linux-4.7/fs/Kconfig
--- linux-4.7.orig/fs/Kconfig	2016-07-24 19:23:50.000000000 +0000
+++ linux-4.7/fs/Kconfig	2016-08-20 20:10:15.772599428 +0000
@@ -111,6 +111,16 @@ source "fs/udf/Kconfig"
 endmenu
 endif # BLOCK
 
+config GOBOHIDE_FS
+	bool "GoboHide support on file systems"
+	default y
+	help
+	  GoboHide is a general interface for providing real hidden files in
+	  a filesystem. GoboHide supports all filesystems sitting on the VFS,
+	  such as EXT3, SquashFS and JFFS2.
+	  To use it, see the documentation of the gobohide userspace tool at
+	  <http://gobolinux.org/?page=doc/articles/gobohide>.
+
 if BLOCK
 menu "DOS/FAT/NT Filesystems"
 
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/Makefile linux-4.7/fs/Makefile
--- linux-4.7.orig/fs/Makefile	2016-07-24 19:23:50.000000000 +0000
+++ linux-4.7/fs/Makefile	2016-08-20 20:10:15.772599428 +0000
@@ -47,6 +47,7 @@ obj-$(CONFIG_FS_POSIX_ACL)	+= posix_acl.
 obj-$(CONFIG_NFS_COMMON)	+= nfs_common/
 obj-$(CONFIG_COREDUMP)		+= coredump.o
 obj-$(CONFIG_SYSCTL)		+= drop_caches.o
+obj-$(CONFIG_GOBOHIDE_FS)	+= gobohide.o
 
 obj-$(CONFIG_FHANDLE)		+= fhandle.o
 
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/namei.c linux-4.7/fs/namei.c
--- linux-4.7.orig/fs/namei.c	2016-07-24 19:23:50.000000000 +0000
+++ linux-4.7/fs/namei.c	2016-09-19 00:07:55.791189096 +0000
@@ -35,6 +35,7 @@
 #include <linux/fs_struct.h>
 #include <linux/posix_acl.h>
 #include <linux/hash.h>
+#include <linux/gobohide.h>
 #include <linux/bitops.h>
 #include <asm/uaccess.h>
 
@@ -3800,6 +3801,7 @@ SYSCALL_DEFINE2(mkdir, const char __user
 
 int vfs_rmdir(struct inode *dir, struct dentry *dentry)
 {
+	struct hide *hidden = NULL;
 	int error = may_delete(dir, dentry, 1);
 
 	if (error)
@@ -3831,8 +3833,13 @@ int vfs_rmdir(struct inode *dir, struct
 out:
 	inode_unlock(dentry->d_inode);
 	dput(dentry);
-	if (!error)
+	if (!error) {
+		if (hidden)
+			gobohide_remove(hidden);
 		d_delete(dentry);
+	}
+	if (hidden)
+		gobohide_put(hidden);
 	return error;
 }
 EXPORT_SYMBOL(vfs_rmdir);
@@ -3921,6 +3928,7 @@ SYSCALL_DEFINE1(rmdir, const char __user
  */
 int vfs_unlink(struct inode *dir, struct dentry *dentry, struct inode **delegated_inode)
 {
+	struct hide *hidden = NULL;
 	struct inode *target = dentry->d_inode;
 	int error = may_delete(dir, dentry, 0);
 
@@ -3930,6 +3938,13 @@ int vfs_unlink(struct inode *dir, struct
 	if (!dir->i_op->unlink)
 		return -EPERM;
 
+	if (dentry->d_inode) {
+		ino_t ino = gobohide_lower_inode_nr(dentry);
+		if (ino)
+			hidden = gobohide_get(ino, dentry->d_name.name,
+				dentry->d_name.len, dentry->d_parent);
+	}
+
 	inode_lock(target);
 	if (is_local_mountpoint(dentry))
 		error = -EBUSY;
@@ -3951,10 +3966,14 @@ out:
 
 	/* We don't d_delete() NFS sillyrenamed files--they still exist. */
 	if (!error && !(dentry->d_flags & DCACHE_NFSFS_RENAMED)) {
+		if (hidden)
+			gobohide_remove(hidden);
 		fsnotify_link_count(target);
 		d_delete(dentry);
 	}
 
+	if (hidden)
+		gobohide_put(hidden);
 	return error;
 }
 EXPORT_SYMBOL(vfs_unlink);
@@ -4056,6 +4075,7 @@ SYSCALL_DEFINE1(unlink, const char __use
 
 int vfs_symlink(struct inode *dir, struct dentry *dentry, const char *oldname)
 {
+	struct hide *hidden = NULL;
 	int error = may_create(dir, dentry);
 
 	if (error)
@@ -4064,6 +4084,13 @@ int vfs_symlink(struct inode *dir, struc
 	if (!dir->i_op->symlink)
 		return -EPERM;
 
+	if (dentry->d_inode) {
+		ino_t ino = gobohide_lower_inode_nr(dentry);
+		if (ino)
+			hidden = gobohide_get(ino, dentry->d_name.name,
+				dentry->d_name.len, dentry->d_parent);
+	}
+
 	error = security_inode_symlink(dir, dentry, oldname);
 	if (error)
 		return error;
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/overlayfs/super.c \
linux-4.7/fs/overlayfs/super.c
--- linux-4.7.orig/fs/overlayfs/super.c	2016-07-24 19:23:50.000000000 +0000
+++ linux-4.7/fs/overlayfs/super.c	2016-09-19 00:20:44.187174029 +0000
@@ -125,6 +125,7 @@ struct dentry *ovl_dentry_upper(struct d
 
 	return ovl_upperdentry_dereference(oe);
 }
+EXPORT_SYMBOL(ovl_dentry_upper);
 
 struct dentry *ovl_dentry_lower(struct dentry *dentry)
 {
@@ -132,6 +133,7 @@ struct dentry *ovl_dentry_lower(struct d
 
 	return __ovl_dentry_lower(oe);
 }
+EXPORT_SYMBOL(ovl_dentry_lower);
 
 struct dentry *ovl_dentry_real(struct dentry *dentry)
 {
@@ -144,6 +146,7 @@ struct dentry *ovl_dentry_real(struct de
 
 	return realdentry;
 }
+EXPORT_SYMBOL(ovl_dentry_real);
 
 struct dentry *ovl_entry_real(struct ovl_entry *oe, bool *is_upper)
 {
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/fs/readdir.c linux-4.7/fs/readdir.c
--- linux-4.7.orig/fs/readdir.c	2016-07-24 19:23:50.000000000 +0000
+++ linux-4.7/fs/readdir.c	2016-08-20 20:10:15.776599428 +0000
@@ -18,6 +18,7 @@
 #include <linux/security.h>
 #include <linux/syscalls.h>
 #include <linux/unistd.h>
+#include <linux/gobohide.h>
 
 #include <asm/uaccess.h>
 
@@ -85,6 +86,7 @@ struct readdir_callback {
 	struct dir_context ctx;
 	struct old_linux_dirent __user * dirent;
 	int result;
+	struct dentry *dentry;
 };
 
 static int fillonedir(struct dir_context *ctx, const char *name, int namlen,
@@ -133,6 +135,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned in
 	if (!f.file)
 		return -EBADF;
 
+	buf.dentry = f.file->f_path.dentry;
 	error = iterate_dir(f.file, &buf.ctx);
 	if (buf.result)
 		error = buf.result;
@@ -160,6 +163,7 @@ struct getdents_callback {
 	struct linux_dirent __user * previous;
 	int count;
 	int error;
+	struct dentry *dentry;
 };
 
 static int filldir(struct dir_context *ctx, const char *name, int namlen,
@@ -169,6 +173,7 @@ static int filldir(struct dir_context *c
 	struct getdents_callback *buf =
 		container_of(ctx, struct getdents_callback, ctx);
 	unsigned long d_ino;
+	struct hide *hidden;
 	int reclen = ALIGN(offsetof(struct linux_dirent, d_name) + namlen + 2,
 		sizeof(long));
 
@@ -182,12 +187,22 @@ static int filldir(struct dir_context *c
 	}
 	dirent = buf->previous;
 	if (dirent) {
+		hidden = gobohide_get(d_ino, name, namlen, buf->dentry);
+		if (hidden) {
+			gobohide_put(hidden);
+			return 0;
+		}
 		if (signal_pending(current))
 			return -EINTR;
 		if (__put_user(offset, &dirent->d_off))
 			goto efault;
 	}
 	dirent = buf->current_dir;
+	hidden = gobohide_get(d_ino, name, namlen, buf->dentry);
+	if (hidden) {
+		gobohide_put(hidden);
+		return 0;
+	}
 	if (__put_user(d_ino, &dirent->d_ino))
 		goto efault;
 	if (__put_user(reclen, &dirent->d_reclen))
@@ -227,6 +242,7 @@ SYSCALL_DEFINE3(getdents, unsigned int,
 	if (!f.file)
 		return -EBADF;
 
+	buf.dentry = f.file->f_path.dentry;
 	error = iterate_dir(f.file, &buf.ctx);
 	if (error >= 0)
 		error = buf.error;
@@ -247,12 +263,14 @@ struct getdents_callback64 {
 	struct linux_dirent64 __user * previous;
 	int count;
 	int error;
+	struct dentry *dentry;
 };
 
 static int filldir64(struct dir_context *ctx, const char *name, int namlen,
 		     loff_t offset, u64 ino, unsigned int d_type)
 {
 	struct linux_dirent64 __user *dirent;
+	struct hide *hidden;
 	struct getdents_callback64 *buf =
 		container_of(ctx, struct getdents_callback64, ctx);
 	int reclen = ALIGN(offsetof(struct linux_dirent64, d_name) + namlen + 1,
@@ -263,12 +281,22 @@ static int filldir64(struct dir_context
 		return -EINVAL;
 	dirent = buf->previous;
 	if (dirent) {
+		hidden = gobohide_get(ino, name, namlen, buf->dentry);
+		if (hidden) {
+			gobohide_put(hidden);
+			return 0;
+		}
 		if (signal_pending(current))
 			return -EINTR;
 		if (__put_user(offset, &dirent->d_off))
 			goto efault;
 	}
 	dirent = buf->current_dir;
+	hidden = gobohide_get(ino, name, namlen, buf->dentry);
+	if (hidden) {
+		gobohide_put(hidden);
+		return 0;
+	}
 	if (__put_user(ino, &dirent->d_ino))
 		goto efault;
 	if (__put_user(0, &dirent->d_off))
@@ -310,6 +338,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int
 	if (!f.file)
 		return -EBADF;
 
+	buf.dentry = f.file->f_path.dentry;
 	error = iterate_dir(f.file, &buf.ctx);
 	if (error >= 0)
 		error = buf.error;
diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/include/linux/gobohide.h \
linux-4.7/include/linux/gobohide.h
--- linux-4.7.orig/include/linux/gobohide.h
+++ linux-4.7/include/linux/gobohide.h
@@ -0,0 +1,58 @@
+#ifndef _LINUX_GOBOHIDE_H
+#define _LINUX_GOBOHIDE_H
+
+#include <linux/fs.h>
+#include <linux/dcache.h>
+
+/* Gobohide internal ioctls */
+
+#define GOBOHIDE_HIDEINODE    0x0000001 /* Hide a given inode number */
+#define GOBOHIDE_UNHIDEINODE  0x0000002 /* Unhide a given inode number */
+#define GOBOHIDE_COUNTHIDDEN  0x0000003 /* Get the number of inodes hidden */
+#define GOBOHIDE_GETHIDDEN    0x0000004 /* Get the inodes hidden */
+
+struct hide {
+   ino_t i_ino;            /* shortcut to inode number */
+   struct file *filp;      /* used to recover the inode's pathname */
+   struct path path;       /* stores the path after a call to user_lpath */
+   char *pathname;         /* a fresh cache of the inode's pathname */
+   unsigned long page;     /* page on which pathname has been copied to */
+   unsigned long refcount; /* number of reference counts to this object */
+   int unlinked;           /* has the structure been unlinked yet? */
+   struct list_head head;  /* a simple doubly linked list */
+};
+
+struct gobohide_stats {
+   int hidden_inodes;      /* how many inodes we're hiding */
+   int filled_size;        /* how many inodes we filled in hidden_list */
+   char **hidden_list;     /* the hidden list */
+};
+
+/* Structure provided by the user on the ioctl to hide or unhide an entry */
+struct gobohide_user {
+   char operation;               /* the operation to be performed */
+   ino_t inode;                  /* the inode number */
+   const char *pathname;         /* the pathname being submitted */
+   char symlink;                 /* is inode a symlink? */
+   struct gobohide_stats stats;  /* holds statistics */
+};
+
+#ifdef CONFIG_GOBOHIDE_FS
+
+int  gobohide_fs_ioctl(struct inode *inode, unsigned long arg);
+ino_t gobohide_lower_inode_nr(struct dentry *dentry);
+struct hide *gobohide_get(ino_t ino, const char *filename,
+	int namelen, struct dentry *parent);
+int  gobohide_put(struct hide *entry);
+int  gobohide_remove(struct hide *hide);
+
+#else
+
+#define gobohide_fs_ioctl(inode, arg) 0
+#define gobohide_lower_inode_nr(dentry) 0
+#define gobohide_get(ino, filename, namelen, parent) NULL
+#define gobohide_put(entry) 0
+#define gobohide_remove(hide) 0
+
+#endif  /* CONFIG_GOBOHIDE_FS */
+#endif  /* _LINUX_GOBOHIDE_H */
diff diff -X linux-4.7/Documentation/dontdiff -Nurp linux-4.7.orig/include/uapi/linux/fs.h \
linux-4.7/include/uapi/linux/fs.h
--- linux-4.7.orig/include/uapi/linux/fs.h
+++ linux-4.7/include/uapi/linux/fs.h
@@ -232,6 +232,7 @@ struct fsxattr {
 #define FICLONE		_IOW(0x94, 9, int)
 #define FICLONERANGE	_IOW(0x94, 13, struct file_clone_range)
 #define FIDEDUPERANGE	_IOWR(0x94, 54, struct file_dedupe_range)
+#define FIGOBOHIDE  _IOW(0x00, 0x22, size_t) /* gobohide-fs ioctl */
 
 #define	FS_IOC_GETFLAGS			_IOR('f', 1, long)
 #define	FS_IOC_SETFLAGS			_IOW('f', 2, long)
Linux 4.7.0-r4 1269  82585 Luca...
The Linux Kernel.
Linux 3.13.3-r1 2149  252629 Luca...
The Linux Kernel.
Linux 3.12.6-r1 2209  238949 Luca...
The Linux Kernel.
Linux 3.9.4-r2 2404  70048 Luca...
The Linux Kernel.
Linux 3.7.1-r2 2577  67579 Luca...
The Linux Kernel.
Linux 3.5.0-r1 2728  124391 Luca...
The Linux Kernel.
Linux 3.4.4-r1 2728  124348 Luca...
The Linux Kernel.
Linux 3.3.6-r1 2728  124410 Luca...
The Linux Kernel.
Linux 3.2.12-r2 2856  124345 Luca...
The Linux Kernel.
Linux 3.2.7-r1 2886  123550 Mich...
The Linux Kernel.
Linux 3.1.1-r1 2991  122907 Mich...
The Linux Kernel.
Linux 3.0.4-r4 3052  122754 Luca...
The Linux Kernel.
Linux 2.6.36.3-r1 3275  116087 Diog...
The Linux Kernel.
Linux 2.6.32.3-r1 3653  117990 Luca...
The Linux Kernel.
Linux 2.6.32-r1 3694  117751 Luca...
The Linux Kernel.
Linux 2.6.31.6-r3 3699  126499 Luca...
The Linux Kernel.
Linux 2.6.30.5-r1 3778  166102 Jona...
The Linux Kernel.
Linux 2.6.29.1-r1 3921  117500 Luca...
The Linux Kernel.
Linux 2.6.28.7-r1 3977  115518 Giam...
The Linux Kernel.
Linux 2.6.28.1-r1 3977  115487 Giam...
The Linux Kernel.
Linux 2.6.28-r1 3977  116681 Mich...
The Linux Kernel.
Linux 2.6.27.8-r1 3977  134160 Giam...
The Linux Kernel.
Linux 2.6.27.4-r3 3977  149529 Luca...
The Linux Kernel.
Linux 2.6.25.17-r1 3977  172834 Giam...
The Linux Kernel.
Linux 2.6.25.16-r1 3977  166500 Giam...
The Linux Kernel.
Linux 2.6.25.10-r2 3977  165320 Giam...
The Linux Kernel.
Linux 2.6.25.7-r1 3977  157294 Giam...
The Linux Kernel.
Linux 2.6.25.4-r1 3977  133017 Hopp...
The Linux Kernel.
Linux 2.6.25-r1 3977  133216 Luca...
The Linux Kernel.
Linux 2.6.24.4-r5 3977  150733
The Linux Kernel.
Linux 2.6.24.3-r5 3977  150221 Luca...
The Linux Kernel.
Linux 2.6.24.2-r3 3977  146488 Giam...
The Linux Kernel.
Linux 2.6.24.1-r1 3977  146454 Giam...
The Linux Kernel.
Linux 2.6.24-r1 3977  146428 Luca...
The Linux Kernel.
Linux 2.6.23.8-r4 3977  155842 Luca...
The Linux Kernel.
Linux 2.6.22.7-r4 3977  114727 Luca...
The Linux Kernel.
Linux 2.6.22.1-r1 3977  121391 Luca...
The Linux Kernel.
Linux 2.6.21.1-r3 3977  118854 Luca...
The Linux Kernel.
Linux 2.6.20.7-r1 3977  117945 Luca...
The Linux Kernel.
Linux 2.6.20.4-r3 3977  151150 Luca...
The Linux Kernel.
Linux 2.6.20-r1 3977  106429 Luca...
The Linux Kernel.
Linux 2.6.18.3-r2 3977  111124 Luca...
The Linux Kernel.
Linux 2.6.17.11-r1 3977  164053 Luca...
The Linux Kernel.
Linux 2.6.17.3-r1 3977  165067 Luca...
The Linux Kernel.
Linux 2.6.16.20-r1 3977  133625 Luca...
The Linux Kernel.
Linux 2.6.16.14-r1 3977  168270 Luca...
The Linux Kernel.
Linux 2.6.15.5-r1 3977  224686 Jona...
The Linux Kernel.
Linux 2.6.15.2-r1 3977  177165 Carl...
The Linux Kernel.
Linux 2.6.15.1-r1 3977  149219 Jona...
The Linux Kernel.
Linux 2.6.15-r1 3977  149214 Luca...
The Linux Kernel.
Linux 2.6.14.4-r1 3977  150166 Jona...
The Linux Kernel.
Linux 2.6.14.3-r1 3977  150060 Jona...
The Linux Kernel.
Linux 2.6.14.2-r1 3977  149791 Carl...
The Linux Kernel.
Linux 2.6.13.4-r1 3977  149559 Luca...
The Linux Kernel.
Linux 2.6.13.2-r1 3977  56611 Jona...
The Linux Kernel.
Linux 2.6.13.1-r1 3977  56378 Luca...
The Linux Kernel.
Linux 2.6.12.2-r1 3977  50355 Luca...
The Linux Kernel.
Linux 2.6.11.9-r1 3977  98969 Luca...
The Linux Kernel.
Linux 2.6.11.8-r1 3977  109424 Jona...
The Linux Kernel.
Linux 2.6.11-r1 3977  99032 Luca...
The Linux Kernel.
Linux 2.6.10-r1 3977  65969 Luca...
The Linux Kernel.
Linux 2.6.9-r1 3977  278461 Luca...
The Linux Kernel.
Linux 2.6.8.1-r1 3977  35576 Luca...
The Linux Kernel.
Linux 2.6.7-r1 3977  22610 Luca...
The Linux Kernel.
Linux 2.6.6-r1 3977  21958 Luca...
The Linux Kernel.
Linux 2.4.26-r1 3977  22359 Luca...
The Linux Kernel.