Skip to content
  1. Jun 14, 2020
    • Linus Torvalds's avatar
      doc: don't use deprecated "---help---" markers in target docs · 3e1ad405
      Linus Torvalds authored
      I'm not convinced the script makes useful automaed help lines anyway,
      but since we're trying to deprecate the use of "---help---" in Kconfig
      files, let's fix the doc example code too.
      
      See commit a7f7f624
      
       ("treewide: replace '---help---' in Kconfig
      files with 'help'")
      
      Cc: Masahiro Yamada <masahiroy@kernel.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      3e1ad405
    • Linus Torvalds's avatar
      Merge tag 'kbuild-v5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild · 6adc19fd
      Linus Torvalds authored
      Pull more Kbuild updates from Masahiro Yamada:
      
       - fix build rules in binderfs sample
      
       - fix build errors when Kbuild recurses to the top Makefile
      
       - covert '---help---' in Kconfig to 'help'
      
      * tag 'kbuild-v5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
        treewide: replace '---help---' in Kconfig files with 'help'
        kbuild: fix broken builds because of GZIP,BZIP2,LZOP variables
        samples: binderfs: really compile this sample and fix build issues
      6adc19fd
    • Linus Torvalds's avatar
      Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi · 3df83e16
      Linus Torvalds authored
      Pull more SCSI updates from James Bottomley:
       "This is the set of changes collected since just before the merge
        window opened. It's mostly minor fixes in drivers.
      
        The one non-driver set is the three optical disk (sr) changes where
        two are error path fixes and one is a helper conversion.
      
        The big driver change is the hpsa compat_alloc_userspace rework by Al
        so he can kill the remaining user. This has been tested and acked by
        the maintainer"
      
      * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (21 commits)
        scsi: acornscsi: Fix an error handling path in acornscsi_probe()
        scsi: storvsc: Remove memset before memory freeing in storvsc_suspend()
        scsi: cxlflash: Remove an unnecessary NULL check
        scsi: ibmvscsi: Don't send host info in adapter info MAD after LPM
        scsi: sr: Fix sr_probe() missing deallocate of device minor
        scsi: sr: Fix sr_probe() missing mutex_destroy
        scsi: st: Convert convert get_user_pages() --> pin_user_pages()
        scsi: target: Rename target_setup_cmd_from_cdb() to target_cmd_parse_cdb()
        scsi: target: Fix NULL pointer dereference
        scsi: target: Initialize LUN in transport_init_se_cmd()
        scsi: target: Factor out a new helper, target_cmd_init_cdb()
        scsi: hpsa: hpsa_ioctl(): Tidy up a bit
        scsi: hpsa: Get rid of compat_alloc_user_space()
        scsi: hpsa: Don't bother with vmalloc for BIG_IOCTL_Command_struct
        scsi: hpsa: Lift {BIG_,}IOCTL_Command_struct copy{in,out} into hpsa_ioctl()
        scsi: ufs: Remove redundant urgent_bkop_lvl initialization
        scsi: ufs: Don't update urgent bkops level when toggling auto bkops
        scsi: qedf: Remove redundant initialization of variable rc
        scsi: mpt3sas: Fix memset() in non-RDPQ mode
        scsi: iscsi: Fix reference count leak in iscsi_boot_create_kobj
        ...
      3df83e16
    • Linus Torvalds's avatar
      Merge branch 'i2c/for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux · 91fa5884
      Linus Torvalds authored
      Pull i2c updates from Wolfram Sang:
       "I2C has quite some patches for you this time. I hope it is the move to
        per-driver-maintainers which is now showing results. We will see.
      
        The big news is two new drivers (Nuvoton NPCM and Qualcomm CCI),
        larger refactoring of the Designware, Tegra, and PXA drivers, the
        Cadence driver supports being a slave now, and there is support to
        instanciate SPD eeproms for well-known cases (which will be
        user-visible because the i801 driver supports it), and some
        devm_platform_ioremap_resource() conversions which blow up the
        diffstat.
      
        Note that I applied the Nuvoton driver quite late, so some minor fixup
        patches arrived during the merge window. I chose to apply them right
        away because they were trivial"
      
      * 'i2c/for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux: (109 commits)
        i2c: Drop stray comma in MODULE_AUTHOR statements
        i2c: npcm7xx: npcm_i2caddr[] can be static
        MAINTAINERS: npcm7xx: Add maintainer for Nuvoton NPCM BMC
        i2c: npcm7xx: Fix a couple of error codes in probe
        i2c: icy: Fix build with CONFIG_AMIGA_PCMCIA=n
        i2c: npcm7xx: Remove unnecessary parentheses
        i2c: npcm7xx: Add support for slave mode for Nuvoton
        i2c: npcm7xx: Add Nuvoton NPCM I2C controller driver
        dt-bindings: i2c: npcm7xx: add NPCM I2C controller
        i2c: pxa: don't error out if there's no pinctrl
        i2c: add 'single-master' property to generic bindings
        i2c: designware: Add Baikal-T1 System I2C support
        i2c: designware: Move reg-space remapping into a dedicated function
        i2c: designware: Retrieve quirk flags as early as possible
        i2c: designware: Convert driver to using regmap API
        i2c: designware: Discard Cherry Trail model flag
        i2c: designware: Add Baytrail sem config DW I2C platform dependency
        i2c: designware: slave: Set DW I2C core module dependency
        i2c: designware: Use `-y` to build multi-object modules
        dt-bindings: i2c: dw: Add Baikal-T1 SoC I2C controller
        ...
      91fa5884
    • Linus Torvalds's avatar
      Merge tag 'media/v5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media · ac911b31
      Linus Torvalds authored
      Pull more media updates from Mauro Carvalho Chehab:
      
       - a set of atomisp patches. They remove several abstraction layers, and
         fixes clang and gcc warnings (that were hidden via some macros that
         were disabling 4 or 5 types of warnings there). There are also some
         important fixes and sensor auto-detection on newer BIOSes via ACPI
         _DCM tables.
      
       - some fixes
      
      * tag 'media/v5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (95 commits)
        media: rkvdec: Fix H264 scaling list order
        media: v4l2-ctrls: Unset correct HEVC loop filter flag
        media: videobuf2-dma-contig: fix bad kfree in vb2_dma_contig_clear_max_seg_size
        media: v4l2-subdev.rst: correct information about v4l2 events
        media: s5p-mfc: Properly handle dma_parms for the allocated devices
        media: medium: cec: Make MEDIA_CEC_SUPPORT default to n if !MEDIA_SUPPORT
        media: cedrus: Implement runtime PM
        media: cedrus: Program output format during each run
        media: atomisp: improve ACPI/DMI detection logs
        media: Revert "media: atomisp: add Asus Transform T101HA ACPI vars"
        media: Revert "media: atomisp: Add some ACPI detection info"
        media: atomisp: improve sensor detection code to use _DSM table
        media: atomisp: get rid of an iomem abstraction layer
        media: atomisp: get rid of a string_support.h abstraction layer
        media: atomisp: use strscpy() instead of less secure variants
        media: atomisp: set DFS to MAX if sensor doesn't report fps
        media: atomisp: use different dfs failed messages
        media: atomisp: change the detection of ISP2401 at runtime
        media: atomisp: use macros from intel-family.h
        media: atomisp: don't set hpll_freq twice with different values
        ...
      ac911b31
    • Linus Torvalds's avatar
      Merge tag 'libnvdimm-for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm · d74b15db
      Linus Torvalds authored
      Pull libnvdimm updates from Dan Williams:
       "Small collection of cleanups to rework usage of ->queuedata and the
        GUID api"
      
      * tag 'libnvdimm-for-5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm:
        nvdimm/pmem: stop using ->queuedata
        nvdimm/btt: stop using ->queuedata
        nvdimm/blk: stop using ->queuedata
        libnvdimm: Replace guid_copy() with import_guid() where it makes sense
      d74b15db
    • Linus Torvalds's avatar
      watch_queue: add gitignore for generated sample program · 298ce0fd
      Linus Torvalds authored
      Let's keep "git status" happy and quiet.
      
      Fixes: f5b5a164
      
       ("Add sample notification program")
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      298ce0fd
    • Linus Torvalds's avatar
      Merge tag 'iomap-5.8-merge-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · 593bd5e5
      Linus Torvalds authored
      Pull iomap fix from Darrick Wong:
       "A single iomap bug fix for a variable type mistake on 32-bit
        architectures, fixing an integer overflow problem in the unshare
        actor"
      
      * tag 'iomap-5.8-merge-1' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        iomap: Fix unsharing of an extent >2GB on a 32-bit machine
      593bd5e5
    • Linus Torvalds's avatar
      Merge tag 'xfs-5.8-merge-9' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux · c5557227
      Linus Torvalds authored
      Pull xfs fix from Darrick Wong:
       "We've settled down into the bugfix phase; this one fixes a resource
        leak on an error bailout path"
      
      * tag 'xfs-5.8-merge-9' of git://git.kernel.org/pub/scm/fs/xfs/xfs-linux:
        xfs: Add the missed xfs_perag_put() for xfs_ifree_cluster()
      c5557227
    • Linus Torvalds's avatar
      Merge tag '9p-for-5.8' of git://github.com/martinetd/linux · 61f3e825
      Linus Torvalds authored
      Pull 9p update from Dominique Martinet:
       "Another very quiet cycle... Only one commit: increase the size of the
        ring used for xen transport"
      
      * tag '9p-for-5.8' of git://github.com/martinetd/linux:
        9p/xen: increase XEN_9PFS_RING_ORDER
      61f3e825
    • Linus Torvalds's avatar
      Merge tag 'powerpc-5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux · 08bf1a27
      Linus Torvalds authored
      Pull powerpc fix from Michael Ellerman:
       "One fix for a recent change which broke nested KVM guests on Power9.
      
        Thanks to Alexey Kardashevskiy"
      
      * tag 'powerpc-5.8-2' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
        KVM: PPC: Fix nested guest RC bits update
      08bf1a27
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm · cfd230b3
      Linus Torvalds authored
      Pull ARM fixes from Russell King:
      
       - fix for "hex" Kconfig default to use 0x0 rather than 0 to allow these
         to be removed from defconfigs
      
       - fix from Ard Biesheuvel for EFI HYP mode booting
      
      * tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm:
        ARM: 8985/1: efi/decompressor: deal with HYP mode boot gracefully
        ARM: 8984/1: Kconfig: set default ZBOOT_ROM_TEXT/BSS value to 0x0
      cfd230b3
    • Linus Torvalds's avatar
      Merge tag 'for-linus' of git://github.com/openrisc/linux · 56192707
      Linus Torvalds authored
      Pull OpenRISC update from Stafford Horne:
       "One patch found wile I was getting the glibc port ready: fix issue
        with clone TLS arg getting overwritten"
      
      * tag 'for-linus' of git://github.com/openrisc/linux:
        openrisc: Fix issue with argument clobbering for clone/fork
      56192707
    • Linus Torvalds's avatar
      Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha · 66125d93
      Linus Torvalds authored
      Pull alpha updates from Matt Turner:
       "A few changes for alpha. They're mostly small janitorial fixes but
        there's also a build fix and most notably a patch from Mikulas that
        fixes a hang on boot on the Avanti platform, which required quite a
        bit of work and review"
      
      * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha:
        alpha: Fix build around srm_sysrq_reboot_op
        alpha: c_next should increase position index
        alpha: Replace sg++ with sg = sg_next(sg)
        alpha: fix memory barriers so that they conform to the specification
        alpha: remove unneeded semicolon in sys_eiger.c
        alpha: remove unneeded semicolon in osf_sys.c
        alpha: Replace strncmp with str_has_prefix
        alpha: fix rtc port ranges
        alpha: Kconfig: pedantic formatting
      66125d93
    • Linus Torvalds's avatar
      Merge tag 'ras-core-2020-06-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · a9429089
      Linus Torvalds authored
      Pull x86 RAS updates from Thomas Gleixner:
       "RAS updates from Borislav Petkov:
      
         - Unmap a whole guest page if an MCE is encountered in it to avoid
           follow-on MCEs leading to the guest crashing, by Tony Luck.
      
           This change collided with the entry changes and the merge
           resolution would have been rather unpleasant. To avoid that the
           entry branch was merged in before applying this. The resulting code
           did not change over the rebase.
      
         - AMD MCE error thresholding machinery cleanup and hotplug
           sanitization, by Thomas Gleixner.
      
         - Change the MCE notifiers to denote whether they have handled the
           error and not break the chain early by returning NOTIFY_STOP, thus
           giving the opportunity for the later handlers in the chain to see
           it. By Tony Luck.
      
         - Add AMD family 0x17, models 0x60-6f support, by Alexander Monakov.
      
         - Last but not least, the usual round of fixes and improvements"
      
      * tag 'ras-core-2020-06-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (23 commits)
        x86/mce/dev-mcelog: Fix -Wstringop-truncation warning about strncpy()
        x86/{mce,mm}: Unmap the entire page if the whole page is affected and poisoned
        EDAC/amd64: Add AMD family 17h model 60h PCI IDs
        hwmon: (k10temp) Add AMD family 17h model 60h PCI match
        x86/amd_nb: Add AMD family 17h model 60h PCI IDs
        x86/mcelog: Add compat_ioctl for 32-bit mcelog support
        x86/mce: Drop bogus comment about mce.kflags
        x86/mce: Fixup exception only for the correct MCEs
        EDAC: Drop the EDAC report status checks
        x86/mce: Add mce=print_all option
        x86/mce: Change default MCE logger to check mce->kflags
        x86/mce: Fix all mce notifiers to update the mce->kflags bitmask
        x86/mce: Add a struct mce.kflags field
        x86/mce: Convert the CEC to use the MCE notifier
        x86/mce: Rename "first" function as "early"
        x86/mce/amd, edac: Remove report_gart_errors
        x86/mce/amd: Make threshold bank setting hotplug robust
        x86/mce/amd: Cleanup threshold device remove path
        x86/mce/amd: Straighten CPU hotplug path
        x86/mce/amd: Sanitize thresholding device creation hotplug path
        ...
      a9429089
    • Linus Torvalds's avatar
      Merge tag 'x86-entry-2020-06-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip · 076f14be
      Linus Torvalds authored
      Pull x86 entry updates from Thomas Gleixner:
       "The x86 entry, exception and interrupt code rework
      
        This all started about 6 month ago with the attempt to move the Posix
        CPU timer heavy lifting out of the timer interrupt code and just have
        lockless quick checks in that code path. Trivial 5 patches.
      
        This unearthed an inconsistency in the KVM handling of task work and
        the review requested to move all of this into generic code so other
        architectures can share.
      
        Valid request and solved with another 25 patches but those unearthed
        inconsistencies vs. RCU and instrumentation.
      
        Digging into this made it obvious that there are quite some
        inconsistencies vs. instrumentation in general. The int3 text poke
        handling in particular was completely unprotected and with the batched
        update of trace events even more likely to expose to endless int3
        recursion.
      
        In parallel the RCU implications of instrumenting fragile entry code
        came up in several discussions.
      
        The conclusion of the x86 maintainer team was to go all the way and
        make the protection against any form of instrumentation of fragile and
        dangerous code pathes enforcable and verifiable by tooling.
      
        A first batch of preparatory work hit mainline with commit
        d5f744f9 ("Pull x86 entry code updates from Thomas Gleixner")
      
        That (almost) full solution introduced a new code section
        '.noinstr.text' into which all code which needs to be protected from
        instrumentation of all sorts goes into. Any call into instrumentable
        code out of this section has to be annotated. objtool has support to
        validate this.
      
        Kprobes now excludes this section fully which also prevents BPF from
        fiddling with it and all 'noinstr' annotated functions also keep
        ftrace off. The section, kprobes and objtool changes are already
        merged.
      
        The major changes coming with this are:
      
          - Preparatory cleanups
      
          - Annotating of relevant functions to move them into the
            noinstr.text section or enforcing inlining by marking them
            __always_inline so the compiler cannot misplace or instrument
            them.
      
          - Splitting and simplifying the idtentry macro maze so that it is
            now clearly separated into simple exception entries and the more
            interesting ones which use interrupt stacks and have the paranoid
            handling vs. CR3 and GS.
      
          - Move quite some of the low level ASM functionality into C code:
      
             - enter_from and exit to user space handling. The ASM code now
               calls into C after doing the really necessary ASM handling and
               the return path goes back out without bells and whistels in
               ASM.
      
             - exception entry/exit got the equivivalent treatment
      
             - move all IRQ tracepoints from ASM to C so they can be placed as
               appropriate which is especially important for the int3
               recursion issue.
      
          - Consolidate the declaration and definition of entry points between
            32 and 64 bit. They share a common header and macros now.
      
          - Remove the extra device interrupt entry maze and just use the
            regular exception entry code.
      
          - All ASM entry points except NMI are now generated from the shared
            header file and the corresponding macros in the 32 and 64 bit
            entry ASM.
      
          - The C code entry points are consolidated as well with the help of
            DEFINE_IDTENTRY*() macros. This allows to ensure at one central
            point that all corresponding entry points share the same
            semantics. The actual function body for most entry points is in an
            instrumentable and sane state.
      
            There are special macros for the more sensitive entry points, e.g.
            INT3 and of course the nasty paranoid #NMI, #MCE, #DB and #DF.
            They allow to put the whole entry instrumentation and RCU handling
            into safe places instead of the previous pray that it is correct
            approach.
      
          - The INT3 text poke handling is now completely isolated and the
            recursion issue banned. Aside of the entry rework this required
            other isolation work, e.g. the ability to force inline bsearch.
      
          - Prevent #DB on fragile entry code, entry relevant memory and
            disable it on NMI, #MC entry, which allowed to get rid of the
            nested #DB IST stack shifting hackery.
      
          - A few other cleanups and enhancements which have been made
            possible through this and already merged changes, e.g.
            consolidating and further restricting the IDT code so the IDT
            table becomes RO after init which removes yet another popular
            attack vector
      
          - About 680 lines of ASM maze are gone.
      
        There are a few open issues:
      
         - An escape out of the noinstr section in the MCE handler which needs
           some more thought but under the aspect that MCE is a complete
           trainwreck by design and the propability to survive it is low, this
           was not high on the priority list.
      
         - Paravirtualization
      
           When PV is enabled then objtool complains about a bunch of indirect
           calls out of the noinstr section. There are a few straight forward
           ways to fix this, but the other issues vs. general correctness were
           more pressing than parawitz.
      
         - KVM
      
           KVM is inconsistent as well. Patches have been posted, but they
           have not yet been commented on or picked up by the KVM folks.
      
         - IDLE
      
           Pretty much the same problems can be found in the low level idle
           code especially the parts where RCU stopped watching. This was
           beyond the scope of the more obvious and exposable problems and is
           on the todo list.
      
        The lesson learned from this brain melting exercise to morph the
        evolved code base into something which can be validated and understood
        is that once again the violation of the most important engineering
        principle "correctness first" has caused quite a few people to spend
        valuable time on problems which could have been avoided in the first
        place. The "features first" tinkering mindset really has to stop.
      
        With that I want to say thanks to everyone involved in contributing to
        this effort. Special thanks go to the following people (alphabetical
        order): Alexandre Chartre, Andy Lutomirski, Borislav Petkov, Brian
        Gerst, Frederic Weisbecker, Josh Poimboeuf, Juergen Gross, Lai
        Jiangshan, Macro Elver, Paolo Bonzin,i Paul McKenney, Peter Zijlstra,
        Vitaly Kuznetsov, and Will Deacon"
      
      * tag 'x86-entry-2020-06-12' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (142 commits)
        x86/entry: Force rcu_irq_enter() when in idle task
        x86/entry: Make NMI use IDTENTRY_RAW
        x86/entry: Treat BUG/WARN as NMI-like entries
        x86/entry: Unbreak __irqentry_text_start/end magic
        x86/entry: __always_inline CR2 for noinstr
        lockdep: __always_inline more for noinstr
        x86/entry: Re-order #DB handler to avoid *SAN instrumentation
        x86/entry: __always_inline arch_atomic_* for noinstr
        x86/entry: __always_inline irqflags for noinstr
        x86/entry: __always_inline debugreg for noinstr
        x86/idt: Consolidate idt functionality
        x86/idt: Cleanup trap_init()
        x86/idt: Use proper constants for table size
        x86/idt: Add comments about early #PF handling
        x86/idt: Mark init only functions __init
        x86/entry: Rename trace_hardirqs_off_prepare()
        x86/entry: Clarify irq_{enter,exit}_rcu()
        x86/entry: Remove DBn stacks
        x86/entry: Remove debug IDT frobbing
        x86/entry: Optimize local_db_save() for virt
        ...
      076f14be
    • Masahiro Yamada's avatar
      treewide: replace '---help---' in Kconfig files with 'help' · a7f7f624
      Masahiro Yamada authored
      Since commit 84af7a61
      
       ("checkpatch: kconfig: prefer 'help' over
      '---help---'"), the number of '---help---' has been gradually
      decreasing, but there are still more than 2400 instances.
      
      This commit finishes the conversion. While I touched the lines,
      I also fixed the indentation.
      
      There are a variety of indentation styles found.
      
        a) 4 spaces + '---help---'
        b) 7 spaces + '---help---'
        c) 8 spaces + '---help---'
        d) 1 space + 1 tab + '---help---'
        e) 1 tab + '---help---'    (correct indentation)
        f) 1 tab + 1 space + '---help---'
        g) 1 tab + 2 spaces + '---help---'
      
      In order to convert all of them to 1 tab + 'help', I ran the
      following commend:
      
        $ find . -name 'Kconfig*' | xargs sed -i 's/^[[:space:]]*---help---/\thelp/'
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      a7f7f624
    • Linus Torvalds's avatar
      Merge tag 'notifications-20200601' of... · 6c329784
      Linus Torvalds authored
      Merge tag 'notifications-20200601' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs
      
      Pull notification queue from David Howells:
       "This adds a general notification queue concept and adds an event
        source for keys/keyrings, such as linking and unlinking keys and
        changing their attributes.
      
        Thanks to Debarshi Ray, we do have a pull request to use this to fix a
        problem with gnome-online-accounts - as mentioned last time:
      
           https://gitlab.gnome.org/GNOME/gnome-online-accounts/merge_requests/47
      
        Without this, g-o-a has to constantly poll a keyring-based kerberos
        cache to find out if kinit has changed anything.
      
        [ There are other notification pending: mount/sb fsinfo notifications
          for libmount that Karel Zak and Ian Kent have been working on, and
          Christian Brauner would like to use them in lxc, but let's see how
          this one works first ]
      
        LSM hooks are included:
      
         - A set of hooks are provided that allow an LSM to rule on whether or
           not a watch may be set. Each of these hooks takes a different
           "watched object" parameter, so they're not really shareable. The
           LSM should use current's credentials. [Wanted by SELinux & Smack]
      
         - A hook is provided to allow an LSM to rule on whether or not a
           particular message may be posted to a particular queue. This is
           given the credentials from the event generator (which may be the
           system) and the watch setter. [Wanted by Smack]
      
        I've provided SELinux and Smack with implementations of some of these
        hooks.
      
        WHY
        ===
      
        Key/keyring notifications are desirable because if you have your
        kerberos tickets in a file/directory, your Gnome desktop will monitor
        that using something like fanotify and tell you if your credentials
        cache changes.
      
        However, we also have the ability to cache your kerberos tickets in
        the session, user or persistent keyring so that it isn't left around
        on disk across a reboot or logout. Keyrings, however, cannot currently
        be monitored asynchronously, so the desktop has to poll for it - not
        so good on a laptop. This facility will allow the desktop to avoid the
        need to poll.
      
        DESIGN DECISIONS
        ================
      
         - The notification queue is built on top of a standard pipe. Messages
           are effectively spliced in. The pipe is opened with a special flag:
      
              pipe2(fds, O_NOTIFICATION_PIPE);
      
           The special flag has the same value as O_EXCL (which doesn't seem
           like it will ever be applicable in this context)[?]. It is given up
           front to make it a lot easier to prohibit splice&co from accessing
           the pipe.
      
           [?] Should this be done some other way?  I'd rather not use up a new
               O_* flag if I can avoid it - should I add a pipe3() system call
               instead?
      
           The pipe is then configured::
      
              ioctl(fds[1], IOC_WATCH_QUEUE_SET_SIZE, queue_depth);
              ioctl(fds[1], IOC_WATCH_QUEUE_SET_FILTER, &filter);
      
           Messages are then read out of the pipe using read().
      
         - It should be possible to allow write() to insert data into the
           notification pipes too, but this is currently disabled as the
           kernel has to be able to insert messages into the pipe *without*
           holding pipe->mutex and the code to make this work needs careful
           auditing.
      
         - sendfile(), splice() and vmsplice() are disabled on notification
           pipes because of the pipe->mutex issue and also because they
           sometimes want to revert what they just did - but one or more
           notification messages might've been interleaved in the ring.
      
         - The kernel inserts messages with the wait queue spinlock held. This
           means that pipe_read() and pipe_write() have to take the spinlock
           to update the queue pointers.
      
         - Records in the buffer are binary, typed and have a length so that
           they can be of varying size.
      
           This allows multiple heterogeneous sources to share a common
           buffer; there are 16 million types available, of which I've used
           just a few, so there is scope for others to be used. Tags may be
           specified when a watchpoint is created to help distinguish the
           sources.
      
         - Records are filterable as types have up to 256 subtypes that can be
           individually filtered. Other filtration is also available.
      
         - Notification pipes don't interfere with each other; each may be
           bound to a different set of watches. Any particular notification
           will be copied to all the queues that are currently watching for it
           - and only those that are watching for it.
      
         - When recording a notification, the kernel will not sleep, but will
           rather mark a queue as having lost a message if there's
           insufficient space. read() will fabricate a loss notification
           message at an appropriate point later.
      
         - The notification pipe is created and then watchpoints are attached
           to it, using one of:
      
              keyctl_watch_key(KEY_SPEC_SESSION_KEYRING, fds[1], 0x01);
              watch_mount(AT_FDCWD, "/", 0, fd, 0x02);
              watch_sb(AT_FDCWD, "/mnt", 0, fd, 0x03);
      
           where in both cases, fd indicates the queue and the number after is
           a tag between 0 and 255.
      
         - Watches are removed if either the notification pipe is destroyed or
           the watched object is destroyed. In the latter case, a message will
           be generated indicating the enforced watch removal.
      
        Things I want to avoid:
      
         - Introducing features that make the core VFS dependent on the
           network stack or networking namespaces (ie. usage of netlink).
      
         - Dumping all this stuff into dmesg and having a daemon that sits
           there parsing the output and distributing it as this then puts the
           responsibility for security into userspace and makes handling
           namespaces tricky. Further, dmesg might not exist or might be
           inaccessible inside a container.
      
         - Letting users see events they shouldn't be able to see.
      
        TESTING AND MANPAGES
        ====================
      
         - The keyutils tree has a pipe-watch branch that has keyctl commands
           for making use of notifications. Proposed manual pages can also be
           found on this branch, though a couple of them really need to go to
           the main manpages repository instead.
      
           If the kernel supports the watching of keys, then running "make
           test" on that branch will cause the testing infrastructure to spawn
           a monitoring process on the side that monitors a notifications pipe
           for all the key/keyring changes induced by the tests and they'll
           all be checked off to make sure they happened.
      
              https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/log/?h=pipe-watch
      
         - A test program is provided (samples/watch_queue/watch_test) that
           can be used to monitor for keyrings, mount and superblock events.
           Information on the notifications is simply logged to stdout"
      
      * tag 'notifications-20200601' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
        smack: Implement the watch_key and post_notification hooks
        selinux: Implement the watch_key security hook
        keys: Make the KEY_NEED_* perms an enum rather than a mask
        pipe: Add notification lossage handling
        pipe: Allow buffers to be marked read-whole-or-error for notifications
        Add sample notification program
        watch_queue: Add a key/keyring notification facility
        security: Add hooks to rule on setting a watch
        pipe: Add general notification queue support
        pipe: Add O_NOTIFICATION_PIPE
        security: Add a hook for the point of notification insertion
        uapi: General notification queue definitions
      6c329784
  2. Jun 13, 2020