Files
Petri Gynther 5cdb13f3cd Merge 4.9.140 into android-msm-bluecross-4.9-lts
Linux 4.9.140
  * Revert "ipv6: set rt6i_protocol properly in the route when it is installed"
      net/ipv6/route.c
  * Revert "x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation"
      kernel/cpu.c
Linux 4.9.139
    ARM: spectre-v1: mitigate user accesses
    ARM: spectre-v1: use get_user() for __get_user()
    ARM: use __inttype() in get_user()
    ARM: oabi-compat: copy semops using __copy_from_user()
    ARM: vfp: use __copy_from_user() when restoring VFP state
    ARM: signal: copy registers using __copy_from_user()
    ARM: spectre-v1: fix syscall entry
    ARM: spectre-v1: add array_index_mask_nospec() implementation
    ARM: spectre-v1: add speculation barrier (csdb) macros
    ARM: KVM: report support for SMCCC_ARCH_WORKAROUND_1
    ARM: KVM: Add SMCCC_ARCH_WORKAROUND_1 fast handling
    ARM: spectre-v2: KVM: invalidate icache on guest exit for Brahma B15
    ARM: KVM: invalidate icache on guest exit for Cortex-A15
    ARM: KVM: invalidate BTB on guest exit for Cortex-A12/A17
    ARM: spectre-v2: warn about incorrect context switching functions
    ARM: spectre-v2: add firmware based hardening
    ARM: spectre-v2: harden user aborts in kernel space
    ARM: spectre-v2: add Cortex A8 and A15 validation of the IBE bit
    ARM: spectre-v2: harden branch predictor on context switches
    ARM: spectre: add Kconfig symbol for CPUs vulnerable to Spectre
    ARM: bugs: add support for per-processor bug checking
    ARM: bugs: hook processor bug checking into SMP and suspend paths
    ARM: bugs: prepare processor bug infrastructure
    ARM: add more CPU part numbers for Cortex and Brahma B15 CPUs
  * arm64: uaccess: suppress spurious clang warning
      arch/arm64/include/asm/uaccess.h
  * Kbuild: use -fshort-wchar globally
      Makefile
    x86/build: Use cc-option to validate stack alignment parameter
    x86/build: Fix stack alignment for CLang
    efi/libstub/arm64: Set -fpie when building the EFI stub
    efi/libstub: Preserve .debug sections after absolute relocation check
    efi/libstub/arm64: Force 'hidden' visibility for section markers
  * efi/libstub/arm64: Use hidden attribute for struct screen_info reference
      arch/arm64/include/asm/efi.h
    x86/boot: #undef memcpy() et al in string.c
  * crypto: arm64/sha - avoid non-standard inline asm tricks
      arch/arm64/crypto/sha1-ce-core.S
      arch/arm64/crypto/sha1-ce-glue.c
      arch/arm64/crypto/sha2-ce-core.S
      arch/arm64/crypto/sha2-ce-glue.c
  * kbuild: clang: Disable 'address-of-packed-member' warning
      Makefile
    x86/build: Specify stack alignment for clang
    x86/build: Use __cc-option for boot code compiler options
  * kbuild: Add __cc-option macro
      Makefile
      scripts/Kbuild.include
      scripts/Makefile.host
    crypto, x86: aesni - fix token pasting for clang
    x86/kbuild: Use cc-option to enable -falign-{jumps/loops}
  * modules: mark __inittest/__exittest as __maybe_unused
      include/linux/module.h
  * kbuild: Add support to generate LLVM assembly files
      Makefile
      scripts/Makefile.build
  * kbuild: use -Oz instead of -Os when using clang
      Makefile
  * kbuild, LLVMLinux: Add -Werror to cc-option to support clang
      scripts/Kbuild.include
  * kbuild: drop -Wno-unknown-warning-option from clang options
      Makefile
      scripts/Makefile.extrawarn
  * kbuild: fix asm-offset generation to work with clang
      include/linux/kbuild.h
      scripts/Makefile.lib
  * kbuild: consolidate redundant sed script ASM offset generation
      scripts/Makefile.lib
  * kbuild: Consolidate header generation from ASM offset information
      Kbuild
      scripts/Makefile.lib
      scripts/mod/Makefile
  * kbuild: clang: add -no-integrated-as to KBUILD_[AC]FLAGS
      Makefile
  * kbuild: Add better clang cross build support
      Makefile
  * ipv6: Fix PMTU updates for UDP/raw sockets in presence of VRF
      net/ipv6/route.c
  * inet: frags: better deal with smp races
      net/ipv4/inet_fragment.c
    usbnet: smsc95xx: disable carrier check while suspending
    tg3: Add PHY reset for 5717/5719/5720 in change ring and flow control paths
    sctp: not allow to set asoc prsctp_enable by sockopt
  * net-gro: reset skb->pkt_type in napi_reuse_skb()
      net/core/dev.c
  * ip_tunnel: don't force DF when MTU is locked
      net/ipv4/ip_tunnel_core.c
  * flow_dissector: do not dissect l4 ports for fragments
      net/core/flow_dissector.c
Linux 4.9.138
    KVM: arm64: Fix caching of host MDCR_EL2 value
    drm/i915/execlists: Force write serialisation into context image vs execution
    drm/i915/hdmi: Add HDMI 2.0 audio clock recovery N values
  * drm/dp_mst: Check if primary mstb is null
      drivers/gpu/drm/drm_dp_mst_topology.c
    drm/rockchip: Allow driver to be shutdown on reboot/kexec
  * mm: migration: fix migration of huge PMD shared pages
      include/linux/hugetlb.h
      include/linux/mm.h
      mm/rmap.c
    hugetlbfs: fix kernel BUG at fs/hugetlbfs/inode.c:444!
    lib/ubsan.c: don't mark __ubsan_handle_builtin_unreachable as noreturn
  * configfs: replace strncpy with memcpy
      fs/configfs/symlink.c
  * fuse: fix leaked notify reply
      fs/fuse/dev.c
  * fuse: fix use-after-free in fuse_direct_IO()
      fs/fuse/file.c
  * rtc: hctosys: Add missing range error reporting
      drivers/rtc/hctosys.c
    nfsd: COPY and CLONE operations require the saved filehandle to be set
    sunrpc: correct the computation for page_ptr when truncating
  * mount: Prevent MNT_DETACH from disconnecting locked mounts
      fs/namespace.c
  * mount: Don't allow copying MNT_UNBINDABLE|MNT_LOCKED mounts
      fs/namespace.c
  * mount: Retest MNT_LOCKED in do_umount
      fs/namespace.c
  * ext4: fix buffer leak in __ext4_read_dirblock() on error path
      fs/ext4/namei.c
  * ext4: fix buffer leak in ext4_xattr_move_to_block() on error path
      fs/ext4/xattr.c
  * ext4: release bs.bh before re-using in ext4_xattr_block_find()
      fs/ext4/xattr.c
  * ext4: fix possible leak of s_journal_flag_rwsem in error path
      fs/ext4/super.c
  * ext4: fix possible leak of sbi->s_group_desc_leak in error path
      fs/ext4/super.c
  * ext4: avoid possible double brelse() in add_new_gdb() on error path
      fs/ext4/resize.c
  * ext4: fix missing cleanup if ext4_alloc_flex_bg_array() fails while resizing
      fs/ext4/resize.c
  * ext4: avoid buffer leak in ext4_orphan_add() after prior errors
      fs/ext4/namei.c
  * ext4: fix possible inode leak in the retry loop of ext4_resize_fs()
      fs/ext4/resize.c
  * ext4: avoid potential extra brelse in setup_new_flex_group_blocks()
      fs/ext4/resize.c
  * ext4: add missing brelse() add_new_gdb_meta_bg()'s error path
      fs/ext4/resize.c
  * ext4: add missing brelse() in set_flexbg_block_bitmap()'s error path
      fs/ext4/resize.c
  * ext4: add missing brelse() update_backups()'s error path
      fs/ext4/resize.c
    clockevents/drivers/i8253: Add support for PIT shutdown quirk
    Btrfs: fix data corruption due to cloning of eof block
    Btrfs: fix cur_offset in the error case for nocow
    arch/alpha, termios: implement BOTHER, IBSHIFT and termios2
  * termios, tty/tty_baudrate.c: fix buffer overrun
      drivers/tty/tty_ioctl.c
    of, numa: Validate some distance map rules
  * mtd: docg3: don't set conflicting BCH_CONST_PARAMS option
      drivers/mtd/devices/Kconfig
  * netfilter: conntrack: fix calculation of next bucket number in early_drop
      net/netfilter/nf_conntrack_core.c
    mm: thp: relax __GFP_THISNODE for MADV_HUGEPAGE mappings
    ocfs2: fix a misuse a of brelse after failing ocfs2_check_dir_entry
    vhost/scsi: truncate T10 PI iov_iter to prot_bytes
    reset: hisilicon: fix potential NULL pointer dereference
    mach64: fix image corruption due to reading accelerator registers
    mach64: fix display corruption on big endian machines
    Revert "ceph: fix dentry leak in splice_dentry()"
    libceph: bump CEPH_MSG_MAX_DATA_LEN
    clk: rockchip: Fix static checker warning in rockchip_ddrclk_get_parent call
    clk: at91: Fix division by zero in PLL recalc_rate()
    clk: s2mps11: Fix matching when built as module and DT node contains compatible
    xtensa: fix boot parameters address translation
    xtensa: make sure bFLT stack is 16 byte aligned
    xtensa: add NOTES section to the linker script
    MIPS: Loongson-3: Fix BRIDGE irq delivery problem
    MIPS: Loongson-3: Fix CPU UART irq delivery problem
    parisc: Fix exported address of os_hpmc handler
    parisc: Fix HPMC handler by increasing size to multiple of 16 bytes
    parisc: Align os_hpmc_size on word boundary
    bna: ethtool: Avoid reading past end of buffer
    e1000: fix race condition between e1000_down() and e1000_watchdog
    e1000: avoid null pointer dereference on invalid stat type
  * mm: do not bug_on on incorrect length in __mm_populate()
      mm/gup.c
      mm/mmap.c
  * fuse: set FR_SENT while locked
      fs/fuse/dev.c
  * fuse: fix blocked_waitq wakeup
      fs/fuse/dev.c
  * fuse: Fix use-after-free in fuse_dev_do_write()
      fs/fuse/dev.c
  * fuse: Fix use-after-free in fuse_dev_do_read()
      fs/fuse/dev.c
    scsi: qla2xxx: shutdown chip if reset fail
    scsi: qla2xxx: Fix incorrect port speed being set for FC adapters
    cdrom: fix improper type cast, which can leat to information leak.
    9p: clear dangling pointers in p9stat_free
    9p locks: fix glock.client_id leak in do_lock
    powerpc/selftests: Wait all threads to join
    media: tvp5150: fix width alignment during set_selection()
    sc16is7xx: Fix for multi-channel stall
    MIPS/PCI: Call pcie_bus_configure_settings() to set MPS/MRRS
    powerpc/boot: Ensure _zimage_start is a weak symbol
    MIPS: kexec: Mark CPU offline before disabling local IRQ
    media: pci: cx23885: handle adding to list failure
    drm/omap: fix memory barrier bug in DMM driver
    powerpc/nohash: fix undefined behaviour when testing page size support
    ARM: imx_v6_v7_defconfig: Select CONFIG_TMPFS_POSIX_ACL
  * tty: check name length in tty_find_polling_driver()
      drivers/tty/tty_io.c
    powerpc/eeh: Fix possible null deref in eeh_dump_dev_log()
Linux 4.9.137
    MD: fix invalid stored role for a disk - try2
    btrfs: set max_extent_size properly
    Btrfs: fix null pointer dereference on compressed write path error
    btrfs: qgroup: Dirty all qgroups before rescan
    Btrfs: fix wrong dentries after fsync of file that got its parent replaced
    btrfs: make sure we create all new block groups
    btrfs: reset max_extent_size on clear in a bitmap
    btrfs: wait on caching when putting the bg cache
    btrfs: don't attempt to trim devices that don't support it
    btrfs: iterate all devices during trim, instead of fs_devices::alloc_list
    btrfs: fix error handling in free_log_tree
    btrfs: locking: Add extra check in btrfs_init_new_buffer() to avoid deadlock
    btrfs: Handle owner mismatch gracefully when walking up tree
    soc/tegra: pmc: Fix child-node lookup
    arm64: dts: stratix10: Correct System Manager register size
    Cramfs: fix abad comparison when wrap-arounds occur
    rpmsg: smd: fix memory leak on channel create
  * arm64: lse: remove -fcall-used-x0 flag
      arch/arm64/lib/Makefile
    media: em28xx: make v4l2-compliance happier by starting sequence on zero
    media: em28xx: fix input name for Terratec AV 350
    media: tvp5150: avoid going past array on v4l2_querymenu()
    media: em28xx: use a default format if TRY_FMT fails
    xen: fix xen_qlock_wait()
    kgdboc: Passing ekgdboc to command line causes panic
    media: v4l2-tpg: fix kernel oops when enabling HFLIP and OSD
    TC: Set DMA masks for devices
    MIPS: OCTEON: fix out of bounds array access on CN68XX
    powerpc/msi: Fix compile error on mpc83xx
  * dm ioctl: harden copy_params()'s copy_from_user() from malicious users
      drivers/md/dm-ioctl.c
    lockd: fix access beyond unterminated strings in prints
    nfsd: Fix an Oops in free_session()
    NFSv4.1: Fix the r/wsize checking
  * genirq: Fix race on spurious interrupt detection
      kernel/irq/manage.c
  * printk: Fix panic caused by passing log_buf_len to command line
      kernel/printk/printk.c
    smb3: on kerberos mount if server doesn't specify auth type use krb5
    smb3: do not attempt cifs operation in smb3 query info error path
    smb3: allow stats which track session and share reconnects to be reset
    w1: omap-hdq: fix missing bus unregister at removal
    iio: adc: at91: fix wrong channel number in triggered buffer mode
    iio: adc: at91: fix acking DRDY irq on simple conversions
    iio: adc: imx25-gcq: Fix leak of device_node in mx25_gcq_setup_cfgs()
    iio: ad5064: Fix regulator handling
  * kbuild: fix kernel/bounds.c 'W=1' warning
      kernel/bounds.c
    hugetlbfs: dirty pages as they are added to pagecache
    ima: fix showing large 'violations' or 'runtime_measurements_count'
    crypto: tcrypt - fix ghash-generic speed test
    crypto: lrw - Fix out-of bounds access on counter overflow
    signal/GenWQE: Fix sending of SIGKILL
  * PCI: Add Device IDs for Intel GPU "spurious interrupt" quirk
      drivers/pci/quirks.c
    EDAC, skx_edac: Fix logical channel intermediate decoding
    EDAC, {i7core,sb,skx}_edac: Fix uncorrected error counting
    HID: hiddev: fix potential Spectre v1
  * ext4: propagate error from dquot_initialize() in EXT4_IOC_FSSETXATTR
      fs/ext4/ioctl.c
  * ext4: initialize retries variable in ext4_da_write_inline_data_begin()
      fs/ext4/inline.c
    gfs2_meta: ->mount() can get NULL dev_name
  * jbd2: fix use after free in jbd2_log_do_checkpoint()
      fs/jbd2/checkpoint.c
    ASoC: intel: skylake: Add missing break in skl_tplg_get_token()
    libnvdimm: Hold reference on parent while scheduling async init
  * net/ipv4: defensive cipso option parsing
      net/ipv4/cipso_ipv4.c
    iwlwifi: mvm: check return value of rs_rate_from_ucode_rate()
    usbip:vudc: BUG kmalloc-2048 (Not tainted): Poison overwritten
    libertas: don't set URB_ZERO_PACKET on IN USB transfer
    xen: make xen_qlock_wait() nestable
    xen: fix race in xen_qlock_wait()
    xen/blkfront: avoid NULL blkfront_info dereference on device removal
    tpm: Restore functionality to xen vtpm driver.
    xen-swiotlb: use actually allocated size on check physical continuous
    ARM: dts: exynos: Mark 1 GHz CPU OPP as suspend OPP on Exynos5250
    ARM: dts: exynos: Convert exynos5250.dtsi to opp-v2 bindings
    arm: dts: exynos: Add missing cooling device properties for CPUs
    ARM: dts: exynos: Remove "cooling-{min|max}-level" for CPU nodes
    ALSA: hda: Check the non-cached stream buffers more explicitly
    dmaengine: dma-jz4780: Return error if not probed from DT
  * signal: Always deliver the kernel's SIGKILL and SIGSTOP to a pid namespace init
      kernel/signal.c
    scsi: lpfc: Correct soft lockup when running mds diagnostics
  * uio: ensure class is registered before devices
      drivers/uio/uio.c
    driver/dma/ioat: Call del_timer_sync() without holding prep_lock
    usb: chipidea: Prevent unbalanced IRQ disable
    crypto: caam - fix implicit casts in endianness helpers
    coresight: etb10: Fix handling of perf mode
  * PCI/MSI: Warn and return error if driver enables MSI/MSI-X twice
      drivers/pci/msi.c
    MD: fix invalid stored role for a disk
  * ext4: fix argument checking in EXT4_IOC_MOVE_EXT
      fs/ext4/move_extent.c
    usb: gadget: udc: atmel: handle at91sam9rl PMC
    VMCI: Resource wildcard match fixed
    tpm: suppress transmit cmd error logs when TPM 1.2 is disabled/deactivated
    IB/ipoib: Clear IPCB before icmp_send
    RDMA/core: Do not expose unsupported counters
    scsi: megaraid_sas: fix a missing-check bug
    scsi: esp_scsi: Track residual for PIO transfers
    cgroup, netclassid: add a preemption point to write_classid
    ath10k: schedule hardware restart if WMI command times out
    ixgbevf: VF2VF TCP RSS
    pinctrl: ssbi-gpio: Fix pm8xxx_pin_config_get() to be compliant
  * pinctrl: spmi-mpp: Fix pmic_mpp_config_get() to be compliant
      drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
  * pinctrl: qcom: spmi-mpp: Fix drive strength setting
      drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
    ACPI / LPSS: Add alternative ACPI HIDs for Cherry Trail DMA controllers
  * kprobes: Return error if we fail to reuse kprobe instead of BUG_ON()
      kernel/kprobes.c
    brcmfmac: fix for proper support of 160MHz bandwidth
  * pinctrl: qcom: spmi-mpp: Fix err handling of pmic_mpp_set_mux
      drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
    x86: boot: Fix EFI stub alignment
    Bluetooth: btbcm: Add entry for BCM4335C0 UART bluetooth
    cpufreq: dt: Try freeing static OPPs only if we have added them
    x86/olpc: Indicate that legacy PC XO-1 platform should not register RTC
    iwlwifi: pcie: avoid empty free RB queue
    mmc: sdhci-pci-o2micro: Add quirk for O2 Micro dev 0x8620 rev 0x01
    perf strbuf: Match va_{add,copy} with va_end
    perf tools: Cleanup trace-event-info 'tdata' leak
    perf tools: Free temporary 'sys' string in read_event_files()
    hwmon: (pwm-fan) Set fan speed to 0 on suspend
    s390/sthyi: Fix machine name validity indication
  * tun: Consistently configure generic netdev params via rtnetlink
      drivers/net/tun.c
    swim: fix cleanup on setup error
    ataflop: fix error handling during setup
  * locking/lockdep: Fix debug_locks off performance problem
      lib/debug_locks.c
    i2c: rcar: cleanup DMA for all kinds of failure
    selftests: ftrace: Add synthetic event syntax testcase
    net: qla3xxx: Remove overflowing shift statement
    x86/fpu: Remove second definition of fpu in __fpu__restore_sig()
    perf cpu_map: Align cpu map synthesized events properly.
  * sched/fair: Fix the min_vruntime update logic in dequeue_entity()
      kernel/sched/fair.c
    sparc64: Make proc_id signed.
    sparc: Fix single-pcr perf event counter management.
  * xfrm: policy: use hlist rcu variants on insert
      net/xfrm/xfrm_policy.c
    Revert "perf tools: Fix PMU term format max value calculation"
    bpf: do not blindly change rlimit in reuseport net selftest
    x86/speculation: Support Enhanced IBRS on future CPUs
    x86/corruption-check: Fix panic in memory_corruption_check() when boot option without value is provided
  * x86/speculation: Enable cross-hyperthread spectre v2 STIBP mitigation
      kernel/cpu.c
    ALSA: ca0106: Disable IZD on SB0570 DAC to fix audio pops
    ALSA: hda - Add mic quirk for the Lenovo G50-30 (17aa:3905)
    ALSA: hda - Fix headphone pin config for ASUS G751
    ALSA: hda - Add quirk for ASUS G751 laptop
    parisc: Fix map_pages() to not overwrite existing pte entries
    parisc: Fix address in HPMC IVA
    ipmi: Fix timer race with module unload
    pcmcia: Implement CLKRUN protocol disabling for Ricoh bridges
    jffs2: free jffs2_sb_info through jffs2_kill_sb()
    hwmon: (pmbus) Fix page count auto-detection.
    bcache: fix miss key refill->end in writeback
Linux 4.9.136
  * posix-timers: Sanitize overrun handling
      include/linux/posix-timers.h
      kernel/time/posix-cpu-timers.c
      kernel/time/posix-timers.c
    net: fs_enet: do not call phy_stop() in interrupts
    x86/time: Correct the attribute on jiffies' definition
    x86/percpu: Fix this_cpu_read()
  * sched/fair: Fix throttle_list starvation with low CFS quota
      kernel/sched/fair.c
      kernel/sched/sched.h
    Input: elan_i2c - add ACPI ID for Lenovo IdeaPad 330-15IGM
  * USB: fix the usbfs flag sanitization for control transfers
      drivers/usb/core/devio.c
  * usb: gadget: storage: Fix Spectre v1 vulnerability
      drivers/usb/gadget/function/f_mass_storage.c
    cdc-acm: correct counting of UART states in serial state notification
    IB/ucm: Fix Spectre v1 vulnerability
    RDMA/ucma: Fix Spectre v1 vulnerability
  * drm/edid: Add 6 bpc quirk for BOE panel in HP Pavilion 15-n233sl
      drivers/gpu/drm/drm_edid.c
    ptp: fix Spectre v1 vulnerability
    cachefiles: fix the race between cachefiles_bury_object() and rmdir(2)
    xfs: truncate transaction does not modify the inobt
    gpio: mxs: Get rid of external API call
    ahci: don't ignore result code of ahci_reset_controller()
  * crypto: shash - Fix a sleep-in-atomic bug in shash_setkey_unaligned
      crypto/shash.c
    Revert "x86/mm: Expand static page table for fixmap space"
  * ip6_tunnel: Fix encapsulation layout
      net/ipv6/ip6_tunnel.c
  * rtnetlink: Disallow FDB configuration for non-Ethernet device
      net/core/rtnetlink.c
  * net: fix pskb_trim_rcsum_slow() with odd trim offset
      net/core/skbuff.c
  * net: drop skb on failure in ip_check_defrag()
      net/ipv4/ip_fragment.c
  * bonding: fix length of actor system
      drivers/net/bonding/bond_netlink.c
  * ethtool: fix a privilege escalation bug
      net/core/ethtool.c
    vhost: Fix Spectre V1 vulnerability
    sctp: fix race on sctp_id2asoc
    r8169: fix NAPI handling under high load
  * net: udp: fix handling of CHECKSUM_COMPLETE packets
      net/core/datagram.c
      net/ipv4/udp.c
      net/ipv6/ip6_checksum.c
    net: stmmac: Fix stmmac_mdio_reset() when building stmmac as modules
  * net: socket: fix a missing-check bug
      net/socket.c
    net: sched: gred: pass the right attribute to gred_change_table_def()
  * net/ipv6: Fix index counter for unicast addresses in in6_dump_addrs
      net/ipv6/addrconf.c
    llc: set SOCK_RCU_FREE in llc_sap_add_socket()
  * ipv6/ndisc: Preserve IPv6 control buffer if protocol error handlers are called
      net/ipv6/ndisc.c
  * ipv6: mcast: fix a use-after-free in inet6_mc_check
      net/ipv6/mcast.c
  * net: bridge: remove ipv6 zero address check in mcast queries
      net/bridge/br_multicast.c
  * bridge: do not add port to router list when receives query with source 0.0.0.0
      net/bridge/br_multicast.c
    perf tools: Disable parallelism for 'make clean'
  * Revert "netfilter: ipv6: nf_defrag: drop skb dst before queueing"
      net/ipv6/netfilter/nf_conntrack_reasm.c
    mtd: spi-nor: Add support for is25wp series chips
  * fs/fat/fatent.c: add cond_resched() to fat_count_free_clusters()
      fs/fat/fatent.c
    net: ena: fix NULL dereference due to untimely napi initialization
    rxrpc: Only take the rwind and mtu values from latest ACK
    rxrpc: Don't check RXRPC_CALL_TX_LAST after calling rxrpc_rotate_tx_window()
    ARM: dts: imx53-qsb: disable 1.2GHz OPP
    perf tests: Fix indexing when invoking subtests
  * xhci: Fix USB3 NULL pointer dereference at logical disconnect.
      drivers/usb/host/xhci-hub.c
    libertas: call into generic suspend code before turning off power
    IB/mlx4: Fix an error handling path in 'mlx4_ib_rereg_user_mr()'
    x86/paravirt: Fix some warning messages
    iio: buffer: fix the function signature to match implementation
    nvmet: fix space padding in serial number
  * bonding: ratelimit failed speed/duplex update warning
      drivers/net/bonding/bond_main.c
    enic: do not overwrite error code
    xen-netfront: Fix mismatched rtnl_unlock
    sparc64: Fix regression in pmdp_invalidate().
    xen-netfront: Update features after registering netdev
    test_bpf: Fix testing with CONFIG_BPF_JIT_ALWAYS_ON=y on other arches
    ALSA: hda - Fix incorrect usage of IS_REACHABLE()
  * futex: futex_wake_op, do not fail on invalid op
      kernel/futex.c
    cifs: Use ULL suffix for 64-bit constant
  * perf/core: Fix locking for children siblings group read
      kernel/events/core.c
    macsec: fix memory leaks when skb_to_sgvec fails
  * l2tp: remove configurable payload offset
      net/l2tp/l2tp_core.c
      net/l2tp/l2tp_core.h
      net/l2tp/l2tp_netlink.c
    iio: pressure: zpa2326: Remove always-true check which confuses gcc
  * module: fix DEBUG_SET_MODULE_RONX typo
      init/main.c
  * drm/msm: Fix possible null dereference on failure of get_pages()
      drivers/gpu/drm/msm/msm_gem.c
    Btrfs: incremental send, fix invalid memory access
    Revert "IB/ipoib: Update broadcast object if PKey value was changed in index 0"
    i40e: avoid NVM acquire deadlock during NVM update
    drm: bochs: Don't remove uninitialized fbdev framebuffer
    scsi: qla2xxx: Avoid double completion of abort command
    IB/mlx5: Avoid passing an invalid QP type to firmware
    mm/frame_vector.c: release a semaphore in 'get_vaddr_frames()'
    nbd: only set MSG_MORE when we have more to send
    IB/rxe: put the pool on allocation failure
    IB/ipoib: Fix lockdep issue found on ipoib_ib_dev_heavy_flush
  * ipv6: fix cleanup ordering for ip6_mr failure
      net/ipv6/af_inet6.c
    ath10k: convert warning about non-existent OTP board id to debug message
    ALSA: hda - No loopback on ALC299 codec
    sctp: use right member as the param of list_for_each_entry
  * net: cdc_ncm: GetNtbFormat endian fix
      drivers/net/usb/cdc_ncm.c
    ocfs2: fix deadlock caused by recursive locking in xattr
    qed: Warn PTT usage by wrong hw-function
    iio: adc: Revert "axp288: Drop bogus AXP288_ADC_TS_PIN_CTRL register modifications"
    rds: ib: Fix missing call to rds_ib_dev_put in rds_ib_setup_qp
    staging: wilc1000: Fix problem with wrong vif index
    ptr_ring: fix up after recent ptr_ring changes
    clk: samsung: Fix m2m scaler clock on Exynos542x
    usb: dwc3: omap: remove IRQ_NOAUTOEN used with shared irq
    usb: renesas_usbhs: gadget: fix unused-but-set-variable warning
    usb: renesas_usbhs: gadget: fix spin_lock_init() for &uep->lock
    net/mlx5: Fix health work queue spin lock to IRQ safe
    perf probe: Fix probe definition for inlined functions
    perf evsel: Fix probing of precise_ip level for default cycles event
    net/mlx5: Fix driver load error flow when firmware is stuck
  * ip6_tunnel: Correct tos value in collect_md mode
      net/ipv6/ip6_tunnel.c
    net/mlx5e: Fix fixpoint divide exception in mlx5e_am_stats_compare
    ufs: we need to sync inode before freeing it
    Btrfs: clear EXTENT_DEFRAG bits in finish_ordered_io
    net: stmmac: ensure jumbo_frm error return is correctly checked for -ve value
  * elevator: fix truncation of icq_cache_name
      include/linux/elevator.h
    gpu: ipu-v3: Fix CSI selection for VDIC
    ARM: 8677/1: boot/compressed: fix decompressor header layout for v7-M
    x86/cpu/cyrix: Add alternative Device ID of Geode GX1 SoC
    qlcnic: Fix tunnel offload for 82xx adapters
    net: ethernet: stmmac: Fix altr_tse_pcs SGMII Initialization
    libata: fix error checking in in ata_parse_force_one()
    mac80211: fix TX aggregation start/stop callback race
    arch/sparc: increase CONFIG_NODES_SHIFT on SPARC64 to 5
    ASoC: Intel: Skylake: Fix to parse consecutive string tkns in manifest
    reset: hi6220: Set module license so that it can be loaded
    ata: sata_rcar: Handle return value of clk_prepare_enable
    btrfs: fiemap: Cache and merge fiemap extent before submit it to user
    ARM: dts: bcm283x: Reserve first page for firmware
    ath10k: fix NAPI enable/disable symmetry for AHB interface
    bnxt_en: Don't use rtnl lock to protect link change logic in workqueue.
    tipc: fix a race condition of releasing subscriber object
    tipc: Fix tipc_sk_reinit handling of -EAGAIN
    net/mlx5: Fix command completion after timeout access invalid structure
    net: phy: marvell: Limit 88m1101 autoneg errata to 88E1145 as well.
    nvme-pci: fix CMB sysfs file removal in reset path
    rxe: Fix a sleep-in-atomic bug in post_one_send
    orangefs: off by ones in xattr size checks
    IB/core: Fix the validations of a multicast LID in attach or detach operations
    IB/ipoib: Do not warn if IPoIB debugfs doesn't exist
    platform/x86: acer-wmi: setup accelerometer when ACPI device was found
  * ipv6: set rt6i_protocol properly in the route when it is installed
      net/ipv6/route.c
    efi/fb: Correct PCI_STD_RESOURCE_END usage
    i2c: bcm2835: Avoid possible NULL ptr dereference
  * PCI: Disable MSI for HiSilicon Hip06/Hip07 only in Root Port mode
      drivers/pci/quirks.c
    ACPI: sysfs: Make ACPI GPE mask kernel parameter cover all GPEs
    igb: Remove superfluous reset to PHY and page 0 selection
  * f2fs: fix multiple f2fs_add_link() having same name for inline dentry
      fs/f2fs/dir.c
    scsi: aacraid: Fix typo in blink status
    MIPS: Handle non word sized instructions when examining frame
    MIPS: microMIPS: Fix decoding of swsp16 instruction
    mm/memory_hotplug.c: fix overflow in test_pages_in_a_zone()
    perf symbols: Fix memory corruption because of zero length symbols
    net: cxgb3_main: fix a missing-check bug
    declance: Fix continuation with the adapter identification message
    net: fec: fix rare tx timeout
    perf/x86/intel/uncore: Fix PCI BDF address of M3UPI on SKX
  * perf/ring_buffer: Prevent concurent ring buffer access
      kernel/events/core.c
    smsc95xx: Check for Wake-on-LAN modes
    smsc75xx: Check for Wake-on-LAN modes
    r8152: Check for supported Wake-on-LAN Modes
    sr9800: Check for supported Wake-on-LAN modes
    lan78xx: Check for supported Wake-on-LAN modes
  * ax88179_178a: Check for supported Wake-on-LAN modes
      drivers/net/usb/ax88179_178a.c
  * asix: Check for supported Wake-on-LAN modes
      drivers/net/usb/asix_common.c
    qed: Avoid constant logical operation warning in qed_vf_pf_acquire
    qed: Avoid implicit enum conversion in qed_roce_mode_to_flavor
    pxa168fb: prepare the clock
  * Bluetooth: SMP: fix crash in unpairing
      net/bluetooth/mgmt.c
      net/bluetooth/smp.c
      net/bluetooth/smp.h
    mac80211_hwsim: do not omit multicast announce of first added radio
  * nl80211: Fix possible Spectre-v1 for NL80211_TXRATE_HT
      net/wireless/nl80211.c
    soc: fsl: qe: Fix copy/paste bug in ucc_get_tdm_sync_shift()
    soc: fsl: qbman: qman: avoid allocating from non existing gen_pool
    net: macb: Clean 64b dma addresses if they are not detected
    ARM: dts: BCM63xx: Fix incorrect interrupt specifiers
  * xfrm: validate template mode
      net/xfrm/xfrm_user.c
    ARM: 8799/1: mm: fix pci_ioremap_io() offset check
    mac80211: TDLS: fix skb queue/priority assignment
  * cfg80211: Address some corner cases in scan result channel updating
      net/wireless/scan.c
    mac80211: fix pending queue hang due to TX_DROP
  * cfg80211: reg: Init wiphy_idx in regulatory_hint_core()
      net/wireless/reg.c
    mac80211: Always report TX status
  * xfrm6: call kfree_skb when skb is toobig
      net/ipv6/xfrm6_output.c
  * xfrm: Validate address prefix lengths in the xfrm selector.
      net/xfrm/xfrm_user.c
Linux 4.9.135
    HV: properly delay KVP packets when negotiation is in progress
  * ext4: avoid running out of journal credits when appending to an inline file
      fs/ext4/ext4.h
      fs/ext4/inline.c
      fs/ext4/xattr.c
  * sched/cputime: Fix ksoftirqd cputime accounting regression
      kernel/sched/cputime.c
      kernel/sched/sched.h
  * sched/cputime: Increment kcpustat directly on irqtime account
      kernel/sched/cputime.c
      kernel/sched/sched.h
    macintosh/rack-meter: Convert cputime64_t use to u64
  * sched/cputime: Convert kcpustat to nsecs
      drivers/cpufreq/cpufreq.c
      drivers/cpufreq/cpufreq_governor.c
      drivers/cpufreq/cpufreq_stats.c
      fs/proc/stat.c
      fs/proc/uptime.c
      kernel/sched/cpuacct.c
      kernel/sched/cputime.c
    usb: gadget: serial: fix oops when data rx'd after close
  * HID: quirks: fix support for Apple Magic Keyboards
      drivers/hid/hid-core.c
    ARC: build: Don't set CROSS_COMPILE in arch's Makefile
    ARC: build: Get rid of toolchain check
  * netfilter: check for seqadj ext existence before adding it in nf_nat_setup_info
      net/netfilter/nf_nat_core.c
    mm: Preserve _PAGE_DEVMAP across mprotect() calls
  * mremap: properly flush TLB before releasing the page
      include/linux/huge_mm.h
      mm/mremap.c
    iommu/amd: Return devid as alias for ACPI HID devices
    powerpc/tm: Avoid possible userspace r1 corruption on reclaim
    powerpc/tm: Fix userspace r13 corruption
    net/mlx4: Use cpumask_available for eq->affinity_mask
  * scsi: sd: don't crash the host on invalid commands
      drivers/scsi/sd.c
    drm: mali-dp: Call drm_crtc_vblank_reset on device init
    ravb: do not write 1 to reserved bits
    Input: atakbd - fix Atari CapsLock behaviour
    Input: atakbd - fix Atari keymap
    scsi: ibmvscsis: Ensure partition name is properly NUL terminated
    scsi: ibmvscsis: Fix a stringop-overflow warning
    clocksource/drivers/ti-32k: Add CLOCK_SOURCE_SUSPEND_NONSTOP flag for non-am43 SoCs
    batman-adv: fix hardif_neigh refcount on queue_work() failure
    batman-adv: fix backbone_gw refcount on queue_work() failure
    batman-adv: Prevent duplicated tvlv handler
    batman-adv: Prevent duplicated global TT entry
    batman-adv: Prevent duplicated softif_vlan entry
    batman-adv: Prevent duplicated nc_node entry
    batman-adv: Fix segfault when writing to sysfs elp_interval
    batman-adv: Fix segfault when writing to throughput_override
    media: af9035: prevent buffer overflow on write
Linux 4.9.134
  * ipv4: frags: precedence bug in ip_expire()
      net/ipv4/ip_fragment.c
  * ip: frags: fix crash in ip_do_fragment()
      net/ipv4/ip_fragment.c
      net/ipv6/netfilter/nf_conntrack_reasm.c
  * ip: process in-order fragments efficiently
      net/ipv4/inet_fragment.c
      net/ipv4/ip_fragment.c
  * ip: add helpers to process in-order fragments faster.
      include/net/inet_frag.h
      net/ipv4/ip_fragment.c
  * ip: use rb trees for IP frag queue.
      include/linux/skbuff.h
      include/net/inet_frag.h
      net/ipv4/inet_fragment.c
      net/ipv4/ip_fragment.c
      net/ipv6/netfilter/nf_conntrack_reasm.c
      net/ipv6/reassembly.c
  * net: add rb_to_skb() and other rb tree helpers
      include/linux/skbuff.h
      net/ipv4/tcp_input.c
  * net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends
      include/linux/skbuff.h
      net/core/skbuff.c
  * ipv6: defrag: drop non-last frags smaller than min mtu
      net/ipv6/netfilter/nf_conntrack_reasm.c
      net/ipv6/reassembly.c
  * net: modify skb_rbtree_purge to return the truesize of all purged skbs.
      include/linux/skbuff.h
      net/core/skbuff.c
  * net: speed up skb_rbtree_purge()
      net/core/skbuff.c
  * ip: discard IPv4 datagrams with overlapping segments.
      include/uapi/linux/snmp.h
      net/ipv4/ip_fragment.c
      net/ipv4/proc.c
  * inet: frags: fix ip6frag_low_thresh boundary
      net/ipv4/ip_fragment.c
      net/ipv6/netfilter/nf_conntrack_reasm.c
      net/ipv6/reassembly.c
  * inet: frags: get rid of ipfrag_skb_cb/FRAG_CB
      include/linux/skbuff.h
  * inet: frags: reorganize struct netns_frags
      include/net/inet_frag.h
  * rhashtable: reorganize struct rhashtable layout
      include/linux/rhashtable.h
  * ipv6: frags: rewrite ip6_expire_frag_queue()
      net/ipv6/reassembly.c
  * inet: frags: do not clone skb in ip_expire()
      net/ipv4/ip_fragment.c
  * inet: frags: break the 2GB limit for frags storage
      include/net/inet_frag.h
      net/ipv4/ip_fragment.c
      net/ipv4/proc.c
      net/ipv6/netfilter/nf_conntrack_reasm.c
      net/ipv6/proc.c
      net/ipv6/reassembly.c
  * inet: frags: remove inet_frag_maybe_warn_overflow()
      include/net/inet_frag.h
      net/ipv4/inet_fragment.c
      net/ipv4/ip_fragment.c
      net/ipv6/netfilter/nf_conntrack_reasm.c
      net/ipv6/reassembly.c
  * inet: frags: get rif of inet_frag_evicting()
      include/net/inet_frag.h
      net/ipv4/ip_fragment.c
      net/ipv6/reassembly.c
  * inet: frags: remove some helpers
      include/net/inet_frag.h
      include/net/ip.h
      include/net/ipv6.h
      net/ipv4/ip_fragment.c
      net/ipv4/proc.c
      net/ipv6/proc.c
  * inet: frags: use rhashtables for reassembly units
      include/net/inet_frag.h
      include/net/ipv6.h
      net/ipv4/inet_fragment.c
      net/ipv4/ip_fragment.c
      net/ipv6/netfilter/nf_conntrack_reasm.c
      net/ipv6/reassembly.c
  * rhashtable: add schedule points
      lib/rhashtable.c
  * ipv6: export ip6 fragments sysctl to unprivileged users
      net/ipv6/reassembly.c
    inet: frags: refactor lowpan_net_frag_init()
  * inet: frags: refactor ipv6_frag_init()
      net/ipv6/reassembly.c
  * inet: frags: refactor ipfrag_init()
      net/ipv4/ip_fragment.c
  * inet: frags: add a pointer to struct netns_frags
      include/net/inet_frag.h
      include/net/ipv6.h
      net/ipv4/inet_fragment.c
      net/ipv4/ip_fragment.c
      net/ipv6/netfilter/nf_conntrack_reasm.c
      net/ipv6/reassembly.c
  * inet: frags: change inet_frags_init_net() return value
      include/net/inet_frag.h
      net/ipv4/ip_fragment.c
      net/ipv6/netfilter/nf_conntrack_reasm.c
      net/ipv6/reassembly.c
  * inet: make sure to grab rcu_read_lock before using ireq->ireq_opt
      include/net/inet_sock.h
      net/ipv4/inet_connection_sock.c
      net/ipv4/tcp_ipv4.c
  * tcp/dccp: fix lockdep issue when SYN is backlogged
      include/net/inet_sock.h
      net/ipv4/tcp_input.c
  * rtnl: limit IFLA_NUM_TX_QUEUES and IFLA_NUM_RX_QUEUES to 4096
      net/core/rtnetlink.c
    net: systemport: Fix wake-up interrupt race during resume
    net: mvpp2: Extract the correct ethtype from the skb for tx csum offload
    net: dsa: bcm_sf2: Fix unbind ordering
    team: Forbid enslaving team device to itself
    qmi_wwan: Added support for Gemalto's Cinterion ALASxx WWAN interface
    qlcnic: fix Tx descriptor corruption on 82xx devices
    net/usb: cancel pending work when unbinding smsc75xx
  * netlabel: check for IPV4MASK in addrinfo_get
      net/netlabel/netlabel_unlabeled.c
  * net/ipv6: Display all addresses in output of /proc/net/if_inet6
      net/ipv6/addrconf.c
  * net: ipv4: update fnhe_pmtu when first hop's MTU changes
      include/linux/netdevice.h
      include/net/ip_fib.h
      net/core/dev.c
      net/ipv4/fib_frontend.c
      net/ipv4/fib_semantics.c
    net: hns: fix for unmapping problem when SMMU is on
    net: dsa: bcm_sf2: Call setup during switch resume
  * ipv6: take rcu lock in rawv6_send_hdrinc()
      net/ipv6/raw.c
  * ipv4: fix use-after-free in ip_cmsg_recv_dstaddr()
      net/ipv4/ip_sockglue.c
  * ip_tunnel: be careful when accessing the inner header
      net/ipv4/ip_tunnel.c
  * ip6_tunnel: be careful when accessing the inner header
      net/ipv6/ip6_tunnel.c
  * bonding: avoid possible dead-lock
      drivers/net/bonding/bond_main.c
      include/net/bonding.h
    bnxt_en: Fix TX timeout during netpoll.
  * xhci: Don't print a warning when setting link state for disabled ports
      drivers/usb/host/xhci-hub.c
    i2c: i2c-scmi: fix for i2c_smbus_write_block_data
    perf script python: Fix export-to-postgresql.py occasional failure
    mach64: detect the dot clock divider correctly on sparc
  * mm/vmstat.c: fix outdated vmstat_text
      mm/vmstat.c
  * ext4: Fix error code in ext4_xattr_set_entry()
      fs/ext4/xattr.c
    drm/amdgpu: Fix SDMA HQD destroy error on gfx_v7
    x86/kvm/lapic: always disable MMIO interface in x2APIC mode
    ARM: dts: at91: add new compatibility string for macb on sama5d3
    net: macb: disable scatter-gather for macb on sama5d3
    stmmac: fix valid numbers of unicast filter entries
    sound: enable interrupt after dma buffer initialization
    scsi: qla2xxx: Fix an endian bug in fcpcmd_is_corrupted()
    scsi: iscsi: target: Don't use stack buffer for scatterlist
    mfd: omap-usb-host: Fix dts probe of children
    selftests: memory-hotplug: add required configs
    selftests/efivarfs: add required kernel configs
    ASoC: sigmadsp: safeload should not have lower byte limit
    ASoC: wm8804: Add ACPI support
Linux 4.9.133
    x86/fpu: Finish excising 'eagerfpu'
    Revert "perf: sync up x86/.../cpufeatures.h"
    x86/fpu: Remove struct fpu::counter
    x86/fpu: Remove use_eager_fpu()
  * ebtables: arpreply: Add the standard target sanity check
      include/linux/netfilter_bridge/ebtables.h
    ath10k: fix scan crash due to incorrect length calculation
    ubifs: Check for name being NULL while mounting
    ucma: fix a use-after-free in ucma_resolve_ip()
  * f2fs: fix invalid memory access
      fs/f2fs/checkpoint.c
    x86/mm: Expand static page table for fixmap space
    ARC: clone syscall to setp r25 as thread pointer
    powerpc/fadump: Return error when fadump registration fails
    ath10k: fix kernel panic issue during pci probe
    ath10k: fix use-after-free in ath10k_wmi_cmd_send_nowait
  * cgroup: Fix deadlock in cpu hotplug path
      kernel/cgroup.c
  * ext4: always verify the magic number in xattr blocks
      fs/ext4/xattr.c
  * ext4: add corruption check in ext4_xattr_set_entry()
      fs/ext4/xattr.c
    of: unittest: Disable interrupt node tests for old world MAC systems
  * tty: Drop tty->count on tty_reopen() failure
      drivers/tty/tty_io.c
    USB: serial: simple: add Motorola Tetra MTP6550 id
    usb: xhci-mtk: resume USB3 roothub first
  * xhci: Add missing CAS workaround for Intel Sunrise Point xHCI
      drivers/usb/host/xhci-pci.c
    dm cache: fix resize crash if user doesn't reload cache table
    dm cache metadata: ignore hints array being too small during resize
  * PM / core: Clear the direct_complete flag on errors
      drivers/base/power/main.c
    mac80211: fix setting IEEE80211_KEY_FLAG_RX_MGMT for AP mode keys
  * PCI: Reprogram bridge prefetch registers on resume
      drivers/pci/pci.c
    x86/vdso: Fix vDSO syscall fallback asm constraint regression
    x86/vdso: Fix asm constraints on vDSO syscall fallbacks
    xen-netback: fix input validation in xenvif_set_hash_mapping()
    fbdev/omapfb: fix omapfb_memory_read infoleak
  * mm/vmstat.c: skip NR_TLB_REMOTE_FLUSH* properly
      mm/vmstat.c
Linux 4.9.132
    dm thin metadata: fix __udivdi3 undefined on 32-bit
    ocfs2: fix locking for res->tracking and dlm->tracking_list
  * proc: restrict kernel stack dumps to root
      fs/proc/base.c
  * gpiolib: Free the last requested descriptor
      drivers/gpio/gpiolib.c
    crypto: mxs-dcp - Fix wait logic on chan threads
    crypto: qat - Fix KASAN stack-out-of-bounds bug in adf_probe()
    ALSA: hda/realtek - Cannot adjust speaker's volume on Dell XPS 27 7760
    smb2: fix missing files in root share directory listing
  * sysfs: Do not return POSIX ACL xattrs via listxattr
      fs/xattr.c
    xen: fix GCC warning and remove duplicate EVTCHN_ROW/EVTCHN_COL usage
    xen: avoid crash in disable_hotplug_cpu
    xen/manage: don't complain about an empty value in control/sysrq node
    cifs: read overflow in is_valid_oplock_break()
    s390/qeth: don't dump past end of unknown HW header
    s390/qeth: use vzalloc for QUERY OAT buffer
    r8169: Clear RTL_FLAG_TASK_*_PENDING when clearing RTL_FLAG_TASK_ENABLED
    arm64: jump_label.h: use asm_volatile_goto macro instead of "asm goto"
    hexagon: modify ffs() and fls() to return int
    arch/hexagon: fix kernel/dma.c build warning
    dm thin metadata: try to avoid ever aborting transactions
    perf/x86/intel: Add support/quirk for the MISPREDICT bit on Knights Landing CPUs
    net: ena: fix driver when PAGE_SIZE == 64kB
    fs/cifs: suppress a string overflow warning
    dm raid: fix rebuild of specific devices by updating superblock
    drm/nouveau/TBDdevinit: don't fail when PMU/PRE_OS is missing from VBIOS
    net/mlx5: Consider PCI domain in search for next dev
    nvmet-rdma: fix possible bogus dereference under heavy load
    USB: yurex: Check for truncation in yurex_read()
    RDMA/ucma: check fd type in ucma_migrate_id()
    perf probe powerpc: Ignore SyS symbols irrespective of endianness
    perf evsel: Fix potential null pointer dereference in perf_evsel__new_idx()
  * HID: hid-saitek: Add device ID for RAT 7 Contagion
      drivers/hid/hid-ids.h
    usb: gadget: fotg210-udc: Fix memory leak of fotg210->ep[i]
  * HID: add support for Apple Magic Keyboards
      drivers/hid/hid-apple.c
      drivers/hid/hid-ids.h
  * mm: madvise(MADV_DODUMP): allow hugetlbfs pages
      mm/madvise.c
    tools/vm/page-types.c: fix "defined but not used" warning
    tools/vm/slabinfo.c: fix sign-compare warning
    mac80211: shorten the IBSS debug messages
    mac80211: don't Tx a deauth frame if the AP forbade Tx
    mac80211: Fix station bandwidth setting after channel switch
    mac80211: fix a race between restart and CSA flows
  * cfg80211: fix a type issue in ieee80211_chandef_to_operating_class()
      net/wireless/util.c
    fs/cifs: don't translate SFM_SLASH (U+F026) to backslash
    net: cadence: Fix a sleep-in-atomic-context bug in macb_halt_tx()
    i2c: uniphier-f: issue STOP only for last message or I2C_M_STOP
    i2c: uniphier: issue STOP only for last message or I2C_M_STOP
    RAID10 BUG_ON in raise_barrier when force is true and conf->barrier is 0
    ARC: atomics: unbork atomic_fetch_##op()
  * gpio: Fix crash due to registration race
      drivers/gpio/gpiolib-of.c
  * cfg80211: nl80211_update_ft_ies() to validate NL80211_ATTR_IE
      net/wireless/nl80211.c
    net: hns: add netif_carrier_off before change speed and duplex
    mac80211: mesh: fix HWMP sequence numbering to follow standard
    gpio: adp5588: Fix sleep-in-atomic-context bug
    mac80211_hwsim: correct use of IEEE80211_VHT_CAP_RXSTBC_X
    mac80211: correct use of IEEE80211_VHT_CAP_RXSTBC_X
    KVM: PPC: Book3S HV: Don't truncate HPTE index in xlate function
    mac80211: Run TXQ teardown code before de-registering interfaces
  * time: Introduce jiffies64_to_nsecs()
      include/linux/jiffies.h
      kernel/time/time.c
      kernel/time/timeconst.bc
    serial: mvebu-uart: Fix reporting of effective CSIZE to userspace
Linux 4.9.131
  * media: v4l: event: Prevent freeing event subscriptions while accessed
      drivers/media/v4l2-core/v4l2-event.c
      drivers/media/v4l2-core/v4l2-fh.c
      include/media/v4l2-fh.h
    arm64: KVM: Sanitize PSTATE.M when being set from userspace
    i2c: i801: Allow ACPI AML access I/O ports not reserved for SMBus
  * arm/arm64: smccc-1.1: Handle function result as parameters
      include/linux/arm-smccc.h
  * arm/arm64: smccc-1.1: Make return values unsigned long
      include/linux/arm-smccc.h
    drm/amdgpu: Update power state at the end of smu hw_init.
    drm/amdgpu: Enable/disable gfx PG feature in rlc safe mode
    hwmon: (adt7475) Make adt7475_read_word() return errors
    hwmon: (ina2xx) fix sysfs shunt resistor read access
    e1000: ensure to free old tx/rx rings in set_ringparam()
    e1000: check on netif_running() before calling e1000_up()
    net: hns: fix skb->truesize underestimation
    net: hns: fix length and page_offset overflow when CONFIG_ARM64_64K_PAGES
  * thermal: of-thermal: disable passive polling when thermal zone is disabled
      drivers/thermal/of-thermal.c
    qed: Wait for MCP halt and resume commands to take place
    qed: Wait for ready indication before rereading the shmem
  * ext4: never move the system.data xattr out of the inode body
      fs/ext4/xattr.c
    arm64: KVM: Tighten guest core register access from userspace
    IB/hfi1: Fix SL array bounds check
    serial: imx: restore handshaking irq for imx1
    scsi: target: iscsi: Use bin2hex instead of a re-implementation
    IB/hfi1: Fix context recovery when PBC has an UnsupportedVL
    IB/hfi1: Invalid user input can result in crash
    IB/srp: Avoid that sg_reset -d ${srp_device} triggers an infinite loop
    Input: elantech - enable middle button of touchpad on ThinkPad P72
  * USB: remove LPM management from usb_driver_claim_interface()
      drivers/usb/core/driver.c
    Revert "usb: cdc-wdm: Fix a sleep-in-atomic-context bug in service_outstanding_interrupt()"
  * USB: usbdevfs: restore warning for nonsensical flags
      drivers/usb/core/devio.c
  * USB: usbdevfs: sanitize flags more
      drivers/usb/core/devio.c
    media: uvcvideo: Support realtek's UVC 1.5 device
  * slub: make ->cpu_partial unsigned int
      include/linux/slub_def.h
      mm/slub.c
  * USB: handle NULL config in usb_find_alt_setting()
      drivers/usb/core/usb.c
  * USB: fix error handling in usb_driver_claim_interface()
      drivers/usb/core/driver.c
  * regulator: fix crash caused by null driver data
      drivers/regulator/core.c
    spi: rspi: Fix interrupted DMA transfers
    spi: rspi: Fix invalid SPI use during system suspend
    spi: sh-msiof: Fix handling of write value for SISTR register
    spi: sh-msiof: Fix invalid SPI use during system suspend
    spi: tegra20-slink: explicitly enable/disable clock
    serial: cpm_uart: return immediately from console poll
    tty: serial: lpuart: avoid leaking struct tty_struct
    floppy: Do not copy a kernel pointer to user memory in FDGETPRM ioctl
    ARM: dts: dra7: fix DCAN node addresses
  * EDAC: Fix memleak in module init error path
      drivers/edac/edac_mc_sysfs.c
    nfsd: fix corrupted reply to badly ordered compound
    gpio: Fix wrong rounding in gpio-menz127
  * module: exclude SHN_UNDEF symbols from kallsyms api
      kernel/module.c
  * ASoC: dapm: Fix potential DAI widget pointer deref when linking DAIs
      sound/soc/soc-dapm.c
    EDAC, i7core: Fix memleaks and use-after-free on probe and remove
    scsi: megaraid_sas: Update controller info during resume
    scsi: bnx2i: add error handling for ioremap_nocache
    perf/x86/intel/lbr: Fix incomplete LBR call stack
    HID: hid-ntrig: add error handling for sysfs_create_group
    ARM: mvebu: declare asm symbols as character arrays in pmsu.c
    wlcore: Add missing PM call for wlcore_cmd_wait_for_event_or_timeout()
    rndis_wlan: potential buffer overflow in rndis_wlan_auth_indication()
    drm/sun4i: Fix releasing node when enumerating enpoints
    net: phy: xgmiitorgmii: Check phy_driver ready before accessing
    ath10k: protect ath10k_htt_rx_ring_free with rx_ring.lock
    net: phy: xgmiitorgmii: Check read_status results
    ALSA: hda: Add AZX_DCAPS_PM_RUNTIME for AMD Raven Ridge
    media: tm6000: add error handling for dvb_register_adapter
    drivers/tty: add error handling for pcmcia_loop_config
  * staging: android: ashmem: Fix mmap size validation
      drivers/staging/android/ashmem.c
    media: omap3isp: zero-initialize the isp cam_xclk{a,b} initial data
    media: soc_camera: ov772x: correct setting of banding filter
    media: s3c-camif: ignore -ENOIOCTLCMD from v4l2_subdev_call for s_power
    ALSA: snd-aoa: add of_node_put() in error path
    s390/extmem: fix gcc 8 stringop-overflow warning
  * alarmtimer: Prevent overflow for relative nanosleep
      kernel/time/alarmtimer.c
    powerpc/powernv/ioda2: Reduce upper limit for DMA window size
    usb: wusbcore: security: cast sizeof to int for comparison
    scsi: ibmvscsi: Improve strings handling
  * scsi: klist: Make it safe to use klists in atomic context
      lib/klist.c
    scsi: target/iscsi: Make iscsit_ta_authentication() respect the output buffer size
    x86/entry/64: Add two more instruction suffixes
    ARM: hwmod: RTC: Don't assume lock/unlock will be called with irq enabled
    x86/tsc: Add missing header to tsc_msr.c
    media: fsl-viu: fix error handling in viu_of_probe()
    powerpc/kdump: Handle crashkernel memory reservation failure
    media: exynos4-is: Prevent NULL pointer dereference in __isp_video_try_fmt()
    IB/core: type promotion bug in rdma_rw_init_one_mr()
    md-cluster: clear another node's suspend_area after the copy is finished
  * power: remove possible deadlock when unregistering power_supply
      drivers/power/supply/power_supply_core.c
      include/linux/power_supply.h
    s390/mm: correct allocate_pgste proc_handler callback
    6lowpan: iphc: reset mac_header after decompress to fix panic
    USB: serial: kobil_sct: fix modem-status error handling
    Bluetooth: Add a new Realtek 8723DE ID 0bda:b009
    iommu/amd: make sure TLB to be flushed before IOVA freed
    power: vexpress: fix corruption in notifier registration
    uwb: hwa-rc: fix memory leak at probe
    staging: rts5208: fix missing error check on call to rtsx_write_register
    x86/numa_emulation: Fix emulated-to-physical node mapping
    vmci: type promotion bug in qp_host_get_user_memory()
    tsl2550: fix lux1_input error in low light
  * crypto: skcipher - Fix -Wstringop-truncation warnings
      crypto/ablkcipher.c
      crypto/blkcipher.c

Change-Id: I20f8975728186d16d30d0be15426ff5a732935d1
Signed-off-by: Petri Gynther <pgynther@google.com>
2018-12-19 14:54:50 -08:00

805 lines
21 KiB
C

/*
* linux/kernel/time.c
*
* Copyright (C) 1991, 1992 Linus Torvalds
*
* This file contains the interface functions for the various
* time related system calls: time, stime, gettimeofday, settimeofday,
* adjtime
*/
/*
* Modification history kernel/time.c
*
* 1993-09-02 Philip Gladstone
* Created file with time related functions from sched/core.c and adjtimex()
* 1993-10-08 Torsten Duwe
* adjtime interface update and CMOS clock write code
* 1995-08-13 Torsten Duwe
* kernel PLL updated to 1994-12-13 specs (rfc-1589)
* 1999-01-16 Ulrich Windl
* Introduced error checking for many cases in adjtimex().
* Updated NTP code according to technical memorandum Jan '96
* "A Kernel Model for Precision Timekeeping" by Dave Mills
* Allow time_constant larger than MAXTC(6) for NTP v4 (MAXTC == 10)
* (Even though the technical memorandum forbids it)
* 2004-07-14 Christoph Lameter
* Added getnstimeofday to allow the posix timer functions to return
* with nanosecond accuracy
*/
#include <linux/export.h>
#include <linux/kernel.h>
#include <linux/timex.h>
#include <linux/capability.h>
#include <linux/timekeeper_internal.h>
#include <linux/errno.h>
#include <linux/syscalls.h>
#include <linux/security.h>
#include <linux/fs.h>
#include <linux/math64.h>
#include <linux/ptrace.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include <generated/timeconst.h>
#include "timekeeping.h"
/*
* The timezone where the local system is located. Used as a default by some
* programs who obtain this value by using gettimeofday.
*/
struct timezone sys_tz;
EXPORT_SYMBOL(sys_tz);
#ifdef __ARCH_WANT_SYS_TIME
/*
* sys_time() can be implemented in user-level using
* sys_gettimeofday(). Is this for backwards compatibility? If so,
* why not move it into the appropriate arch directory (for those
* architectures that need it).
*/
SYSCALL_DEFINE1(time, time_t __user *, tloc)
{
time_t i = get_seconds();
if (tloc) {
if (put_user(i,tloc))
return -EFAULT;
}
force_successful_syscall_return();
return i;
}
/*
* sys_stime() can be implemented in user-level using
* sys_settimeofday(). Is this for backwards compatibility? If so,
* why not move it into the appropriate arch directory (for those
* architectures that need it).
*/
SYSCALL_DEFINE1(stime, time_t __user *, tptr)
{
struct timespec tv;
int err;
if (get_user(tv.tv_sec, tptr))
return -EFAULT;
tv.tv_nsec = 0;
err = security_settime(&tv, NULL);
if (err)
return err;
do_settimeofday(&tv);
return 0;
}
#endif /* __ARCH_WANT_SYS_TIME */
SYSCALL_DEFINE2(gettimeofday, struct timeval __user *, tv,
struct timezone __user *, tz)
{
if (likely(tv != NULL)) {
struct timeval ktv;
do_gettimeofday(&ktv);
if (copy_to_user(tv, &ktv, sizeof(ktv)))
return -EFAULT;
}
if (unlikely(tz != NULL)) {
if (copy_to_user(tz, &sys_tz, sizeof(sys_tz)))
return -EFAULT;
}
return 0;
}
/*
* Indicates if there is an offset between the system clock and the hardware
* clock/persistent clock/rtc.
*/
int persistent_clock_is_local;
/*
* Adjust the time obtained from the CMOS to be UTC time instead of
* local time.
*
* This is ugly, but preferable to the alternatives. Otherwise we
* would either need to write a program to do it in /etc/rc (and risk
* confusion if the program gets run more than once; it would also be
* hard to make the program warp the clock precisely n hours) or
* compile in the timezone information into the kernel. Bad, bad....
*
* - TYT, 1992-01-01
*
* The best thing to do is to keep the CMOS clock in universal time (UTC)
* as real UNIX machines always do it. This avoids all headaches about
* daylight saving times and warping kernel clocks.
*/
static inline void warp_clock(void)
{
if (sys_tz.tz_minuteswest != 0) {
struct timespec adjust;
persistent_clock_is_local = 1;
adjust.tv_sec = sys_tz.tz_minuteswest * 60;
adjust.tv_nsec = 0;
timekeeping_inject_offset(&adjust);
}
}
/*
* In case for some reason the CMOS clock has not already been running
* in UTC, but in some local time: The first time we set the timezone,
* we will warp the clock so that it is ticking UTC time instead of
* local time. Presumably, if someone is setting the timezone then we
* are running in an environment where the programs understand about
* timezones. This should be done at boot time in the /etc/rc script,
* as soon as possible, so that the clock can be set right. Otherwise,
* various programs will get confused when the clock gets warped.
*/
int do_sys_settimeofday64(const struct timespec64 *tv, const struct timezone *tz)
{
static int firsttime = 1;
int error = 0;
if (tv && !timespec64_valid(tv))
return -EINVAL;
error = security_settime64(tv, tz);
if (error)
return error;
if (tz) {
/* Verify we're witin the +-15 hrs range */
if (tz->tz_minuteswest > 15*60 || tz->tz_minuteswest < -15*60)
return -EINVAL;
sys_tz = *tz;
update_vsyscall_tz();
if (firsttime) {
firsttime = 0;
if (!tv)
warp_clock();
}
}
if (tv)
return do_settimeofday64(tv);
return 0;
}
SYSCALL_DEFINE2(settimeofday, struct timeval __user *, tv,
struct timezone __user *, tz)
{
struct timeval user_tv;
struct timespec new_ts = {0};
struct timezone new_tz;
if (tv) {
if (copy_from_user(&user_tv, tv, sizeof(*tv)))
return -EFAULT;
if (!timeval_valid(&user_tv))
return -EINVAL;
new_ts.tv_sec = user_tv.tv_sec;
new_ts.tv_nsec = user_tv.tv_usec * NSEC_PER_USEC;
}
if (tz) {
if (copy_from_user(&new_tz, tz, sizeof(*tz)))
return -EFAULT;
}
return do_sys_settimeofday(tv ? &new_ts : NULL, tz ? &new_tz : NULL);
}
SYSCALL_DEFINE1(adjtimex, struct timex __user *, txc_p)
{
struct timex txc; /* Local copy of parameter */
int ret;
/* Copy the user data space into the kernel copy
* structure. But bear in mind that the structures
* may change
*/
if(copy_from_user(&txc, txc_p, sizeof(struct timex)))
return -EFAULT;
ret = do_adjtimex(&txc);
return copy_to_user(txc_p, &txc, sizeof(struct timex)) ? -EFAULT : ret;
}
/**
* current_fs_time - Return FS time
* @sb: Superblock.
*
* Return the current time truncated to the time granularity supported by
* the fs.
*/
struct timespec current_fs_time(struct super_block *sb)
{
struct timespec now = current_kernel_time();
return timespec_trunc(now, sb->s_time_gran);
}
EXPORT_SYMBOL(current_fs_time);
/*
* Convert jiffies to milliseconds and back.
*
* Avoid unnecessary multiplications/divisions in the
* two most common HZ cases:
*/
unsigned int jiffies_to_msecs(const unsigned long j)
{
#if HZ <= MSEC_PER_SEC && !(MSEC_PER_SEC % HZ)
return (MSEC_PER_SEC / HZ) * j;
#elif HZ > MSEC_PER_SEC && !(HZ % MSEC_PER_SEC)
return (j + (HZ / MSEC_PER_SEC) - 1)/(HZ / MSEC_PER_SEC);
#else
# if BITS_PER_LONG == 32
return (HZ_TO_MSEC_MUL32 * j + (1ULL << HZ_TO_MSEC_SHR32) - 1) >>
HZ_TO_MSEC_SHR32;
# else
return DIV_ROUND_UP(j * HZ_TO_MSEC_NUM, HZ_TO_MSEC_DEN);
# endif
#endif
}
EXPORT_SYMBOL(jiffies_to_msecs);
unsigned int jiffies_to_usecs(const unsigned long j)
{
/*
* Hz usually doesn't go much further MSEC_PER_SEC.
* jiffies_to_usecs() and usecs_to_jiffies() depend on that.
*/
BUILD_BUG_ON(HZ > USEC_PER_SEC);
#if !(USEC_PER_SEC % HZ)
return (USEC_PER_SEC / HZ) * j;
#else
# if BITS_PER_LONG == 32
return (HZ_TO_USEC_MUL32 * j) >> HZ_TO_USEC_SHR32;
# else
return (j * HZ_TO_USEC_NUM) / HZ_TO_USEC_DEN;
# endif
#endif
}
EXPORT_SYMBOL(jiffies_to_usecs);
/**
* timespec_trunc - Truncate timespec to a granularity
* @t: Timespec
* @gran: Granularity in ns.
*
* Truncate a timespec to a granularity. Always rounds down. gran must
* not be 0 nor greater than a second (NSEC_PER_SEC, or 10^9 ns).
*/
struct timespec timespec_trunc(struct timespec t, unsigned gran)
{
/* Avoid division in the common cases 1 ns and 1 s. */
if (gran == 1) {
/* nothing */
} else if (gran == NSEC_PER_SEC) {
t.tv_nsec = 0;
} else if (gran > 1 && gran < NSEC_PER_SEC) {
t.tv_nsec -= t.tv_nsec % gran;
} else {
WARN(1, "illegal file time granularity: %u", gran);
}
return t;
}
EXPORT_SYMBOL(timespec_trunc);
/*
* mktime64 - Converts date to seconds.
* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
* Assumes input in normal date format, i.e. 1980-12-31 23:59:59
* => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
*
* [For the Julian calendar (which was used in Russia before 1917,
* Britain & colonies before 1752, anywhere else before 1582,
* and is still in use by some communities) leave out the
* -year/100+year/400 terms, and add 10.]
*
* This algorithm was first published by Gauss (I think).
*
* A leap second can be indicated by calling this function with sec as
* 60 (allowable under ISO 8601). The leap second is treated the same
* as the following second since they don't exist in UNIX time.
*
* An encoding of midnight at the end of the day as 24:00:00 - ie. midnight
* tomorrow - (allowable under ISO 8601) is supported.
*/
time64_t mktime64(const unsigned int year0, const unsigned int mon0,
const unsigned int day, const unsigned int hour,
const unsigned int min, const unsigned int sec)
{
unsigned int mon = mon0, year = year0;
/* 1..12 -> 11,12,1..10 */
if (0 >= (int) (mon -= 2)) {
mon += 12; /* Puts Feb last since it has leap day */
year -= 1;
}
return ((((time64_t)
(year/4 - year/100 + year/400 + 367*mon/12 + day) +
year*365 - 719499
)*24 + hour /* now have hours - midnight tomorrow handled here */
)*60 + min /* now have minutes */
)*60 + sec; /* finally seconds */
}
EXPORT_SYMBOL(mktime64);
/**
* set_normalized_timespec - set timespec sec and nsec parts and normalize
*
* @ts: pointer to timespec variable to be set
* @sec: seconds to set
* @nsec: nanoseconds to set
*
* Set seconds and nanoseconds field of a timespec variable and
* normalize to the timespec storage format
*
* Note: The tv_nsec part is always in the range of
* 0 <= tv_nsec < NSEC_PER_SEC
* For negative values only the tv_sec field is negative !
*/
void set_normalized_timespec(struct timespec *ts, time_t sec, s64 nsec)
{
while (nsec >= NSEC_PER_SEC) {
/*
* The following asm() prevents the compiler from
* optimising this loop into a modulo operation. See
* also __iter_div_u64_rem() in include/linux/time.h
*/
asm("" : "+rm"(nsec));
nsec -= NSEC_PER_SEC;
++sec;
}
while (nsec < 0) {
asm("" : "+rm"(nsec));
nsec += NSEC_PER_SEC;
--sec;
}
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
EXPORT_SYMBOL(set_normalized_timespec);
/**
* ns_to_timespec - Convert nanoseconds to timespec
* @nsec: the nanoseconds value to be converted
*
* Returns the timespec representation of the nsec parameter.
*/
struct timespec ns_to_timespec(const s64 nsec)
{
struct timespec ts;
s32 rem;
if (!nsec)
return (struct timespec) {0, 0};
ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem);
if (unlikely(rem < 0)) {
ts.tv_sec--;
rem += NSEC_PER_SEC;
}
ts.tv_nsec = rem;
return ts;
}
EXPORT_SYMBOL(ns_to_timespec);
/**
* ns_to_timeval - Convert nanoseconds to timeval
* @nsec: the nanoseconds value to be converted
*
* Returns the timeval representation of the nsec parameter.
*/
struct timeval ns_to_timeval(const s64 nsec)
{
struct timespec ts = ns_to_timespec(nsec);
struct timeval tv;
tv.tv_sec = ts.tv_sec;
tv.tv_usec = (suseconds_t) ts.tv_nsec / 1000;
return tv;
}
EXPORT_SYMBOL(ns_to_timeval);
#if BITS_PER_LONG == 32
/**
* set_normalized_timespec - set timespec sec and nsec parts and normalize
*
* @ts: pointer to timespec variable to be set
* @sec: seconds to set
* @nsec: nanoseconds to set
*
* Set seconds and nanoseconds field of a timespec variable and
* normalize to the timespec storage format
*
* Note: The tv_nsec part is always in the range of
* 0 <= tv_nsec < NSEC_PER_SEC
* For negative values only the tv_sec field is negative !
*/
void set_normalized_timespec64(struct timespec64 *ts, time64_t sec, s64 nsec)
{
while (nsec >= NSEC_PER_SEC) {
/*
* The following asm() prevents the compiler from
* optimising this loop into a modulo operation. See
* also __iter_div_u64_rem() in include/linux/time.h
*/
asm("" : "+rm"(nsec));
nsec -= NSEC_PER_SEC;
++sec;
}
while (nsec < 0) {
asm("" : "+rm"(nsec));
nsec += NSEC_PER_SEC;
--sec;
}
ts->tv_sec = sec;
ts->tv_nsec = nsec;
}
EXPORT_SYMBOL(set_normalized_timespec64);
/**
* ns_to_timespec64 - Convert nanoseconds to timespec64
* @nsec: the nanoseconds value to be converted
*
* Returns the timespec64 representation of the nsec parameter.
*/
struct timespec64 ns_to_timespec64(const s64 nsec)
{
struct timespec64 ts;
s32 rem;
if (!nsec)
return (struct timespec64) {0, 0};
ts.tv_sec = div_s64_rem(nsec, NSEC_PER_SEC, &rem);
if (unlikely(rem < 0)) {
ts.tv_sec--;
rem += NSEC_PER_SEC;
}
ts.tv_nsec = rem;
return ts;
}
EXPORT_SYMBOL(ns_to_timespec64);
#endif
/**
* msecs_to_jiffies: - convert milliseconds to jiffies
* @m: time in milliseconds
*
* conversion is done as follows:
*
* - negative values mean 'infinite timeout' (MAX_JIFFY_OFFSET)
*
* - 'too large' values [that would result in larger than
* MAX_JIFFY_OFFSET values] mean 'infinite timeout' too.
*
* - all other values are converted to jiffies by either multiplying
* the input value by a factor or dividing it with a factor and
* handling any 32-bit overflows.
* for the details see __msecs_to_jiffies()
*
* msecs_to_jiffies() checks for the passed in value being a constant
* via __builtin_constant_p() allowing gcc to eliminate most of the
* code, __msecs_to_jiffies() is called if the value passed does not
* allow constant folding and the actual conversion must be done at
* runtime.
* the _msecs_to_jiffies helpers are the HZ dependent conversion
* routines found in include/linux/jiffies.h
*/
unsigned long __msecs_to_jiffies(const unsigned int m)
{
/*
* Negative value, means infinite timeout:
*/
if ((int)m < 0)
return MAX_JIFFY_OFFSET;
return _msecs_to_jiffies(m);
}
EXPORT_SYMBOL(__msecs_to_jiffies);
unsigned long __usecs_to_jiffies(const unsigned int u)
{
if (u > jiffies_to_usecs(MAX_JIFFY_OFFSET))
return MAX_JIFFY_OFFSET;
return _usecs_to_jiffies(u);
}
EXPORT_SYMBOL(__usecs_to_jiffies);
/*
* The TICK_NSEC - 1 rounds up the value to the next resolution. Note
* that a remainder subtract here would not do the right thing as the
* resolution values don't fall on second boundries. I.e. the line:
* nsec -= nsec % TICK_NSEC; is NOT a correct resolution rounding.
* Note that due to the small error in the multiplier here, this
* rounding is incorrect for sufficiently large values of tv_nsec, but
* well formed timespecs should have tv_nsec < NSEC_PER_SEC, so we're
* OK.
*
* Rather, we just shift the bits off the right.
*
* The >> (NSEC_JIFFIE_SC - SEC_JIFFIE_SC) converts the scaled nsec
* value to a scaled second value.
*/
static unsigned long
__timespec64_to_jiffies(u64 sec, long nsec)
{
nsec = nsec + TICK_NSEC - 1;
if (sec >= MAX_SEC_IN_JIFFIES){
sec = MAX_SEC_IN_JIFFIES;
nsec = 0;
}
return ((sec * SEC_CONVERSION) +
(((u64)nsec * NSEC_CONVERSION) >>
(NSEC_JIFFIE_SC - SEC_JIFFIE_SC))) >> SEC_JIFFIE_SC;
}
static unsigned long
__timespec_to_jiffies(unsigned long sec, long nsec)
{
return __timespec64_to_jiffies((u64)sec, nsec);
}
unsigned long
timespec64_to_jiffies(const struct timespec64 *value)
{
return __timespec64_to_jiffies(value->tv_sec, value->tv_nsec);
}
EXPORT_SYMBOL(timespec64_to_jiffies);
void
jiffies_to_timespec64(const unsigned long jiffies, struct timespec64 *value)
{
/*
* Convert jiffies to nanoseconds and separate with
* one divide.
*/
u32 rem;
value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC,
NSEC_PER_SEC, &rem);
value->tv_nsec = rem;
}
EXPORT_SYMBOL(jiffies_to_timespec64);
/*
* We could use a similar algorithm to timespec_to_jiffies (with a
* different multiplier for usec instead of nsec). But this has a
* problem with rounding: we can't exactly add TICK_NSEC - 1 to the
* usec value, since it's not necessarily integral.
*
* We could instead round in the intermediate scaled representation
* (i.e. in units of 1/2^(large scale) jiffies) but that's also
* perilous: the scaling introduces a small positive error, which
* combined with a division-rounding-upward (i.e. adding 2^(scale) - 1
* units to the intermediate before shifting) leads to accidental
* overflow and overestimates.
*
* At the cost of one additional multiplication by a constant, just
* use the timespec implementation.
*/
unsigned long
timeval_to_jiffies(const struct timeval *value)
{
return __timespec_to_jiffies(value->tv_sec,
value->tv_usec * NSEC_PER_USEC);
}
EXPORT_SYMBOL(timeval_to_jiffies);
void jiffies_to_timeval(const unsigned long jiffies, struct timeval *value)
{
/*
* Convert jiffies to nanoseconds and separate with
* one divide.
*/
u32 rem;
value->tv_sec = div_u64_rem((u64)jiffies * TICK_NSEC,
NSEC_PER_SEC, &rem);
value->tv_usec = rem / NSEC_PER_USEC;
}
EXPORT_SYMBOL(jiffies_to_timeval);
/*
* Convert jiffies/jiffies_64 to clock_t and back.
*/
clock_t jiffies_to_clock_t(unsigned long x)
{
#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
# if HZ < USER_HZ
return x * (USER_HZ / HZ);
# else
return x / (HZ / USER_HZ);
# endif
#else
return div_u64((u64)x * TICK_NSEC, NSEC_PER_SEC / USER_HZ);
#endif
}
EXPORT_SYMBOL(jiffies_to_clock_t);
unsigned long clock_t_to_jiffies(unsigned long x)
{
#if (HZ % USER_HZ)==0
if (x >= ~0UL / (HZ / USER_HZ))
return ~0UL;
return x * (HZ / USER_HZ);
#else
/* Don't worry about loss of precision here .. */
if (x >= ~0UL / HZ * USER_HZ)
return ~0UL;
/* .. but do try to contain it here */
return div_u64((u64)x * HZ, USER_HZ);
#endif
}
EXPORT_SYMBOL(clock_t_to_jiffies);
u64 jiffies_64_to_clock_t(u64 x)
{
#if (TICK_NSEC % (NSEC_PER_SEC / USER_HZ)) == 0
# if HZ < USER_HZ
x = div_u64(x * USER_HZ, HZ);
# elif HZ > USER_HZ
x = div_u64(x, HZ / USER_HZ);
# else
/* Nothing to do */
# endif
#else
/*
* There are better ways that don't overflow early,
* but even this doesn't overflow in hundreds of years
* in 64 bits, so..
*/
x = div_u64(x * TICK_NSEC, (NSEC_PER_SEC / USER_HZ));
#endif
return x;
}
EXPORT_SYMBOL(jiffies_64_to_clock_t);
u64 nsec_to_clock_t(u64 x)
{
#if (NSEC_PER_SEC % USER_HZ) == 0
return div_u64(x, NSEC_PER_SEC / USER_HZ);
#elif (USER_HZ % 512) == 0
return div_u64(x * USER_HZ / 512, NSEC_PER_SEC / 512);
#else
/*
* max relative error 5.7e-8 (1.8s per year) for USER_HZ <= 1024,
* overflow after 64.99 years.
* exact for HZ=60, 72, 90, 120, 144, 180, 300, 600, 900, ...
*/
return div_u64(x * 9, (9ull * NSEC_PER_SEC + (USER_HZ / 2)) / USER_HZ);
#endif
}
u64 jiffies64_to_nsecs(u64 j)
{
#if !(NSEC_PER_SEC % HZ)
return (NSEC_PER_SEC / HZ) * j;
# else
return div_u64(j * HZ_TO_NSEC_NUM, HZ_TO_NSEC_DEN);
#endif
}
EXPORT_SYMBOL(jiffies64_to_nsecs);
/**
* nsecs_to_jiffies64 - Convert nsecs in u64 to jiffies64
*
* @n: nsecs in u64
*
* Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64.
* And this doesn't return MAX_JIFFY_OFFSET since this function is designed
* for scheduler, not for use in device drivers to calculate timeout value.
*
* note:
* NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
* ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
*/
u64 nsecs_to_jiffies64(u64 n)
{
#if (NSEC_PER_SEC % HZ) == 0
/* Common case, HZ = 100, 128, 200, 250, 256, 500, 512, 1000 etc. */
return div_u64(n, NSEC_PER_SEC / HZ);
#elif (HZ % 512) == 0
/* overflow after 292 years if HZ = 1024 */
return div_u64(n * HZ / 512, NSEC_PER_SEC / 512);
#else
/*
* Generic case - optimized for cases where HZ is a multiple of 3.
* overflow after 64.99 years, exact for HZ = 60, 72, 90, 120 etc.
*/
return div_u64(n * 9, (9ull * NSEC_PER_SEC + HZ / 2) / HZ);
#endif
}
EXPORT_SYMBOL(nsecs_to_jiffies64);
/**
* nsecs_to_jiffies - Convert nsecs in u64 to jiffies
*
* @n: nsecs in u64
*
* Unlike {m,u}secs_to_jiffies, type of input is not unsigned int but u64.
* And this doesn't return MAX_JIFFY_OFFSET since this function is designed
* for scheduler, not for use in device drivers to calculate timeout value.
*
* note:
* NSEC_PER_SEC = 10^9 = (5^9 * 2^9) = (1953125 * 512)
* ULLONG_MAX ns = 18446744073.709551615 secs = about 584 years
*/
unsigned long nsecs_to_jiffies(u64 n)
{
return (unsigned long)nsecs_to_jiffies64(n);
}
EXPORT_SYMBOL_GPL(nsecs_to_jiffies);
/*
* Add two timespec values and do a safety check for overflow.
* It's assumed that both values are valid (>= 0)
*/
struct timespec timespec_add_safe(const struct timespec lhs,
const struct timespec rhs)
{
struct timespec res;
set_normalized_timespec(&res, lhs.tv_sec + rhs.tv_sec,
lhs.tv_nsec + rhs.tv_nsec);
if (res.tv_sec < lhs.tv_sec || res.tv_sec < rhs.tv_sec)
res.tv_sec = TIME_T_MAX;
return res;
}
/*
* Add two timespec64 values and do a safety check for overflow.
* It's assumed that both values are valid (>= 0).
* And, each timespec64 is in normalized form.
*/
struct timespec64 timespec64_add_safe(const struct timespec64 lhs,
const struct timespec64 rhs)
{
struct timespec64 res;
set_normalized_timespec64(&res, (timeu64_t) lhs.tv_sec + rhs.tv_sec,
lhs.tv_nsec + rhs.tv_nsec);
if (unlikely(res.tv_sec < lhs.tv_sec || res.tv_sec < rhs.tv_sec)) {
res.tv_sec = TIME64_MAX;
res.tv_nsec = 0;
}
return res;
}