24 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public licence as published by
    the free software foundation either version 2 of the licence or at
    your option any later version

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 114 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190520170857.552531963@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

04 Apr, 2018

1 commit

  • Add some tracepoints to fscache:

    (*) fscache_cookie - Tracks a cookie's usage count.

    (*) fscache_netfs - Logs registration of a network filesystem, including
    the pointer to the cookie allocated.

    (*) fscache_acquire - Logs cookie acquisition.

    (*) fscache_relinquish - Logs cookie relinquishment.

    (*) fscache_enable - Logs enablement of a cookie.

    (*) fscache_disable - Logs disablement of a cookie.

    (*) fscache_osm - Tracks execution of states in the object state machine.

    and cachefiles:

    (*) cachefiles_ref - Tracks a cachefiles object's usage count.

    (*) cachefiles_lookup - Logs result of lookup_one_len().

    (*) cachefiles_mkdir - Logs result of vfs_mkdir().

    (*) cachefiles_create - Logs result of vfs_create().

    (*) cachefiles_unlink - Logs calls to vfs_unlink().

    (*) cachefiles_rename - Logs calls to vfs_rename().

    (*) cachefiles_mark_active - Logs an object becoming active.

    (*) cachefiles_wait_active - Logs a wait for an old object to be
    destroyed.

    (*) cachefiles_mark_inactive - Logs an object becoming inactive.

    (*) cachefiles_mark_buried - Logs the burial of an object.

    Signed-off-by: David Howells

    David Howells
     

20 Jun, 2017

2 commits

  • The wait_bit*() types and APIs are mixed into wait.h, but they
    are a pretty orthogonal extension of wait-queues.

    Furthermore, only about 50 kernel files use these APIs, while
    over 1000 use the regular wait-queue functionality.

    So clean up the main wait.h by moving the wait-bit functionality
    out of it, into a separate .h and .c file:

    include/linux/wait_bit.h for types and APIs
    kernel/sched/wait_bit.c for the implementation

    Update all header dependencies.

    This reduces the size of wait.h rather significantly, by about 30%.

    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     
  • Rename:

    wait_queue_t => wait_queue_entry_t

    'wait_queue_t' was always a slight misnomer: its name implies that it's a "queue",
    but in reality it's a queue *entry*. The 'real' queue is the wait queue head,
    which had to carry the name.

    Start sorting this out by renaming it to 'wait_queue_entry_t'.

    This also allows the real structure name 'struct __wait_queue' to
    lose its double underscore and become 'struct wait_queue_entry',
    which is the more canonical nomenclature for such data types.

    Cc: Linus Torvalds
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Cc: linux-kernel@vger.kernel.org
    Signed-off-by: Ingo Molnar

    Ingo Molnar
     

02 Mar, 2017

1 commit


28 Sep, 2016

1 commit

  • An NULL-pointer dereference happens in cachefiles_mark_object_inactive()
    when it tries to read i_blocks so that it can tell the cachefilesd daemon
    how much space it's making available.

    The problem is that cachefiles_drop_object() calls
    cachefiles_mark_object_inactive() after calling cachefiles_delete_object()
    because the object being marked active staves off attempts to (re-)use the
    file at that filename until after it has been deleted. This means that
    d_inode is NULL by the time we come to try to access it.

    To fix the problem, have the caller of cachefiles_mark_object_inactive()
    supply the number of blocks freed up.

    Without this, the following oops may occur:

    BUG: unable to handle kernel NULL pointer dereference at 0000000000000098
    IP: [] cachefiles_mark_object_inactive+0x61/0xb0 [cachefiles]
    ...
    CPU: 11 PID: 527 Comm: kworker/u64:4 Tainted: G I ------------ 3.10.0-470.el7.x86_64 #1
    Hardware name: Hewlett-Packard HP Z600 Workstation/0B54h, BIOS 786G4 v03.19 03/11/2011
    Workqueue: fscache_object fscache_object_work_func [fscache]
    task: ffff880035edaf10 ti: ffff8800b77c0000 task.ti: ffff8800b77c0000
    RIP: 0010:[] cachefiles_mark_object_inactive+0x61/0xb0 [cachefiles]
    RSP: 0018:ffff8800b77c3d70 EFLAGS: 00010246
    RAX: 0000000000000000 RBX: ffff8800bf6cc400 RCX: 0000000000000034
    RDX: 0000000000000000 RSI: ffff880090ffc710 RDI: ffff8800bf761ef8
    RBP: ffff8800b77c3d88 R08: 2000000000000000 R09: 0090ffc710000000
    R10: ff51005d2ff1c400 R11: 0000000000000000 R12: ffff880090ffc600
    R13: ffff8800bf6cc520 R14: ffff8800bf6cc400 R15: ffff8800bf6cc498
    FS: 0000000000000000(0000) GS:ffff8800bb8c0000(0000) knlGS:0000000000000000
    CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
    CR2: 0000000000000098 CR3: 00000000019ba000 CR4: 00000000000007e0
    DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
    DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
    Stack:
    ffff880090ffc600 ffff8800bf6cc400 ffff8800867df140 ffff8800b77c3db0
    ffffffffa06c48cb ffff880090ffc600 ffff880090ffc180 ffff880090ffc658
    ffff8800b77c3df0 ffffffffa085d846 ffff8800a96b8150 ffff880090ffc600
    Call Trace:
    [] cachefiles_drop_object+0x6b/0xf0 [cachefiles]
    [] fscache_drop_object+0xd6/0x1e0 [fscache]
    [] fscache_object_work_func+0xa5/0x200 [fscache]
    [] process_one_work+0x17b/0x470
    [] worker_thread+0x126/0x410
    [] ? rescuer_thread+0x460/0x460
    [] kthread+0xcf/0xe0
    [] ? kthread_create_on_node+0x140/0x140
    [] ret_from_fork+0x58/0x90
    [] ? kthread_create_on_node+0x140/0x140

    The oopsing code shows:

    callq 0xffffffff810af6a0
    mov 0xf8(%r12),%rax
    mov 0x30(%rax),%rax
    mov 0x98(%rax),%rax dentry)->i_blocks

    Fixes: a5b3a80b899bda0f456f1246c4c5a1191ea01519 (CacheFiles: Provide read-and-reset release counters for cachefilesd)
    Reported-by: Jianhong Yin
    Signed-off-by: David Howells
    Reviewed-by: Jeff Layton
    Reviewed-by: Steve Dickson
    cc: stable@vger.kernel.org
    Signed-off-by: Al Viro

    David Howells
     

02 Feb, 2016

1 commit

  • Provide read-and-reset objects- and blocks-released counters for cachefilesd
    to use to work out whether there's anything new that can be culled.

    One of the problems cachefilesd has is that if all the objects in the cache
    are pinned by inodes lying dormant in the kernel inode cache, there isn't
    anything for it to cull. In such a case, it just spins around walking the
    filesystem tree and scanning for something to cull. This eats up a lot of
    CPU time.

    By telling cachefilesd if there have been any releases, the daemon can
    sleep until there is the possibility of something to do.

    cachefilesd finds this information by the following means:

    (1) When the control fd is read, the kernel presents a list of values of
    interest. "freleased=N" and "breleased=N" are added to this list to
    indicate the number of files released and number of blocks released
    since the last read call. At this point the counters are reset.

    (2) POLLIN is signalled if the number of files released becomes greater
    than 0.

    Note that by 'released' it just means that the kernel has released its
    interest in those files for the moment, not necessarily that the files
    should be deleted from the cache.

    Signed-off-by: David Howells
    Reviewed-by: Steve Dickson
    Signed-off-by: Al Viro

    David Howells
     

07 Nov, 2015

1 commit

  • __GFP_WAIT was used to signal that the caller was in atomic context and
    could not sleep. Now it is possible to distinguish between true atomic
    context and callers that are not willing to sleep. The latter should
    clear __GFP_DIRECT_RECLAIM so kswapd will still wake. As clearing
    __GFP_WAIT behaves differently, there is a risk that people will clear the
    wrong flags. This patch renames __GFP_WAIT to __GFP_RECLAIM to clearly
    indicate what it does -- setting it allows all reclaim activity, clearing
    them prevents it.

    [akpm@linux-foundation.org: fix build]
    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Mel Gorman
    Acked-by: Michal Hocko
    Acked-by: Vlastimil Babka
    Acked-by: Johannes Weiner
    Cc: Christoph Lameter
    Acked-by: David Rientjes
    Cc: Vitaly Wool
    Cc: Rik van Riel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mel Gorman
     

24 Feb, 2015

1 commit


26 Sep, 2014

1 commit


07 Jun, 2014

2 commits


06 Sep, 2013

1 commit


21 Dec, 2012

1 commit


13 Aug, 2010

1 commit


12 May, 2010

1 commit

  • Fix an occasional EIO returned by a call to vfs_unlink():

    [ 4868.465413] CacheFiles: I/O Error: Unlink failed
    [ 4868.465444] FS-Cache: Cache cachefiles stopped due to I/O error
    [ 4947.320011] CacheFiles: File cache on md3 unregistering
    [ 4947.320041] FS-Cache: Withdrawing cache "mycache"
    [ 5127.348683] FS-Cache: Cache "mycache" added (type cachefiles)
    [ 5127.348716] CacheFiles: File cache on md3 registered
    [ 7076.871081] CacheFiles: I/O Error: Unlink failed
    [ 7076.871130] FS-Cache: Cache cachefiles stopped due to I/O error
    [ 7116.780891] CacheFiles: File cache on md3 unregistering
    [ 7116.780937] FS-Cache: Withdrawing cache "mycache"
    [ 7296.813394] FS-Cache: Cache "mycache" added (type cachefiles)
    [ 7296.813432] CacheFiles: File cache on md3 registered

    What happens is this:

    (1) A cached NFS file is seen to have become out of date, so NFS retires the
    object and immediately acquires a new object with the same key.

    (2) Retirement of the old object is done asynchronously - so the lookup/create
    to generate the new object may be done first.

    This can be a problem as the old object and the new object must exist at
    the same point in the backing filesystem (i.e. they must have the same
    pathname).

    (3) The lookup for the new object sees that a backing file already exists,
    checks to see whether it is valid and sees that it isn't. It then deletes
    that file and creates a new one on disk.

    (4) The retirement phase for the old file is then performed. It tries to
    delete the dentry it has, but ext4_unlink() returns -EIO because the inode
    attached to that dentry no longer matches the inode number associated with
    the filename in the parent directory.

    The trace below shows this quite well.

    [md5sum] ==> __fscache_relinquish_cookie(ffff88002d12fb58{NFS.fh,ffff88002ce62100},1)
    [md5sum] ==> __fscache_acquire_cookie({NFS.server},{NFS.fh},ffff88002ce62100)

    NFS has retired the old cookie and asked for a new one.

    [kslowd] ==> fscache_object_state_machine({OBJ52,OBJECT_ACTIVE,24})
    [kslowd] OBJECT_DYING]
    [kslowd] ==> fscache_object_state_machine({OBJ53,OBJECT_INIT,0})
    [kslowd] OBJECT_LOOKING_UP]
    [kslowd] ==> fscache_object_state_machine({OBJ52,OBJECT_DYING,24})
    [kslowd] OBJECT_RECYCLING]

    The old object (OBJ52) is going through the terminal states to get rid of it,
    whilst the new object - (OBJ53) - is coming into being.

    [kslowd] ==> fscache_object_state_machine({OBJ53,OBJECT_LOOKING_UP,0})
    [kslowd] ==> cachefiles_walk_to_object({ffff88003029d8b8},OBJ53,@68,)
    [kslowd] lookup '@68'
    [kslowd] next -> ffff88002ce41bd0 positive
    [kslowd] advance
    [kslowd] lookup 'Es0g00og0_Nd_XCYe3BOzvXrsBLMlN6aw16M1htaA'
    [kslowd] next -> ffff8800369faac8 positive

    The new object has looked up the subdir in which the file would be in (getting
    dentry ffff88002ce41bd0) and then looked up the file itself (getting dentry
    ffff8800369faac8).

    [kslowd] validate 'Es0g00og0_Nd_XCYe3BOzvXrsBLMlN6aw16M1htaA'
    [kslowd] ==> cachefiles_bury_object(,'@68','Es0g00og0_Nd_XCYe3BOzvXrsBLMlN6aw16M1htaA')
    [kslowd] remove ffff8800369faac8 from ffff88002ce41bd0
    [kslowd] unlink stale object
    [kslowd] inode does not match i_ino.

    [kslowd] OBJECT_DEAD]
    [kslowd] ==> fscache_object_state_machine({OBJ53,OBJECT_AVAILABLE,0})
    [kslowd] OBJECT_ACTIVE]

    (Note that the above trace includes extra information beyond that produced by
    the upstream code).

    The fix is to note when an object that is being retired has had its object
    deleted preemptively by a replacement object that is being created, and to
    skip the second removal attempt in such a case.

    Reported-by: Greg M
    Reported-by: Mark Moseley
    Reported-by: Romain DEGEZ
    Signed-off-by: David Howells
    Signed-off-by: Linus Torvalds

    David Howells
     

28 May, 2009

1 commit


03 Apr, 2009

1 commit

  • Add an FS-Cache cache-backend that permits a mounted filesystem to be used as a
    backing store for the cache.

    CacheFiles uses a userspace daemon to do some of the cache management - such as
    reaping stale nodes and culling. This is called cachefilesd and lives in
    /sbin. The source for the daemon can be downloaded from:

    http://people.redhat.com/~dhowells/cachefs/cachefilesd.c

    And an example configuration from:

    http://people.redhat.com/~dhowells/cachefs/cachefilesd.conf

    The filesystem and data integrity of the cache are only as good as those of the
    filesystem providing the backing services. Note that CacheFiles does not
    attempt to journal anything since the journalling interfaces of the various
    filesystems are very specific in nature.

    CacheFiles creates a misc character device - "/dev/cachefiles" - that is used
    to communication with the daemon. Only one thing may have this open at once,
    and whilst it is open, a cache is at least partially in existence. The daemon
    opens this and sends commands down it to control the cache.

    CacheFiles is currently limited to a single cache.

    CacheFiles attempts to maintain at least a certain percentage of free space on
    the filesystem, shrinking the cache by culling the objects it contains to make
    space if necessary - see the "Cache Culling" section. This means it can be
    placed on the same medium as a live set of data, and will expand to make use of
    spare space and automatically contract when the set of data requires more
    space.

    ============
    REQUIREMENTS
    ============

    The use of CacheFiles and its daemon requires the following features to be
    available in the system and in the cache filesystem:

    - dnotify.

    - extended attributes (xattrs).

    - openat() and friends.

    - bmap() support on files in the filesystem (FIBMAP ioctl).

    - The use of bmap() to detect a partial page at the end of the file.

    It is strongly recommended that the "dir_index" option is enabled on Ext3
    filesystems being used as a cache.

    =============
    CONFIGURATION
    =============

    The cache is configured by a script in /etc/cachefilesd.conf. These commands
    set up cache ready for use. The following script commands are available:

    (*) brun %
    (*) bcull %
    (*) bstop %
    (*) frun %
    (*) fcull %
    (*) fstop %

    Configure the culling limits. Optional. See the section on culling
    The defaults are 7% (run), 5% (cull) and 1% (stop) respectively.

    The commands beginning with a 'b' are file space (block) limits, those
    beginning with an 'f' are file count limits.

    (*) dir

    Specify the directory containing the root of the cache. Mandatory.

    (*) tag

    Specify a tag to FS-Cache to use in distinguishing multiple caches.
    Optional. The default is "CacheFiles".

    (*) debug

    Specify a numeric bitmask to control debugging in the kernel module.
    Optional. The default is zero (all off). The following values can be
    OR'd into the mask to collect various information:

    1 Turn on trace of function entry (_enter() macros)
    2 Turn on trace of function exit (_leave() macros)
    4 Turn on trace of internal debug points (_debug())

    This mask can also be set through sysfs, eg:

    echo 5 >/sys/modules/cachefiles/parameters/debug

    ==================
    STARTING THE CACHE
    ==================

    The cache is started by running the daemon. The daemon opens the cache device,
    configures the cache and tells it to begin caching. At that point the cache
    binds to fscache and the cache becomes live.

    The daemon is run as follows:

    /sbin/cachefilesd [-d]* [-s] [-n] [-f ]

    The flags are:

    (*) -d

    Increase the debugging level. This can be specified multiple times and
    is cumulative with itself.

    (*) -s

    Send messages to stderr instead of syslog.

    (*) -n

    Don't daemonise and go into background.

    (*) -f

    Use an alternative configuration file rather than the default one.

    ===============
    THINGS TO AVOID
    ===============

    Do not mount other things within the cache as this will cause problems. The
    kernel module contains its own very cut-down path walking facility that ignores
    mountpoints, but the daemon can't avoid them.

    Do not create, rename or unlink files and directories in the cache whilst the
    cache is active, as this may cause the state to become uncertain.

    Renaming files in the cache might make objects appear to be other objects (the
    filename is part of the lookup key).

    Do not change or remove the extended attributes attached to cache files by the
    cache as this will cause the cache state management to get confused.

    Do not create files or directories in the cache, lest the cache get confused or
    serve incorrect data.

    Do not chmod files in the cache. The module creates things with minimal
    permissions to prevent random users being able to access them directly.

    =============
    CACHE CULLING
    =============

    The cache may need culling occasionally to make space. This involves
    discarding objects from the cache that have been used less recently than
    anything else. Culling is based on the access time of data objects. Empty
    directories are culled if not in use.

    Cache culling is done on the basis of the percentage of blocks and the
    percentage of files available in the underlying filesystem. There are six
    "limits":

    (*) brun
    (*) frun

    If the amount of free space and the number of available files in the cache
    rises above both these limits, then culling is turned off.

    (*) bcull
    (*) fcull

    If the amount of available space or the number of available files in the
    cache falls below either of these limits, then culling is started.

    (*) bstop
    (*) fstop

    If the amount of available space or the number of available files in the
    cache falls below either of these limits, then no further allocation of
    disk space or files is permitted until culling has raised things above
    these limits again.

    These must be configured thusly:

    0 < bcull < brun < 100
    0 < fcull < frun < 100

    Note that these are percentages of available space and available files, and do
    _not_ appear as 100 minus the percentage displayed by the "df" program.

    The userspace daemon scans the cache to build up a table of cullable objects.
    These are then culled in least recently used order. A new scan of the cache is
    started as soon as space is made in the table. Objects will be skipped if
    their atimes have changed or if the kernel module says it is still using them.

    ===============
    CACHE STRUCTURE
    ===============

    The CacheFiles module will create two directories in the directory it was
    given:

    (*) cache/

    (*) graveyard/

    The active cache objects all reside in the first directory. The CacheFiles
    kernel module moves any retired or culled objects that it can't simply unlink
    to the graveyard from which the daemon will actually delete them.

    The daemon uses dnotify to monitor the graveyard directory, and will delete
    anything that appears therein.

    The module represents index objects as directories with the filename "I..." or
    "J...". Note that the "cache/" directory is itself a special index.

    Data objects are represented as files if they have no children, or directories
    if they do. Their filenames all begin "D..." or "E...". If represented as a
    directory, data objects will have a file in the directory called "data" that
    actually holds the data.

    Special objects are similar to data objects, except their filenames begin
    "S..." or "T...".

    If an object has children, then it will be represented as a directory.
    Immediately in the representative directory are a collection of directories
    named for hash values of the child object keys with an '@' prepended. Into
    this directory, if possible, will be placed the representations of the child
    objects:

    INDEX INDEX INDEX DATA FILES
    ========= ========== ================================= ================
    cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400
    cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...DB1ry
    cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...N22ry
    cache/@4a/I03nfs/@30/Ji000000000000000--fHg8hi8400/@75/Es0g000w...FP1ry

    If the key is so long that it exceeds NAME_MAX with the decorations added on to
    it, then it will be cut into pieces, the first few of which will be used to
    make a nest of directories, and the last one of which will be the objects
    inside the last directory. The names of the intermediate directories will have
    '+' prepended:

    J1223/@23/+xy...z/+kl...m/Epqr

    Note that keys are raw data, and not only may they exceed NAME_MAX in size,
    they may also contain things like '/' and NUL characters, and so they may not
    be suitable for turning directly into a filename.

    To handle this, CacheFiles will use a suitably printable filename directly and
    "base-64" encode ones that aren't directly suitable. The two versions of
    object filenames indicate the encoding:

    OBJECT TYPE PRINTABLE ENCODED
    =============== =============== ===============
    Index "I..." "J..."
    Data "D..." "E..."
    Special "S..." "T..."

    Intermediate directories are always "@" or "+" as appropriate.

    Each object in the cache has an extended attribute label that holds the object
    type ID (required to distinguish special objects) and the auxiliary data from
    the netfs. The latter is used to detect stale objects in the cache and update
    or retire them.

    Note that CacheFiles will erase from the cache any file it doesn't recognise or
    any file of an incorrect type (such as a FIFO file or a device file).

    ==========================
    SECURITY MODEL AND SELINUX
    ==========================

    CacheFiles is implemented to deal properly with the LSM security features of
    the Linux kernel and the SELinux facility.

    One of the problems that CacheFiles faces is that it is generally acting on
    behalf of a process, and running in that process's context, and that includes a
    security context that is not appropriate for accessing the cache - either
    because the files in the cache are inaccessible to that process, or because if
    the process creates a file in the cache, that file may be inaccessible to other
    processes.

    The way CacheFiles works is to temporarily change the security context (fsuid,
    fsgid and actor security label) that the process acts as - without changing the
    security context of the process when it the target of an operation performed by
    some other process (so signalling and suchlike still work correctly).

    When the CacheFiles module is asked to bind to its cache, it:

    (1) Finds the security label attached to the root cache directory and uses
    that as the security label with which it will create files. By default,
    this is:

    cachefiles_var_t

    (2) Finds the security label of the process which issued the bind request
    (presumed to be the cachefilesd daemon), which by default will be:

    cachefilesd_t

    and asks LSM to supply a security ID as which it should act given the
    daemon's label. By default, this will be:

    cachefiles_kernel_t

    SELinux transitions the daemon's security ID to the module's security ID
    based on a rule of this form in the policy.

    type_transition ;

    For instance:

    type_transition cachefilesd_t kernel_t : process cachefiles_kernel_t;

    The module's security ID gives it permission to create, move and remove files
    and directories in the cache, to find and access directories and files in the
    cache, to set and access extended attributes on cache objects, and to read and
    write files in the cache.

    The daemon's security ID gives it only a very restricted set of permissions: it
    may scan directories, stat files and erase files and directories. It may
    not read or write files in the cache, and so it is precluded from accessing the
    data cached therein; nor is it permitted to create new files in the cache.

    There are policy source files available in:

    http://people.redhat.com/~dhowells/fscache/cachefilesd-0.8.tar.bz2

    and later versions. In that tarball, see the files:

    cachefilesd.te
    cachefilesd.fc
    cachefilesd.if

    They are built and installed directly by the RPM.

    If a non-RPM based system is being used, then copy the above files to their own
    directory and run:

    make -f /usr/share/selinux/devel/Makefile
    semodule -i cachefilesd.pp

    You will need checkpolicy and selinux-policy-devel installed prior to the
    build.

    By default, the cache is located in /var/fscache, but if it is desirable that
    it should be elsewhere, than either the above policy files must be altered, or
    an auxiliary policy must be installed to label the alternate location of the
    cache.

    For instructions on how to add an auxiliary policy to enable the cache to be
    located elsewhere when SELinux is in enforcing mode, please see:

    /usr/share/doc/cachefilesd-*/move-cache.txt

    When the cachefilesd rpm is installed; alternatively, the document can be found
    in the sources.

    ==================
    A NOTE ON SECURITY
    ==================

    CacheFiles makes use of the split security in the task_struct. It allocates
    its own task_security structure, and redirects current->act_as to point to it
    when it acts on behalf of another process, in that process's context.

    The reason it does this is that it calls vfs_mkdir() and suchlike rather than
    bypassing security and calling inode ops directly. Therefore the VFS and LSM
    may deny the CacheFiles access to the cache data because under some
    circumstances the caching code is running in the security context of whatever
    process issued the original syscall on the netfs.

    Furthermore, should CacheFiles create a file or directory, the security
    parameters with that object is created (UID, GID, security label) would be
    derived from that process that issued the system call, thus potentially
    preventing other processes from accessing the cache - including CacheFiles's
    cache management daemon (cachefilesd).

    What is required is to temporarily override the security of the process that
    issued the system call. We can't, however, just do an in-place change of the
    security data as that affects the process as an object, not just as a subject.
    This means it may lose signals or ptrace events for example, and affects what
    the process looks like in /proc.

    So CacheFiles makes use of a logical split in the security between the
    objective security (task->sec) and the subjective security (task->act_as). The
    objective security holds the intrinsic security properties of a process and is
    never overridden. This is what appears in /proc, and is what is used when a
    process is the target of an operation by some other process (SIGKILL for
    example).

    The subjective security holds the active security properties of a process, and
    may be overridden. This is not seen externally, and is used whan a process
    acts upon another object, for example SIGKILLing another process or opening a
    file.

    LSM hooks exist that allow SELinux (or Smack or whatever) to reject a request
    for CacheFiles to run in a context of a specific security label, or to create
    files and directories with another security label.

    This documentation is added by the patch to:

    Documentation/filesystems/caching/cachefiles.txt

    Signed-Off-By: David Howells
    Acked-by: Steve Dickson
    Acked-by: Trond Myklebust
    Acked-by: Al Viro
    Tested-by: Daire Byrne

    David Howells