OSDN Git Service

Merge tag 'for-linus-20190715' of git://git.kernel.org/pub/scm/linux/kernel/git/braun...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Jul 2019 18:30:07 +0000 (11:30 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 16 Jul 2019 18:30:07 +0000 (11:30 -0700)
Pull pidfd and clone3 fixes from Christian Brauner:
 "This contains a bugfix for CLONE_PIDFD when used with the legacy clone
  syscall, two fixes to ensure that syscall numbering and clone3
  entrypoint implementations will stay consistent, and an update for the
  maintainers file:

   - The addition of clone3 broke CLONE_PIDFD for legacy clone on all
     architectures that use do_fork() directly instead of calling the
     clone syscall itself. (Fwiw, cleaning do_fork() up is on my todo.)

     The reason this happened was that during conversion of _do_fork()
     to use struct kernel_clone_args we missed that do_fork() is called
     directly by various architectures. This is fixed by making sure
     that the pidfd argument in struct kernel_clone_args is correctly
     initialized with the parent_tidptr argument passed down from
     do_fork(). Additionally, do_fork() missed a check to make
     CLONE_PIDFD and CLONE_PARENT_SETTID mutually exclusive just a
     clone() does. This is now fixed too.

   - When clone3() was introduced we skipped architectures that require
     special handling for fork-like syscalls. Their syscall tables did
     not contain any mention of clone3().

     To make sure that Arnd's work to make syscall numbers on all
     architectures identical (minus alpha) was not for naught we are
     placing a comment in all syscall tables that do not yet implement
     clone3(). The comment makes it clear that 435 is reserved for
     clone3 and should not be used.

   - Also, this contains a patch to make the clone3() syscall definition
     in asm-generic/unist.h conditional on __ARCH_WANT_SYS_CLONE3. This
     lets us catch new architectures that implicitly make use of clone3
     without setting __ARCH_WANT_SYS_CLONE3 which is a good indicator
     that they did not check whether it needs special treatment or not.

   - Finally, this contains a patch to add me as maintainer for pidfd
     stuff so people can start blaming me (more)"

* tag 'for-linus-20190715' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux:
  MAINTAINERS: add new entry for pidfd api
  unistd: protect clone3 via __ARCH_WANT_SYS_CLONE3
  arch: mark syscall number 435 reserved for clone3
  clone: fix CLONE_PIDFD support

1  2 
MAINTAINERS
kernel/fork.c

diff --combined MAINTAINERS
@@@ -2625,15 -2625,6 +2625,15 @@@ S:    Maintaine
  F:    Documentation/hwmon/asc7621.rst
  F:    drivers/hwmon/asc7621.c
  
 +ASPEED PINCTRL DRIVERS
 +M:    Andrew Jeffery <andrew@aj.id.au>
 +L:    linux-aspeed@lists.ozlabs.org (moderated for non-subscribers)
 +L:    openbmc@lists.ozlabs.org (moderated for non-subscribers)
 +L:    linux-gpio@vger.kernel.org
 +S:    Maintained
 +F:    drivers/pinctrl/aspeed/
 +F:    Documentation/devicetree/bindings/pinctrl/aspeed,*
 +
  ASPEED VIDEO ENGINE DRIVER
  M:    Eddie James <eajames@linux.ibm.com>
  L:    linux-media@vger.kernel.org
@@@ -4183,19 -4174,6 +4183,19 @@@ S:    Maintaine
  F:    mm/memcontrol.c
  F:    mm/swap_cgroup.c
  
 +CONTROL GROUP - BLOCK IO CONTROLLER (BLKIO)
 +M:    Tejun Heo <tj@kernel.org>
 +M:    Jens Axboe <axboe@kernel.dk>
 +L:    cgroups@vger.kernel.org
 +L:    linux-block@vger.kernel.org
 +T:    git git://git.kernel.dk/linux-block
 +F:    Documentation/cgroup-v1/blkio-controller.rst
 +F:    block/blk-cgroup.c
 +F:    include/linux/blk-cgroup.h
 +F:    block/blk-throttle.c
 +F:    block/blk-iolatency.c
 +F:    block/bfq-cgroup.c
 +
  CORETEMP HARDWARE MONITORING DRIVER
  M:    Fenghua Yu <fenghua.yu@intel.com>
  L:    linux-hwmon@vger.kernel.org
@@@ -5212,13 -5190,6 +5212,13 @@@ S:    Maintaine
  F:    drivers/gpu/drm/tinydrm/st7735r.c
  F:    Documentation/devicetree/bindings/display/sitronix,st7735r.txt
  
 +DRM DRIVER FOR ST-ERICSSON MCDE
 +M:    Linus Walleij <linus.walleij@linaro.org>
 +T:    git git://anongit.freedesktop.org/drm/drm-misc
 +S:    Maintained
 +F:    drivers/gpu/drm/mcde/
 +F:    Documentation/devicetree/bindings/display/ste,mcde.txt
 +
  DRM DRIVER FOR TDFX VIDEO CARDS
  S:    Orphan / Obsolete
  F:    drivers/gpu/drm/tdfx/
@@@ -5504,7 -5475,6 +5504,7 @@@ T:      git git://anongit.freedesktop.org/dr
  
  DRM PANEL DRIVERS
  M:    Thierry Reding <thierry.reding@gmail.com>
 +R:    Sam Ravnborg <sam@ravnborg.org>
  L:    dri-devel@lists.freedesktop.org
  T:    git git://anongit.freedesktop.org/drm/drm-misc
  S:    Maintained
@@@ -5533,6 -5503,7 +5533,6 @@@ F:      Documentation/gpu/xen-front.rs
  DRM TTM SUBSYSTEM
  M:    Christian Koenig <christian.koenig@amd.com>
  M:    Huang Rui <ray.huang@amd.com>
 -M:    Junwei Zhang <Jerry.Zhang@amd.com>
  T:    git git://people.freedesktop.org/~agd5f/linux
  S:    Maintained
  L:    dri-devel@lists.freedesktop.org
@@@ -6561,7 -6532,7 +6561,7 @@@ M:      "Rafael J. Wysocki" <rjw@rjwysocki.n
  M:    Pavel Machek <pavel@ucw.cz>
  L:    linux-pm@vger.kernel.org
  S:    Supported
 -F:    Documentation/power/freezing-of-tasks.txt
 +F:    Documentation/power/freezing-of-tasks.rst
  F:    include/linux/freezer.h
  F:    kernel/freezer.c
  
@@@ -7455,14 -7426,6 +7455,14 @@@ F:    include/asm-generic/mshyperv.
  F:    tools/hv/
  F:    Documentation/ABI/stable/sysfs-bus-vmbus
  
 +HYPERBUS SUPPORT
 +M:    Vignesh Raghavendra <vigneshr@ti.com>
 +S:    Supported
 +F:    drivers/mtd/hyperbus/
 +F:    include/linux/mtd/hyperbus.h
 +F:    Documentation/devicetree/bindings/mtd/cypress,hyperflash.txt
 +F:    Documentation/devicetree/bindings/mtd/ti,am654-hbmc.txt
 +
  HYPERVISOR VIRTUAL CONSOLE DRIVER
  L:    linuxppc-dev@lists.ozlabs.org
  S:    Odd Fixes
@@@ -8235,7 -8198,7 +8235,7 @@@ T:      git git://git.kernel.org/pub/scm/lin
  F:    drivers/gpio/gpio-*cove.c
  F:    drivers/gpio/gpio-msic.c
  
 -INTEL MULTIFUNCTION PMIC DEVICE DRIVERS
 +INTEL PMIC MULTIFUNCTION DEVICE DRIVERS
  R:    Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  S:    Maintained
  F:    drivers/mfd/intel_msic.c
@@@ -8266,14 -8229,6 +8266,14 @@@ S:    Supporte
  F:    drivers/infiniband/hw/i40iw/
  F:    include/uapi/rdma/i40iw-abi.h
  
 +INTEL SPEED SELECT TECHNOLOGY
 +M:    Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
 +L:    platform-driver-x86@vger.kernel.org
 +S:    Maintained
 +F:    drivers/platform/x86/intel_speed_select_if/
 +F:    tools/power/x86/intel-speed-select/
 +F:    include/uapi/linux/isst_if.h
 +
  INTEL TELEMETRY DRIVER
  M:    Rajneesh Bhardwaj <rajneesh.bhardwaj@linux.intel.com>
  M:    "David E. Box" <david.e.box@linux.intel.com>
@@@ -10136,13 -10091,6 +10136,13 @@@ L: linux-wireless@vger.kernel.or
  S:    Maintained
  F:    drivers/net/wireless/mediatek/mt7601u/
  
 +MEDIATEK MT7621/28/88 I2C DRIVER
 +M:    Stefan Roese <sr@denx.de>
 +L:    linux-i2c@vger.kernel.org
 +S:    Maintained
 +F:    drivers/i2c/busses/i2c-mt7621.c
 +F:    Documentation/devicetree/bindings/i2c/i2c-mt7621.txt
 +
  MEDIATEK NAND CONTROLLER DRIVER
  M:    Xiaolei Li <xiaolei.li@mediatek.com>
  L:    linux-mtd@lists.infradead.org
@@@ -11038,6 -10986,14 +11038,6 @@@ F:  driver/net/net_failover.
  F:    include/net/net_failover.h
  F:    Documentation/networking/net_failover.rst
  
 -NETEFFECT IWARP RNIC DRIVER (IW_NES)
 -M:    Faisal Latif <faisal.latif@intel.com>
 -L:    linux-rdma@vger.kernel.org
 -W:    http://www.intel.com/Products/Server/Adapters/Server-Cluster/Server-Cluster-overview.htm
 -S:    Supported
 -F:    drivers/infiniband/hw/nes/
 -F:    include/uapi/rdma/nes-abi.h
 -
  NETEM NETWORK EMULATOR
  M:    Stephen Hemminger <stephen@networkplumber.org>
  L:    netem@lists.linux-foundation.org (moderated for non-subscribers)
@@@ -11962,7 -11918,7 +11962,7 @@@ S:   Maintaine
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm.git
  F:    drivers/opp/
  F:    include/linux/pm_opp.h
 -F:    Documentation/power/opp.txt
 +F:    Documentation/power/opp.rst
  F:    Documentation/devicetree/bindings/opp/
  
  OPL4 DRIVER
@@@ -12349,7 -12305,7 +12349,7 @@@ M:   Sam Bobroff <sbobroff@linux.ibm.com
  M:    Oliver O'Halloran <oohall@gmail.com>
  L:    linuxppc-dev@lists.ozlabs.org
  S:    Supported
 -F:    Documentation/PCI/pci-error-recovery.txt
 +F:    Documentation/PCI/pci-error-recovery.rst
  F:    drivers/pci/pcie/aer.c
  F:    drivers/pci/pcie/dpc.c
  F:    drivers/pci/pcie/err.c
@@@ -12362,7 -12318,7 +12362,7 @@@ PCI ERROR RECOVER
  M:    Linas Vepstas <linasvepstas@gmail.com>
  L:    linux-pci@vger.kernel.org
  S:    Supported
 -F:    Documentation/PCI/pci-error-recovery.txt
 +F:    Documentation/PCI/pci-error-recovery.rst
  
  PCI MSI DRIVER FOR ALTERA MSI IP
  M:    Ley Foon Tan <lftan@altera.com>
@@@ -12611,6 -12567,17 +12611,17 @@@ F: arch/arm/boot/dts/picoxcell
  F:    arch/arm/mach-picoxcell/
  F:    drivers/crypto/picoxcell*
  
+ PIDFD API
+ M:    Christian Brauner <christian@brauner.io>
+ L:    linux-kernel@vger.kernel.org
+ S:    Maintained
+ T:    git git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux.git
+ F:    samples/pidfd/
+ F:    tools/testing/selftests/pidfd/
+ K:    (?i)pidfd
+ K:    (?i)clone3
+ K:    \b(clone_args|kernel_clone_args)\b
  PIN CONTROL SUBSYSTEM
  M:    Linus Walleij <linus.walleij@linaro.org>
  L:    linux-gpio@vger.kernel.org
@@@ -14767,13 -14734,6 +14778,13 @@@ M: Chris Boot <bootc@bootc.net
  S:    Maintained
  F:    drivers/leds/leds-net48xx.c
  
 +SOFT-IWARP DRIVER (siw)
 +M:    Bernard Metzler <bmt@zurich.ibm.com>
 +L:    linux-rdma@vger.kernel.org
 +S:    Supported
 +F:    drivers/infiniband/sw/siw/
 +F:    include/uapi/rdma/siw-abi.h
 +
  SOFT-ROCE DRIVER (rxe)
  M:    Moni Shoua <monis@mellanox.com>
  L:    linux-rdma@vger.kernel.org
diff --combined kernel/fork.c
@@@ -677,6 -677,7 +677,6 @@@ void __mmdrop(struct mm_struct *mm
        WARN_ON_ONCE(mm == current->active_mm);
        mm_free_pgd(mm);
        destroy_context(mm);
 -      hmm_mm_destroy(mm);
        mmu_notifier_mm_destroy(mm);
        check_mm(mm);
        put_user_ns(mm->user_ns);
@@@ -2405,6 -2406,16 +2405,16 @@@ long _do_fork(struct kernel_clone_args 
        return nr;
  }
  
+ bool legacy_clone_args_valid(const struct kernel_clone_args *kargs)
+ {
+       /* clone(CLONE_PIDFD) uses parent_tidptr to return a pidfd */
+       if ((kargs->flags & CLONE_PIDFD) &&
+           (kargs->flags & CLONE_PARENT_SETTID))
+               return false;
+       return true;
+ }
  #ifndef CONFIG_HAVE_COPY_THREAD_TLS
  /* For compatibility with architectures that call do_fork directly rather than
   * using the syscall entry points below. */
@@@ -2416,6 -2427,7 +2426,7 @@@ long do_fork(unsigned long clone_flags
  {
        struct kernel_clone_args args = {
                .flags          = (clone_flags & ~CSIGNAL),
+               .pidfd          = parent_tidptr,
                .child_tid      = child_tidptr,
                .parent_tid     = parent_tidptr,
                .exit_signal    = (clone_flags & CSIGNAL),
                .stack_size     = stack_size,
        };
  
+       if (!legacy_clone_args_valid(&args))
+               return -EINVAL;
        return _do_fork(&args);
  }
  #endif
@@@ -2504,8 -2519,7 +2518,7 @@@ SYSCALL_DEFINE5(clone, unsigned long, c
                .tls            = tls,
        };
  
-       /* clone(CLONE_PIDFD) uses parent_tidptr to return a pidfd */
-       if ((clone_flags & CLONE_PIDFD) && (clone_flags & CLONE_PARENT_SETTID))
+       if (!legacy_clone_args_valid(&args))
                return -EINVAL;
  
        return _do_fork(&args);