Skip to content
Permalink
Xin-Ji/dt-bind…
Switch branches/tags

Commits on Jan 21, 2022

  1. usb: typec: anx7411: Add Analogix PD ANX7411 support

    Add driver for analogix ANX7411 USB Type-C DRP port controller.
    
    Signed-off-by: Xin Ji <xji@analogixsemi.com>
    Xin Ji authored and intel-lab-lkp committed Jan 21, 2022
  2. dt-bindings: usb: Add analogix anx7411 PD binding

    Add analogix PD chip anx7411 device binding
    
    Signed-off-by: Xin Ji <xji@analogixsemi.com>
    Xin Ji authored and intel-lab-lkp committed Jan 21, 2022

Commits on Jan 8, 2022

  1. docs: ABI: fixed formatting in configfs-usb-gadget-uac2

    Added missing tab, line breaks.
    
    Fixes: e3088eb ("docs: ABI: added missing num_requests param to UAC2")
    Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
    Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
    Link: https://lore.kernel.org/r/20220108105608.10726-1-pavel.hofman@ivitera.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    pavhofman authored and gregkh committed Jan 8, 2022

Commits on Jan 6, 2022

  1. usb: gadget: u_audio: Subdevice 0 for capture ctls

    Both capture and playback alsa devices use subdevice 0. Yet capture-side
    ctls are defined for subdevice 1. The patch sets subdevice 0 for them.
    
    Fixes: 02de698 ("usb: gadget: u_audio: add bi-directional volume and mute support")
    Signed-off-by: Pavel Hofman <pavel.hofman@ivitera.com>
    Link: https://lore.kernel.org/r/20220105104643.90125-1-pavel.hofman@ivitera.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    pavhofman authored and gregkh committed Jan 6, 2022
  2. usb: gadget: u_audio: fix calculations for small bInterval

    If bInterval is 1, then p_interval is 8000 and p_interval_mil is 8E9,
    which is too big for a 32-bit value.  While the storage is indeed
    64-bit, this value is used as the divisor in do_div() which will
    truncate it into a uint32_t leading to incorrect calculated values.
    
    Switch back to keeping the base value in struct snd_uac_chip which fits
    easily into an int, meaning that the division can be done in two steps
    with the divisor fitting safely into a uint32_t on both steps.
    
    Fixes: 6fec018 ("usb: gadget: u_audio.c: Adding Playback Pitch ctl for sync playback")
    Tested-by: Pavel Hofman <pavel.hofman@ivitera.com>
    Signed-off-by: John Keeping <john@metanate.com>
    Link: https://lore.kernel.org/r/20220104183243.718258-1-john@metanate.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    johnkeeping authored and gregkh committed Jan 6, 2022
  3. usb: dwc2: gadget: initialize max_speed from params

    DWC2 may be paired with a full-speed PHY which is not capable of
    high-speed operation.  Report this correctly to the gadget core by
    setting max_speed from the core parameters.
    
    Prior to commit 5324bad ("usb: dwc2: gadget: implement
    udc_set_speed()") this didn't cause the hardware to be configured
    incorrectly, although the speed may have been reported incorrectly.  But
    after that commit params.speed is updated based on a value passed in by
    the gadget core which may set it to a faster speed than is supported by
    the hardware.  Initialising the max_speed parameter ensures the speed
    passed to dwc2_gadget_set_speed() will be one supported by the hardware.
    
    Fixes: 5324bad ("usb: dwc2: gadget: implement udc_set_speed()")
    Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
    Signed-off-by: John Keeping <john@metanate.com>
    Link: https://lore.kernel.org/r/20220106115731.1473909-1-john@metanate.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    johnkeeping authored and gregkh committed Jan 6, 2022
  4. usb: dwc2: do not gate off the hardware if it does not support clock …

    …gating
    
    We should not be clearing the HCD_FLAG_HW_ACCESSIBLE bit if the hardware
    does not support clock gating.
    
    Fixes: 50fb0c1 ("usb: dwc2: Add clock gating entering flow by system suspend")
    Acked-by: Minas Harutyunyan <Minas.Harutyunyan@synopsys.com>
    Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
    Link: https://lore.kernel.org/r/20220104135922.734776-1-dinguyen@kernel.org
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Dinh Nguyen authored and gregkh committed Jan 6, 2022
  5. usb: dwc3: qcom: Fix NULL vs IS_ERR checking in dwc3_qcom_probe

    Since the acpi_create_platform_device() function may return error
    pointers, dwc3_qcom_create_urs_usb_platdev() function may return error
    pointers too. Using IS_ERR_OR_NULL() to check the return value to fix this.
    
    Fixes: c25c210 ("usb: dwc3: qcom: add URS Host support for sdm845 ACPI boot")
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20211222111823.22887-1-linmq006@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Yuuoniy authored and gregkh committed Jan 6, 2022

Commits on Jan 5, 2022

  1. headers/deps: USB: Optimize <linux/usb/ch9.h> dependencies, remove <l…

    …inux/device.h>
    
    The <linux/usb/ch9.h> header is used over 1,400 times in a typical distro
    build, but few of its users actually need the full <linux/device.h> header.
    
              --------------------------------------------------------------------
              | Combined, preprocessed C code size of header, without line markers,
              | with comments stripped:
              -------------------------
      before: | #include <linux/usb/ch9.h>              | LOC:  7,078 | headers:  172
       after: | #include <linux/usb/ch9.h>              | LOC:    812 | headers:   38
    
    Remove it and add it to the places that need it.
    
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Ingo Molnar authored and gregkh committed Jan 5, 2022
  2. USB: common: debug: add needed kernel.h include

    drivers/usb/common/debug.c was only including one usb .h file, which
    would then accidentally drag in other .h files that were really needed.
    Fix up the implict dependancy by correctly adding kernel.h to the file.
    
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    gregkh committed Jan 5, 2022
  3. headers/prep: Fix non-standard header section: drivers/usb/host/ohci-…

    …tmio.c
    
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Ingo Molnar authored and gregkh committed Jan 5, 2022
  4. headers/prep: Fix non-standard header section: drivers/usb/cdns3/core.h

    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Ingo Molnar authored and gregkh committed Jan 5, 2022
  5. headers/prep: usb: gadget: Fix namespace collision

    Avoid namespace collision with dev_ioctl() and dev_open(), also provided by generic headers.
    
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Ingo Molnar authored and gregkh committed Jan 5, 2022

Commits on Jan 3, 2022

  1. USB: core: Fix bug in resuming hub's handling of wakeup requests

    Bugzilla #213839 reports a 7-port hub that doesn't work properly when
    devices are plugged into some of the ports; the kernel goes into an
    unending disconnect/reinitialize loop as shown in the bug report.
    
    This "7-port hub" comprises two four-port hubs with one plugged into
    the other; the failures occur when a device is plugged into one of the
    downstream hub's ports.  (These hubs have other problems too.  For
    example, they bill themselves as USB-2.0 compliant but they only run
    at full speed.)
    
    It turns out that the failures are caused by bugs in both the kernel
    and the hub.  The hub's bug is that it reports a different
    bmAttributes value in its configuration descriptor following a remote
    wakeup (0xe0 before, 0xc0 after -- the wakeup-support bit has
    changed).
    
    The kernel's bug is inside the hub driver's resume handler.  When
    hub_activate() sees that one of the hub's downstream ports got a
    wakeup request from a child device, it notes this fact by setting the
    corresponding bit in the hub->change_bits variable.  But this variable
    is meant for connection changes, not wakeup events; setting it causes
    the driver to believe the downstream port has been disconnected and
    then connected again (in addition to having received a wakeup
    request).
    
    Because of this, the hub driver then tries to check whether the device
    currently plugged into the downstream port is the same as the device
    that had been attached there before.  Normally this check succeeds and
    wakeup handling continues with no harm done (which is why the bug
    remained undetected until now).  But with these dodgy hubs, the check
    fails because the config descriptor has changed.  This causes the hub
    driver to reinitialize the child device, leading to the
    disconnect/reinitialize loop described in the bug report.
    
    The proper way to note reception of a downstream wakeup request is
    to set a bit in the hub->event_bits variable instead of
    hub->change_bits.  That way the hub driver will realize that something
    has happened to the port but will not think the port and child device
    have been disconnected.  This patch makes that change.
    
    Cc: <stable@vger.kernel.org>
    Tested-by: Jonathan McDowell <noodles@earth.li>
    Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
    Link: https://lore.kernel.org/r/YdCw7nSfWYPKWQoD@rowland.harvard.edu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    AlanStern authored and gregkh committed Jan 3, 2022
  2. USB: Fix "slab-out-of-bounds Write" bug in usb_hcd_poll_rh_status

    When the USB core code for getting root-hub status reports was
    originally written, it was assumed that the hub driver would be its
    only caller.  But this isn't true now; user programs can use usbfs to
    communicate with root hubs and get status reports.  When they do this,
    they may use a transfer_buffer that is smaller than the data returned
    by the HCD, which will lead to a buffer overflow error when
    usb_hcd_poll_rh_status() tries to store the status data.  This was
    discovered by syzbot:
    
    BUG: KASAN: slab-out-of-bounds in memcpy include/linux/fortify-string.h:225 [inline]
    BUG: KASAN: slab-out-of-bounds in usb_hcd_poll_rh_status+0x5f4/0x780 drivers/usb/core/hcd.c:776
    Write of size 2 at addr ffff88801da403c0 by task syz-executor133/4062
    
    This patch fixes the bug by reducing the amount of status data if it
    won't fit in the transfer_buffer.  If some data gets discarded then
    the URB's completion status is set to -EOVERFLOW rather than 0, to let
    the user know what happened.
    
    Reported-and-tested-by: syzbot+3ae6a2b06f131ab9849f@syzkaller.appspotmail.com
    Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
    Cc: <stable@vger.kernel.org>
    Link: https://lore.kernel.org/r/Yc+3UIQJ2STbxNua@rowland.harvard.edu
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    AlanStern authored and gregkh committed Jan 3, 2022
  3. usb: dwc3: dwc3-qcom: Add missing platform_device_put() in dwc3_qcom_…

    …acpi_register_core
    
    Add the missing platform_device_put() before return from
    dwc3_qcom_acpi_register_core in the error handling case.
    
    Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
    Link: https://lore.kernel.org/r/20211231113641.31474-1-linmq006@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    Yuuoniy authored and gregkh committed Jan 3, 2022
  4. usb: gadget: clear related members when goto fail

    dev->config and dev->hs_config and dev->dev need to be cleaned if
    dev_config fails to avoid UAF.
    
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Link: https://lore.kernel.org/r/20211231172138.7993-3-hbh25y@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    HBh25Y authored and gregkh committed Jan 3, 2022
  5. usb: gadget: don't release an existing dev->buf

    dev->buf does not need to be released if it already exists before
    executing dev_config.
    
    Acked-by: Alan Stern <stern@rowland.harvard.edu>
    Signed-off-by: Hangyu Hua <hbh25y@gmail.com>
    Link: https://lore.kernel.org/r/20211231172138.7993-2-hbh25y@gmail.com
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    HBh25Y authored and gregkh committed Jan 3, 2022
  6. Merge tag 'thunderbolt-for-v5.17-rc1' of git://git.kernel.org/pub/scm…

    …/linux/kernel/git/westeri/thunderbolt into usb-next
    
    Mika writes:
    
    thunderbolt: Changes for v5.17 merge window
    
    This includes following Thunderbolt/USB4 changes for the v5.17 merge
    window:
    
      * Enable low-power link state (CL0s) for USB4 and Intel Titan Ridge
        devices
      * Add support for TMU (Time Management Unit) uni-directional mode
      * Power management improvements (suspend-to-disk, runtime PM)
      * USB4 compatibility fixes
      * Minor fixes and cleanups.
    
    All these have been in linux-next with no reported issues.
    
    * tag 'thunderbolt-for-v5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/westeri/thunderbolt:
      thunderbolt: Add module parameter for CLx disabling
      thunderbolt: Enable CL0s for Intel Titan Ridge
      thunderbolt: Rename Intel TB_VSE_CAP_IECS capability
      thunderbolt: Implement TMU time disruption for Intel Titan Ridge
      thunderbolt: Move usb4_switch_wait_for_bit() to switch.c
      thunderbolt: Add CL0s support for USB4 routers
      thunderbolt: Add TMU uni-directional mode
      thunderbolt: Check return value of kmemdup() in icm_handle_event()
      thunderbolt: Do not dereference fwnode in struct device
      thunderbolt: Add debug logging of DisplayPort resource allocation
      thunderbolt: Do not program path HopIDs for USB4 routers
      thunderbolt: Do not allow subtracting more NFC credits than configured
      thunderbolt: Runtime resume USB4 port when retimers are scanned
      thunderbolt: Tear down existing tunnels when resuming from hibernate
      thunderbolt: Runtime PM activate both ends of the device link
      thunderbolt: xdomain: Avoid potential stack OOB read
    gregkh committed Jan 3, 2022
  7. Merge 5.16-rc8 into usb-next

    We need the USB fixes in here as well.
    
    Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
    gregkh committed Jan 3, 2022

Commits on Jan 2, 2022

  1. Linux 5.16-rc8

    torvalds committed Jan 2, 2022
  2. Merge tag 'perf-tools-fixes-for-v5.16-2022-01-02' of git://git.kernel…

    ….org/pub/scm/linux/kernel/git/acme/linux
    
    Pull perf tools fixes from Arnaldo Carvalho de Melo:
    
     - Fix TUI exit screen refresh race condition in 'perf top'.
    
     - Fix parsing of Intel PT VM time correlation arguments.
    
     - Honour CPU filtering command line request of a script's switch events
       in 'perf script'.
    
     - Fix printing of switch events in Intel PT python script.
    
     - Fix duplicate alias events list printing in 'perf list', noticed on
       heterogeneous arm64 systems.
    
     - Fix return value of ids__new(), users expect NULL for failure, not
       ERR_PTR(-ENOMEM).
    
    * tag 'perf-tools-fixes-for-v5.16-2022-01-02' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux:
      perf top: Fix TUI exit screen refresh race condition
      perf pmu: Fix alias events list
      perf scripts python: intel-pt-events.py: Fix printing of switch events
      perf script: Fix CPU filtering of a script's switch events
      perf intel-pt: Fix parsing of VM time correlation arguments
      perf expr: Fix return value of ids__new()
    torvalds committed Jan 2, 2022
  3. Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/…

    …kernel/git/wsa/linux
    
    Pull i2c fixes from Wolfram Sang:
     "Better input validation for compat ioctls and a documentation bugfix
      for 5.16"
    
    * 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
      Docs: Fixes link to I2C specification
      i2c: validate user data in compat ioctl
    torvalds committed Jan 2, 2022
  4. Merge tag 'x86_urgent_for_v5.16_rc8' of git://git.kernel.org/pub/scm/…

    …linux/kernel/git/tip/tip
    
    Pull x86 fix from Borislav Petkov:
    
     - Use the proper CONFIG symbol in a preprocessor check.
    
    * tag 'x86_urgent_for_v5.16_rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
      x86/build: Use the proper name CONFIG_FW_LOADER
    torvalds committed Jan 2, 2022
  5. perf top: Fix TUI exit screen refresh race condition

    When the following command is executed several times, a coredump file is
    generated.
    
    	$ timeout -k 9 5 perf top -e task-clock
    	*******
    	*******
    	*******
    	0.01%  [kernel]                  [k] __do_softirq
    	0.01%  libpthread-2.28.so        [.] __pthread_mutex_lock
    	0.01%  [kernel]                  [k] __ll_sc_atomic64_sub_return
    	double free or corruption (!prev) perf top --sort comm,dso
    	timeout: the monitored command dumped core
    
    When we terminate "perf top" using sending signal method,
    SLsmg_reset_smg() called. SLsmg_reset_smg() resets the SLsmg screen
    management routines by freeing all memory allocated while it was active.
    
    However SLsmg_reinit_smg() maybe be called by another thread.
    
    SLsmg_reinit_smg() will free the same memory accessed by
    SLsmg_reset_smg(), thus it results in a double free.
    
    SLsmg_reinit_smg() is called already protected by ui__lock, so we fix
    the problem by adding pthread_mutex_trylock of ui__lock when calling
    SLsmg_reset_smg().
    
    Signed-off-by: Wenyu Liu <liuwenyu7@huawei.com>
    Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: wuxu.wu@huawei.com
    Link: http://lore.kernel.org/lkml/a91e3943-7ddc-f5c0-a7f5-360f073c20e6@huawei.com
    Signed-off-by: Hewenliang <hewenliang4@huawei.com>
    Signed-off-by: yaowenbin <yaowenbin1@huawei.com>
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    yaowenbin authored and Arnaldo Carvalho de Melo committed Jan 2, 2022
  6. perf pmu: Fix alias events list

    Commit 0e0ae87 ("perf list: Display hybrid PMU events with cpu
    type") changes the event list for uncore PMUs or arm64 heterogeneous CPU
    systems, such that duplicate aliases are incorrectly listed per PMU
    (which they should not be), like:
    
      # perf list
      ...
      unc_cbo_cache_lookup.any_es
      [Unit: uncore_cbox L3 Lookup any request that access cache and found
      line in E or S-state]
      unc_cbo_cache_lookup.any_es
      [Unit: uncore_cbox L3 Lookup any request that access cache and found
      line in E or S-state]
      unc_cbo_cache_lookup.any_i
      [Unit: uncore_cbox L3 Lookup any request that access cache and found
      line in I-state]
      unc_cbo_cache_lookup.any_i
      [Unit: uncore_cbox L3 Lookup any request that access cache and found
      line in I-state]
      ...
    
    Notice how the events are listed twice.
    
    The named commit changed how we remove duplicate events, in that events
    for different PMUs are not treated as duplicates. I suppose this is to
    handle how "Each hybrid pmu event has been assigned with a pmu name".
    
    Fix PMU alias listing by restoring behaviour to remove duplicates for
    non-hybrid PMUs.
    
    Fixes: 0e0ae87 ("perf list: Display hybrid PMU events with cpu type")
    Signed-off-by: John Garry <john.garry@huawei.com>
    Tested-by: Zhengjun Xing <zhengjun.xing@linux.intel.com>
    Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
    Cc: Ian Rogers <irogers@google.com>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Jiri Olsa <jolsa@redhat.com>
    Cc: Kan Liang <kan.liang@linux.intel.com>
    Cc: Mark Rutland <mark.rutland@arm.com>
    Cc: Namhyung Kim <namhyung@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Link: https://lore.kernel.org/r/1640103090-140490-1-git-send-email-john.garry@huawei.com
    Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
    johnpgarry authored and Arnaldo Carvalho de Melo committed Jan 2, 2022

Commits on Jan 1, 2022

  1. Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel…

    …/git/dtor/input
    
    Pull input fixes from Dmitry Torokhov:
     "Two small fixups for spaceball joystick driver and appletouch touchpad
      driver"
    
    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
      Input: spaceball - fix parsing of movement data packets
      Input: appletouch - initialize work before device registration
    torvalds committed Jan 1, 2022

Commits on Dec 31, 2021

  1. mm: vmscan: reduce throttling due to a failure to make progress -fix

    Hugh Dickins reported the following
    
    	My tmpfs swapping load (tweaked to use huge pages more heavily
    	than in real life) is far from being a realistic load: but it was
    	notably slowed down by your throttling mods in 5.16-rc, and this
    	patch makes it well again - thanks.
    
    	But: it very quickly hit NULL pointer until I changed that last
    	line to
    
            if (first_pgdat)
                    consider_reclaim_throttle(first_pgdat, sc);
    
    The likely issue is that huge pages are a major component of the test
    workload.  When this is the case, first_pgdat may never get set if
    compaction is ready to continue due to this check
    
            if (IS_ENABLED(CONFIG_COMPACTION) &&
                sc->order > PAGE_ALLOC_COSTLY_ORDER &&
                compaction_ready(zone, sc)) {
                    sc->compaction_ready = true;
                    continue;
            }
    
    If this was true for every zone in the zonelist, first_pgdat would never
    get set resulting in a NULL pointer exception.
    
    Link: https://lkml.kernel.org/r/20211209095453.GM3366@techsingularity.net
    Fixes: 1b4e3f2 ("mm: vmscan: Reduce throttling due to a failure to make progress")
    Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
    Reported-by: Hugh Dickins <hughd@google.com>
    Cc: Michal Hocko <mhocko@suse.com>
    Cc: Vlastimil Babka <vbabka@suse.cz>
    Cc: Rik van Riel <riel@surriel.com>
    Cc: Mike Galbraith <efault@gmx.de>
    Cc: Darrick J. Wong <djwong@kernel.org>
    Cc: Shakeel Butt <shakeelb@google.com>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    gormanm authored and torvalds committed Dec 31, 2021
  2. mm: vmscan: Reduce throttling due to a failure to make progress

    Mike Galbraith, Alexey Avramov and Darrick Wong all reported similar
    problems due to reclaim throttling for excessive lengths of time.  In
    Alexey's case, a memory hog that should go OOM quickly stalls for
    several minutes before stalling.  In Mike and Darrick's cases, a small
    memcg environment stalled excessively even though the system had enough
    memory overall.
    
    Commit 69392a4 ("mm/vmscan: throttle reclaim when no progress is
    being made") introduced the problem although commit a19594c
    ("mm/vmscan: increase the timeout if page reclaim is not making
    progress") made it worse.  Systems at or near an OOM state that cannot
    be recovered must reach OOM quickly and memcg should kill tasks if a
    memcg is near OOM.
    
    To address this, only stall for the first zone in the zonelist, reduce
    the timeout to 1 tick for VMSCAN_THROTTLE_NOPROGRESS and only stall if
    the scan control nr_reclaimed is 0, kswapd is still active and there
    were excessive pages pending for writeback.  If kswapd has stopped
    reclaiming due to excessive failures, do not stall at all so that OOM
    triggers relatively quickly.  Similarly, if an LRU is simply congested,
    only lightly throttle similar to NOPROGRESS.
    
    Alexey's original case was the most straight forward
    
    	for i in {1..3}; do tail /dev/zero; done
    
    On vanilla 5.16-rc1, this test stalled heavily, after the patch the test
    completes in a few seconds similar to 5.15.
    
    Alexey's second test case added watching a youtube video while tail runs
    10 times.  On 5.15, playback only jitters slightly, 5.16-rc1 stalls a
    lot with lots of frames missing and numerous audio glitches.  With this
    patch applies, the video plays similarly to 5.15.
    
    [lkp@intel.com: Fix W=1 build warning]
    
    Link: https://lore.kernel.org/r/99e779783d6c7fce96448a3402061b9dc1b3b602.camel@gmx.de
    Link: https://lore.kernel.org/r/20211124011954.7cab9bb4@mail.inbox.lv
    Link: https://lore.kernel.org/r/20211022144651.19914-1-mgorman@techsingularity.net
    Link: https://lore.kernel.org/r/20211202150614.22440-1-mgorman@techsingularity.net
    Link: https://linux-regtracking.leemhuis.info/regzbot/regression/20211124011954.7cab9bb4@mail.inbox.lv/
    Reported-and-tested-by: Alexey Avramov <hakavlad@inbox.lv>
    Reported-and-tested-by: Mike Galbraith <efault@gmx.de>
    Reported-and-tested-by: Darrick J. Wong <djwong@kernel.org>
    Reported-by: kernel test robot <lkp@intel.com>
    Acked-by: Hugh Dickins <hughd@google.com>
    Tracked-by: Thorsten Leemhuis <regressions@leemhuis.info>
    Fixes: 69392a4 ("mm/vmscan: throttle reclaim when no progress is being made")
    Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    gormanm authored and torvalds committed Dec 31, 2021
  3. Merge branch 'akpm' (patches from Andrew)

    Merge misc mm fixes from Andrew Morton:
     "2 patches.
    
      Subsystems affected by this patch series: mm (userfaultfd and damon)"
    
    * akpm:
      mm/damon/dbgfs: fix 'struct pid' leaks in 'dbgfs_target_ids_write()'
      userfaultfd/selftests: fix hugetlb area allocations
    torvalds committed Dec 31, 2021
  4. Merge tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/g…

    …it/jejb/scsi
    
    Pull SCSI fixes from James Bottomley:
     "Three fixes, all in drivers. The lpfc one doesn't look exploitable,
      but nasty things could happen in string operations if mybuf ends up
      with an on stack unterminated string"
    
    * tag 'scsi-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi:
      scsi: vmw_pvscsi: Set residual data length conditionally
      scsi: libiscsi: Fix UAF in iscsi_conn_get_param()/iscsi_conn_teardown()
      scsi: lpfc: Terminate string in lpfc_debugfs_nvmeio_trc_write()
    torvalds committed Dec 31, 2021
  5. mm/damon/dbgfs: fix 'struct pid' leaks in 'dbgfs_target_ids_write()'

    DAMON debugfs interface increases the reference counts of 'struct pid's
    for targets from the 'target_ids' file write callback
    ('dbgfs_target_ids_write()'), but decreases the counts only in DAMON
    monitoring termination callback ('dbgfs_before_terminate()').
    
    Therefore, when 'target_ids' file is repeatedly written without DAMON
    monitoring start/termination, the reference count is not decreased and
    therefore memory for the 'struct pid' cannot be freed.  This commit
    fixes this issue by decreasing the reference counts when 'target_ids' is
    written.
    
    Link: https://lkml.kernel.org/r/20211229124029.23348-1-sj@kernel.org
    Fixes: 4bc0595 ("mm/damon: implement a debugfs-based user space interface")
    Signed-off-by: SeongJae Park <sj@kernel.org>
    Cc: <stable@vger.kernel.org>	[5.15+]
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    SeongJae Park authored and torvalds committed Dec 31, 2021
  6. userfaultfd/selftests: fix hugetlb area allocations

    Currently, userfaultfd selftest for hugetlb as run from run_vmtests.sh
    or any environment where there are 'just enough' hugetlb pages will
    always fail with:
    
      testing events (fork, remap, remove):
    		ERROR: UFFDIO_COPY error: -12 (errno=12, line=616)
    
    The ENOMEM error code implies there are not enough hugetlb pages.
    However, there are free hugetlb pages but they are all reserved.  There
    is a basic problem with the way the test allocates hugetlb pages which
    has existed since the test was originally written.
    
    Due to the way 'cleanup' was done between different phases of the test,
    this issue was masked until recently.  The issue was uncovered by commit
    8ba6e86 ("userfaultfd/selftests: reinitialize test context in each
    test").
    
    For the hugetlb test, src and dst areas are allocated as PRIVATE
    mappings of a hugetlb file.  This means that at mmap time, pages are
    reserved for the src and dst areas.  At the start of event testing (and
    other tests) the src area is populated which results in allocation of
    huge pages to fill the area and consumption of reserves associated with
    the area.  Then, a child is forked to fault in the dst area.  Note that
    the dst area was allocated in the parent and hence the parent owns the
    reserves associated with the mapping.  The child has normal access to
    the dst area, but can not use the reserves created/owned by the parent.
    Thus, if there are no other huge pages available allocation of a page
    for the dst by the child will fail.
    
    Fix by not creating reserves for the dst area.  In this way the child
    can use free (non-reserved) pages.
    
    Also, MAP_PRIVATE of a file only makes sense if you are interested in
    the contents of the file before making a COW copy.  The test does not do
    this.  So, just use MAP_ANONYMOUS | MAP_HUGETLB to create an anonymous
    hugetlb mapping.  There is no need to create a hugetlb file in the
    non-shared case.
    
    Link: https://lkml.kernel.org/r/20211217172919.7861-1-mike.kravetz@oracle.com
    Signed-off-by: Mike Kravetz <mike.kravetz@oracle.com>
    Cc: Axel Rasmussen <axelrasmussen@google.com>
    Cc: Peter Xu <peterx@redhat.com>
    Cc: Andrea Arcangeli <aarcange@redhat.com>
    Cc: Mina Almasry <almasrymina@google.com>
    Cc: Shuah Khan <shuah@kernel.org>
    Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
    mjkravetz authored and torvalds committed Dec 31, 2021
  7. Docs: Fixes link to I2C specification

    The link to the I2C specification is broken. Although
    "https://www.nxp.com" hosts Rev 7 (2021) of this specification, it is
    behind a login-wall. Thus, an additional link has been added (which
    doesn't require a login) and the NXP official docs link has been
    updated.
    
    Signed-off-by: Deep Majumder <deep@fastmail.in>
    [wsa: minor updates to text and commit message]
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    Deep Majumder authored and Wolfram Sang committed Dec 31, 2021
  8. i2c: validate user data in compat ioctl

    Wrong user data may cause warning in i2c_transfer(), ex: zero msgs.
    Userspace should not be able to trigger warnings, so this patch adds
    validation checks for user data in compact ioctl to prevent reported
    warnings
    
    Reported-and-tested-by: syzbot+e417648b303855b91d8a@syzkaller.appspotmail.com
    Fixes: 7d5cb45 ("i2c compat ioctls: move to ->compat_ioctl()")
    Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
    Signed-off-by: Wolfram Sang <wsa@kernel.org>
    pskrgag authored and Wolfram Sang committed Dec 31, 2021
Older