Commit graph

7592 commits

Author SHA1 Message Date
Danny Lin
00c4a222bb exec: Add node tampering blacklist function
We'll be adding checks to block writes from processes which tamper with
values that we control from within the kernel, especially ones that
userspace writes to for boosting. Add a central function to perform the
process check to reduce code duplication.

This blacklists the following processes which are known to tamper with
such values:
  - init
  - libperfmgr (power@1.3-servi and NodeLooperThrea)
  - perfd (perf@1.0-servic)
  - init.qcom.post_boot.sh (init.qcom.post_)

Signed-off-by: Danny Lin <danny@kdrag0n.dev>
Signed-off-by: Julian Liu <wlootlxt123@gmail.com>
Signed-off-by: Fiqri Ardyansyah <fiqri15072019@gmail.com>
Signed-off-by: rezaadi0105 <rezaadipangestu5@gmail.com>
2025-01-17 20:18:34 +01:00
Ksawlii
1aaa0360e8 kernel_build: build*.sh: Tweak echo commands 2025-01-17 19:24:28 +01:00
Ksawlii
b419a4cf57 build.sh: Add an option to clean build dirs 2025-01-17 16:37:35 +01:00
Ksawlii
ca7685d6b1 build.sh: Exit after building 2025-01-17 00:06:58 +01:00
Ksawlii
46ef9e7f51 defconfigs: Regenerate with regen.sh 2025-01-17 00:03:07 +01:00
Ksawlii
642aac6c75 kernel_build: regen.sh Set CONFIG_KSU to =n after regeneration 2025-01-17 00:01:05 +01:00
Ksawlii
046f1b47c2 defconfigs: Regenerate with regen.sh 2025-01-16 23:53:44 +01:00
Ksawlii
f0a38abfb0 Ignore *.zip *.tar *.img.lz4 in kernel_build directory 2025-01-16 23:35:34 +01:00
Ksawlii
cbbab54bac Add a script to regenerate defconfigs 2025-01-16 23:32:03 +01:00
Tim Zimmermann
bdd9818338 net: wireless: scsc: Add support for NL80211_WPA_VERSION_3
* Required after V QPR1 wpa_supplicant updates

Change-Id: I0f09cc03ef11260e56c882c12f4f11be1bf2547e
2025-01-16 23:19:27 +01:00
Ksawlii
f697483a60 Makefile,kernel_build: Set PLATFORM_VERSION to 15.0 2025-01-16 23:19:19 +01:00
Nathan Chancellor
d57c773f75 UPSTREAM: Makefile: Only specify '--prefix=' when building with clang + GNU as
When building with LLVM_IAS=1, there is no point to specifying
'--prefix=' because that flag is only used to find GNU cross tools,
which will not be used indirectly when using the integrated assembler.
All of the tools are invoked directly from PATH or a full path specified
via the command line, which does not depend on the value of '--prefix='.

Sharing commands to reproduce issues becomes a little bit easier without
a '--prefix=' value because that '--prefix=' value is specific to a
user's machine due to it being an absolute path.

Some further notes from Fangrui Song:

  clang can spawn GNU as (if -f?no-integrated-as is specified) and GNU
  objcopy (-f?no-integrated-as and -gsplit-dwarf and -g[123]).
  objcopy is only used for GNU as assembled object files.
  With integrated assembler, the object file streamer creates .o and
  .dwo simultaneously.
  With GNU as, two objcopy commands are needed to extract .debug*.dwo to
  .dwo files && another command to remove .debug*.dwo sections.

A small consequence of this change (to keep things simple) is that
'--prefix=' will always be specified now, even with a native build, when
it was not before. This should not be an issue due to the way that the
Makefile searches for the prefix (based on elfedit's location). This
ends up improving the experience for host builds because PATH is better
respected and matches GCC's behavior more closely. See the below thread
for more details:

https://lore.kernel.org/r/20210205213651.GA16907@Ryzen-5-4500U.localdomain/

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
(cherry picked from commit eec08090bcc113643522d4272dc0b945045aba74)
Bug: 209655537
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Change-Id: I90f232a1551afb9118176a61ac5de38384a171fd
2025-01-16 23:17:02 +01:00
Nathan Chancellor
8e358dd764 UPSTREAM: Makefile: Remove '--gcc-toolchain' flag
This flag was originally added to allow clang to find the GNU cross
tools in commit 785f11aa595b ("kbuild: Add better clang cross build
support"). This flag was not enough to find the tools at times so
'--prefix' was added to the list in commit ef8c4ed9db80 ("kbuild: allow
to use GCC toolchain not in Clang search path") and improved upon in
commit ca9b31f6bb9c ("Makefile: Fix GCC_TOOLCHAIN_DIR prefix for Clang
cross compilation"). Now that '--prefix' specifies a full path and
prefix, '--gcc-toolchain' serves no purpose because the kernel builds
with '-nostdinc' and '-nostdlib'.

This has been verified with self compiled LLVM 10.0.1 and LLVM 13.0.0 as
well as a distribution version of LLVM 11.1.0 without binutils in the
LLVM toolchain locations.

Link: https://reviews.llvm.org/D97902
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Reviewed-by: Fangrui Song <maskray@google.com>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Sedat Dilek <sedat.dilek@gmail.com>
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
(cherry picked from commit c91d4e47e10ee4d3163838b1b727fe1d0664115b)
Bug: 209655537
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Change-Id: Ie1f64ed8562964ceba21e402a3d97850f6471508
2025-01-16 23:16:57 +01:00
Masahiro Yamada
d52b4aa77b UPSTREAM: kbuild: remove ld-version macro
There is no direct user of ld-version; you can use CONFIG_LD_VERSION
if needed.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
Bug: 209655537
(cherry picked from commit 05f6bbf2d714309607d5533f0265a95d037610b4)
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
Change-Id: If7f82474beea2822340ee8503de5087336766223
2025-01-16 23:16:51 +01:00
LuK1337
4a42267412 Android: Add empty Android.mk file
* This prevents inclusion of drivers/staging/greybus/tools/Android.mk
  which will conflict in case we have more than 1 kernel tree in AOSP
  source dir.

Change-Id: I335bca7b6d6463b1ffc673ab5367603347516e13
2025-01-16 23:15:38 +01:00
Tim Zimmermann
6b53dc899e drivers: misc: samsung: scsc: fix build without CONFIG_SCSC_WLBTD
Change-Id: I13cba302b47e5353656bab86b725e128bdd5e628
2025-01-16 23:15:33 +01:00
Tim Zimmermann
39efa81db3 misc: samsung: scsc_bt: Always set transport unit size to 16
* Our firmware wants this to be 16 (PCM) instead of 0x00 (HCI)
* Removes the need for patching userspace

Change-Id: Ie88a682b5acc6ef73db5d35dbd336544ab0a1a2a
2025-01-16 23:15:22 +01:00
Tim Zimmermann
ac4a6294be battery: sm5714_fuelgauge: Use CHARGE_FULL capacity for CHARGE_COUNTER
Change-Id: Id43d7f233e9492d609eaf2510e85dee8f962c192
2025-01-16 23:09:28 +01:00
Tim Zimmermann
8ef191ee08 battery: sm5714_fuelgauge: Support CAPACITY_AGEDCELL
Change-Id: If9b68c2c931e3003edbbd4ac8a187fdeb5da76b0
2025-01-16 23:08:52 +01:00
Tim Zimmermann
bfbff4db95 drivers: net: wireless: scsc: update slsi_lls_peer_info struct for Android S
* In 359fa1d1ba
  there was a new field added to wifi_peer_info struct, our HAL expects these two
  to match - with the new change num_rate wasn't properly aligned anymore
  causing userspace to allocate a "random" amount of wifi_rate_stat structs

Change-Id: I791a5a26fbb5123d08a8280e3312946b7f89c45c
2025-01-16 23:08:36 +01:00
Tim Zimmermann
50596b1299 configs: s5e8825: Rename AP interface from swlan0 to wlan1
* Needed to get STA/AP concurrency working
* See https://source.android.com/devices/tech/connect/wifi-sta-ap-concurrency?hl=en

Change-Id: I9c3331d14e12325e12ac5af41590ad83ee37ec95
Signed-off-by: Nahuel Gómez <nahuelgomez329@gmail.com>
2025-01-16 23:08:04 +01:00
Tim Zimmermann
b01f73ace1 include: Move videodev2_exynos_media.h to uapi/linux
* For building `hardware/samsung_slsi-linaro/exynos` components after Blueprint transition.

Change-Id: Ida4dd16a5103bea9316638d6cdf6381f08407946
2025-01-16 23:07:16 +01:00
Tim Zimmermann
3358a70312 media: platform: exynos: camera: Fix enum-compare compilation error from clang 19
../../../../../../kernel/samsung/gta4xls/drivers/media/platform/exynos/camera/vendor/mcd_v2/is-vender.c:2686:65: error: comparison of different enumeration types ('enum camera2_sensor_hdr_mode' and 'enum is_senso
r_hdr_mode') [-Werror,-Wenum-compare]
 2686 |         return (((cis_shared_data *)cis_data)->is_data.sensor_hdr_mode == SENSOR_HDR_MODE_2AEB ? true : false);
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~
1 error generated.

Change-Id: I8df427a0b86f3a6eff29554d16508f07703b50fb
2025-01-16 23:06:54 +01:00
Arjan van de Ven
54bab59901 fs: ext4: fsync: optimize double-fsync() a bunch
There are cases where EXT4 is a bit too conservative sending barriers down to
the disk; there are cases where the transaction in progress is not the one
that sent the barrier (in other words: the fsync is for a file for which the
IO happened more time ago and all data was already sent to the disk).

For that case, a more performing tradeoff can be made on SSD devices (which
have the ability to flush their dram caches in a hurry on a power fail event)
where the barrier gets sent to the disk, but we don't need to wait for the
barrier to complete. Any consecutive IO will block on the barrier correctly.

Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
(cherry picked from commit 74aa09a7751e438bd15b5cd73f611021b7239240)
(cherry picked from commit fa3bdf1a32cac074ff52403cb9ce18eb18c7f7d1)
2025-01-16 22:01:03 +01:00
ztc1997
8d7a99febf block: Do not allow boosters to adjusting scheduler 2025-01-16 21:58:52 +01:00
Nahuel Gómez
d3fdbe7c8a mm: default overcommit_ratio to 100
Signed-off-by: Nahuel Gómez <nahuelgomez329@gmail.com>
2025-01-16 21:58:05 +01:00
Ksawlii
bea7ef974b defconfigs: Increase log buffer to 1MB 2025-01-16 21:56:54 +01:00
Ksawlii
b1369a53be mm: Don't warn on page allocation failures for OOM-killed processes 2025-01-16 21:46:08 +01:00
Nahuel Gómez
5049015630 net: tcp: bbrplus for 5.10
Taken from: https://github.com/UJX6N/bbrplus-5.10

Signed-off-by: Nahuel Gómez <nahuelgomez329@gmail.com>
2025-01-16 21:37:27 +01:00
Ksawlii
ebeaa159e3 android: Add scsi_device_resume 2025-01-16 21:35:18 +01:00
Ksawlii
09fb15e899 defconfig: Disable CONFIG_KSU on vanilla builds 2025-01-15 16:49:21 +01:00
Ksawlii
552619876d defconfigs: Regenerate with regenerate.sh
regenerate.sh: Best work frfr
2025-01-15 16:47:28 +01:00
Nahuel Gómez
1c7179186b configs: turn down undervolt to a safe value
We need to investigate reports of random reboots.

Signed-off-by: Nahuel Gómez <nahuelgomez329@gmail.com>
2025-01-15 16:40:13 +01:00
Nahuel Gómez
f4634f8802 fvmap: move undervolting settings to Kconfig
Signed-off-by: Nahuel Gómez <nahuelgomez329@gmail.com>
2025-01-15 16:40:04 +01:00
Nahuel Gómez
eb36a10226 exynos: acme: dumb down code to take in any freq table
Don't validate it, just take it.
This will make it much easier to tune CPU frequencies.

Signed-off-by: Nahuel Gómez <nahuelgomez329@gmail.com>
2025-01-15 16:39:44 +01:00
Nahuel Gómez
e89716836f configs: disable EFI support
We don't use it.

Signed-off-by: Nahuel Gómez <nahuelgomez329@gmail.com>
2025-01-15 16:39:25 +01:00
Ksawlii
98564339fe defconfigs: enable CONFIG_CC_OPTIMIZE_FOR_PERFORMANCE_O3 2025-01-15 16:39:12 +01:00
Ksawlii
40426ac858 drivers: fvmap.c: Deprecate voltage_offset
Forgot to nuke this dangerous shit, anyways moved undervolt to Kconfig (Thanks @Flopster101) so it can be controlled in defconfig without issues
2025-01-15 16:39:06 +01:00
Ksawlii
8167679483 Revert "skb_expand_head() adjust skb->truesize incorrectly"
This reverts commit 7f4081157dd46180087c7cad43e37b956dd3ea71.
2025-01-15 16:38:33 +01:00
Ksawlii
46676a78ff Revert "epoll: Add synchronous wakeup support for ep_poll_callback"
This reverts commit b718903719ca67c98f72863873dbedef8900ec2a.
2025-01-15 16:38:29 +01:00
Ksawlii
24be309e47 FireAsf 5.0 Testing 5.10.233 Release 2025-01-15 16:37:04 +01:00
Ksawlii
a7d0f558f3 Welcome KernelSU Next 2025-01-15 16:32:35 +01:00
Greg Kroah-Hartman
ad3db97b79 Linux 5.10.233
Link: https://lore.kernel.org/r/20250106151133.209718681@linuxfoundation.org
Tested-by: Pavel Machek (CIP) <pavel@denx.de>
Tested-by: Florian Fainelli <florian.fainelli@broadcom.com>
Tested-by: Dominique Martinet <dominique.martinet@atmark-techno.com>
Tested-by: Mark Brown <broonie@kernel.org>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: kernelci.org bot <bot@kernelci.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-15 16:29:56 +01:00
Seiji Nishikawa
01bc6312f9 mm: vmscan: account for free pages to prevent infinite Loop in throttle_direct_reclaim()
commit 6aaced5abd32e2a57cd94fd64f824514d0361da8 upstream.

The task sometimes continues looping in throttle_direct_reclaim() because
allow_direct_reclaim(pgdat) keeps returning false.

 #0 [ffff80002cb6f8d0] __switch_to at ffff8000080095ac
 #1 [ffff80002cb6f900] __schedule at ffff800008abbd1c
 #2 [ffff80002cb6f990] schedule at ffff800008abc50c
 #3 [ffff80002cb6f9b0] throttle_direct_reclaim at ffff800008273550
 #4 [ffff80002cb6fa20] try_to_free_pages at ffff800008277b68
 #5 [ffff80002cb6fae0] __alloc_pages_nodemask at ffff8000082c4660
 #6 [ffff80002cb6fc50] alloc_pages_vma at ffff8000082e4a98
 #7 [ffff80002cb6fca0] do_anonymous_page at ffff80000829f5a8
 #8 [ffff80002cb6fce0] __handle_mm_fault at ffff8000082a5974
 #9 [ffff80002cb6fd90] handle_mm_fault at ffff8000082a5bd4

At this point, the pgdat contains the following two zones:

        NODE: 4  ZONE: 0  ADDR: ffff00817fffe540  NAME: "DMA32"
          SIZE: 20480  MIN/LOW/HIGH: 11/28/45
          VM_STAT:
                NR_FREE_PAGES: 359
        NR_ZONE_INACTIVE_ANON: 18813
          NR_ZONE_ACTIVE_ANON: 0
        NR_ZONE_INACTIVE_FILE: 50
          NR_ZONE_ACTIVE_FILE: 0
          NR_ZONE_UNEVICTABLE: 0
        NR_ZONE_WRITE_PENDING: 0
                     NR_MLOCK: 0
                    NR_BOUNCE: 0
                   NR_ZSPAGES: 0
            NR_FREE_CMA_PAGES: 0

        NODE: 4  ZONE: 1  ADDR: ffff00817fffec00  NAME: "Normal"
          SIZE: 8454144  PRESENT: 98304  MIN/LOW/HIGH: 68/166/264
          VM_STAT:
                NR_FREE_PAGES: 146
        NR_ZONE_INACTIVE_ANON: 94668
          NR_ZONE_ACTIVE_ANON: 3
        NR_ZONE_INACTIVE_FILE: 735
          NR_ZONE_ACTIVE_FILE: 78
          NR_ZONE_UNEVICTABLE: 0
        NR_ZONE_WRITE_PENDING: 0
                     NR_MLOCK: 0
                    NR_BOUNCE: 0
                   NR_ZSPAGES: 0
            NR_FREE_CMA_PAGES: 0

In allow_direct_reclaim(), while processing ZONE_DMA32, the sum of
inactive/active file-backed pages calculated in zone_reclaimable_pages()
based on the result of zone_page_state_snapshot() is zero.

Additionally, since this system lacks swap, the calculation of inactive/
active anonymous pages is skipped.

        crash> p nr_swap_pages
        nr_swap_pages = $1937 = {
          counter = 0
        }

As a result, ZONE_DMA32 is deemed unreclaimable and skipped, moving on to
the processing of the next zone, ZONE_NORMAL, despite ZONE_DMA32 having
free pages significantly exceeding the high watermark.

The problem is that the pgdat->kswapd_failures hasn't been incremented.

        crash> px ((struct pglist_data *) 0xffff00817fffe540)->kswapd_failures
        $1935 = 0x0

This is because the node deemed balanced.  The node balancing logic in
balance_pgdat() evaluates all zones collectively.  If one or more zones
(e.g., ZONE_DMA32) have enough free pages to meet their watermarks, the
entire node is deemed balanced.  This causes balance_pgdat() to exit early
before incrementing the kswapd_failures, as it considers the overall
memory state acceptable, even though some zones (like ZONE_NORMAL) remain
under significant pressure.


The patch ensures that zone_reclaimable_pages() includes free pages
(NR_FREE_PAGES) in its calculation when no other reclaimable pages are
available (e.g., file-backed or anonymous pages).  This change prevents
zones like ZONE_DMA32, which have sufficient free pages, from being
mistakenly deemed unreclaimable.  By doing so, the patch ensures proper
node balancing, avoids masking pressure on other zones like ZONE_NORMAL,
and prevents infinite loops in throttle_direct_reclaim() caused by
allow_direct_reclaim(pgdat) repeatedly returning false.


The kernel hangs due to a task stuck in throttle_direct_reclaim(), caused
by a node being incorrectly deemed balanced despite pressure in certain
zones, such as ZONE_NORMAL.  This issue arises from
zone_reclaimable_pages() returning 0 for zones without reclaimable file-
backed or anonymous pages, causing zones like ZONE_DMA32 with sufficient
free pages to be skipped.

The lack of swap or reclaimable pages results in ZONE_DMA32 being ignored
during reclaim, masking pressure in other zones.  Consequently,
pgdat->kswapd_failures remains 0 in balance_pgdat(), preventing fallback
mechanisms in allow_direct_reclaim() from being triggered, leading to an
infinite loop in throttle_direct_reclaim().

This patch modifies zone_reclaimable_pages() to account for free pages
(NR_FREE_PAGES) when no other reclaimable pages exist.  This ensures zones
with sufficient free pages are not skipped, enabling proper balancing and
reclaim behavior.

[akpm@linux-foundation.org: coding-style cleanups]
Link: https://lkml.kernel.org/r/20241130164346.436469-1-snishika@redhat.com
Link: https://lkml.kernel.org/r/20241130161236.433747-2-snishika@redhat.com
Fixes: 5a1c84b404a7 ("mm: remove reclaim and compaction retry approximations")
Signed-off-by: Seiji Nishikawa <snishika@redhat.com>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-15 16:29:56 +01:00
Biju Das
defe11ba1b drm: adv7511: Drop dsi single lane support
commit 79d67c499c3f886202a40c5cb27e747e4fa4d738 upstream.

As per [1] and [2], ADV7535/7533 supports only 2-, 3-, or 4-lane. Drop
unsupported 1-lane.

[1] https://www.analog.com/media/en/technical-documentation/data-sheets/ADV7535.pdf
[2] https://www.analog.com/media/en/technical-documentation/data-sheets/ADV7533.pdf

Fixes: 1e4d58cd7f88 ("drm/bridge: adv7533: Create a MIPI DSI device")
Reported-by: Hien Huynh <hien.huynh.px@renesas.com>
Cc: stable@vger.kernel.org
Reviewed-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Reviewed-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241119192040.152657-4-biju.das.jz@bp.renesas.com
Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-15 16:29:56 +01:00
Nikolay Kuratov
42e3599e06 net/sctp: Prevent autoclose integer overflow in sctp_association_init()
commit 4e86729d1ff329815a6e8a920cb554a1d4cb5b8d upstream.

While by default max_autoclose equals to INT_MAX / HZ, one may set
net.sctp.max_autoclose to UINT_MAX. There is code in
sctp_association_init() that can consequently trigger overflow.

Cc: stable@vger.kernel.org
Fixes: 9f70f46bd4c7 ("sctp: properly latch and use autoclose value from sock to association")
Signed-off-by: Nikolay Kuratov <kniv@yandex-team.ru>
Acked-by: Xin Long <lucien.xin@gmail.com>
Link: https://patch.msgid.link/20241219162114.2863827-1-kniv@yandex-team.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-15 16:29:56 +01:00
Pascal Hambourg
82bf6bc3e5 sky2: Add device ID 11ab:4373 for Marvell 88E8075
commit 03c8d0af2e409e15c16130b185e12b5efba0a6b9 upstream.

A Marvell 88E8075 ethernet controller has this device ID instead of
11ab:4370 and works fine with the sky2 driver.

Signed-off-by: Pascal Hambourg <pascal@plouf.fr.eu.org>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/10165a62-99fb-4be6-8c64-84afd6234085@plouf.fr.eu.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-15 16:29:56 +01:00
Evgenii Shatokhin
bc815d14c5 pinctrl: mcp23s08: Fix sleeping in atomic context due to regmap locking
commit a37eecb705f33726f1fb7cd2a67e514a15dfe693 upstream.

If a device uses MCP23xxx IO expander to receive IRQs, the following
bug can happen:

  BUG: sleeping function called from invalid context
    at kernel/locking/mutex.c:283
  in_atomic(): 1, irqs_disabled(): 1, non_block: 0, ...
  preempt_count: 1, expected: 0
  ...
  Call Trace:
  ...
  __might_resched+0x104/0x10e
  __might_sleep+0x3e/0x62
  mutex_lock+0x20/0x4c
  regmap_lock_mutex+0x10/0x18
  regmap_update_bits_base+0x2c/0x66
  mcp23s08_irq_set_type+0x1ae/0x1d6
  __irq_set_trigger+0x56/0x172
  __setup_irq+0x1e6/0x646
  request_threaded_irq+0xb6/0x160
  ...

We observed the problem while experimenting with a touchscreen driver which
used MCP23017 IO expander (I2C).

The regmap in the pinctrl-mcp23s08 driver uses a mutex for protection from
concurrent accesses, which is the default for regmaps without .fast_io,
.disable_locking, etc.

mcp23s08_irq_set_type() calls regmap_update_bits_base(), and the latter
locks the mutex.

However, __setup_irq() locks desc->lock spinlock before calling these
functions. As a result, the system tries to lock the mutex whole holding
the spinlock.

It seems, the internal regmap locks are not needed in this driver at all.
mcp->lock seems to protect the regmap from concurrent accesses already,
except, probably, in mcp_pinconf_get/set.

mcp23s08_irq_set_type() and mcp23s08_irq_mask/unmask() are called under
chip_bus_lock(), which calls mcp23s08_irq_bus_lock(). The latter takes
mcp->lock and enables regmap caching, so that the potentially slow I2C
accesses are deferred until chip_bus_unlock().

The accesses to the regmap from mcp23s08_probe_one() do not need additional
locking.

In all remaining places where the regmap is accessed, except
mcp_pinconf_get/set(), the driver already takes mcp->lock.

This patch adds locking in mcp_pinconf_get/set() and disables internal
locking in the regmap config. Among other things, it fixes the sleeping
in atomic context described above.

Fixes: 8f38910ba4f6 ("pinctrl: mcp23s08: switch to regmap caching")
Cc: stable@vger.kernel.org
Signed-off-by: Evgenii Shatokhin <e.shatokhin@yadro.com>
Link: https://lore.kernel.org/20241209074659.1442898-1-e.shatokhin@yadro.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-15 16:29:56 +01:00
Dan Carpenter
201a79d6da RDMA/uverbs: Prevent integer overflow issue
commit d0257e089d1bbd35c69b6c97ff73e3690ab149a9 upstream.

In the expression "cmd.wqe_size * cmd.wr_count", both variables are u32
values that come from the user so the multiplication can lead to integer
wrapping.  Then we pass the result to uverbs_request_next_ptr() which also
could potentially wrap.  The "cmd.sge_count * sizeof(struct ib_uverbs_sge)"
multiplication can also overflow on 32bit systems although it's fine on
64bit systems.

This patch does two things.  First, I've re-arranged the condition in
uverbs_request_next_ptr() so that the use controlled variable "len" is on
one side of the comparison by itself without any math.  Then I've modified
all the callers to use size_mul() for the multiplications.

Fixes: 67cdb40ca444 ("[IB] uverbs: Implement more commands")
Cc: stable@vger.kernel.org
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Link: https://patch.msgid.link/b8765ab3-c2da-4611-aae0-ddd6ba173d23@stanley.mountain
Signed-off-by: Leon Romanovsky <leon@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-01-15 16:29:56 +01:00
Masahiro Yamada
bf82241403 modpost: fix the missed iteration for the max bit in do_input()
[ Upstream commit bf36b4bf1b9a7a0015610e2f038ee84ddb085de2 ]

This loop should iterate over the range from 'min' to 'max' inclusively.
The last interation is missed.

Fixes: 1d8f430c15b3 ("[PATCH] Input: add modalias support")
Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Tested-by: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2025-01-15 16:29:56 +01:00