1
0
Fork 0
Commit Graph

889999 Commits (redonkable)

Author SHA1 Message Date
jebba 880648b300 kern ver 2021-06-26 20:42:55 -06:00
jebba af0ad66655 alistair23 fork 2021-06-26 20:29:08 -06:00
jebba 37f034027e perchance imx_v6_v7_defconfig 2021-06-26 20:21:19 -06:00
jebba 9ff47560e5 readme stub 2021-06-26 20:18:48 -06:00
Anna Boettcher f31f3d3270 Remove old do_gettimeofday call 2021-03-16 17:05:02 -04:00
Alistair Francis 064c838bd2 rM2: power: supply: sysfs: Copy over rM2 patches
Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-11 17:44:42 -08:00
Alistair Francis 53e60e4761 Revert "brcmfmac: Loading the correct firmware for brcm43456"
This reverts commit e3062e05e1.

There is no brcmfmac43456-sdio.* firmware in the linux-firmware repo,
and the brcmfmac43455-sdio.* works fine, so let's just use that.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-11 17:44:42 -08:00
Shawn Guo 991d5b4eda mmc: pwrseq_simple: select pinctrl state during suspend/resume
To support suspend/resume from LPSR mode, we need to select default
pinctrl state in resume, so that IOMUXC settings can be restored from
power losing.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
2021-02-11 17:44:42 -08:00
Shawn Guo 34906fc690 watchdog: imx2_wdt: select pinctrl state during suspend/resume
To support suspend/resume from LPSR mode, we need to select default
pinctrl state in resume, so that IOMUXC settings can be restored.

Signed-off-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-11 17:44:41 -08:00
Alistair Francis 539b322758 ARM: imx_v6_v7_defconfig: Update to work for rM2
Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-11 17:44:38 -08:00
Alistair Francis a0d1c5194a zero-sugar.dts: Enable the power button
Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-11 13:33:41 -08:00
Alistair Francis 905eb92565 zero-sugar: Print output on UART6
Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-11 13:33:41 -08:00
Alistair Francis ac8c3d57e7 rM2: touchscreen: Copy the rM2 wacom changes
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-11 13:33:41 -08:00
Alistair Francis 3e9697d639 rM2: video: fbdev: mxsfb: Copy the rM2 mxsfb changes
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-11 13:33:41 -08:00
Steinar Bakkemo 499a2c6700 usb-gadget: set VID/PID for the USB/RNDIS driver
Use an existing VID/PID recognized on Windows platforms by default
2021-02-07 14:28:26 -08:00
Alistair Francis 55043fe464 rM2: usb: chipidea: rM2 specific changes
Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:26 -08:00
Alistair Francis d0fd59fb0a rM2: thermal: Copy the rM2 sy7636a_thermal driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:26 -08:00
Alistair Francis d3d2e5282b rM2: rtc: Copy the rM2 rtc-bd7181x driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:26 -08:00
Alistair Francis 9592b400b2 rM2: regulator: Copy the rM2 sy7636a-regulator driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:26 -08:00
Alistair Francis 63323d8556 rM2: mfd: Copy the rM2 bd7181x driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:26 -08:00
Alistair Francis 332b1bc1a9 rM2: mfd: Copy the rM2 sy7636a driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:26 -08:00
Alistair Francis 61f72c26e7 rM2: hwmon: Copy the rM2 sy7636a-hwmon driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:25 -08:00
Alistair Francis 947d13cb95 rM2: gpio: Copy rM2 BD7181x driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:25 -08:00
Alistair Francis 81326a172e rM2: power: supply: Copy the rM2 bd7181x-power driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:25 -08:00
Alistair Francis 4879c1b867 rM2: Copy the rM2 max77818 driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:28:22 -08:00
Alistair Francis 3b4900abbe rM2: regulator: Copy the rM2 max77818-regulator driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:20:28 -08:00
Alistair Francis 953298a715 rM2: regulator: Copy the rM2 bd7181x-regulator driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:19:10 -08:00
Alistair Francis 64aa77fbef rM2: misc: Copy rM2 otgcontrol driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 14:00:25 -08:00
Alistair Francis c222fce7d8 rM2: input: touchscreen: Copy rM2 cyttsp5 driver
Copy the rM2 zero-sugar branch
(https://github.com/reMarkable/linux/tree/zero-sugar) to the new kernel.

Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 13:50:25 -08:00
Alistair Francis 8508afa801 rM2: ARM: dts: imx7d: remarkable2: Initial commit
Signed-off-by: Alistair Francis <alistair@alistair23.me>
2021-02-07 13:50:25 -08:00
Otavio Salvador 739c2edfa2
Merge pull request #240 from zandrey/5.4-2.2.x-imx
[EOL]: Update 5.4-2.2.x-imx to v5.4.94
2021-02-01 13:05:24 -03:00
Andrey Zhizhikin aba3f8060d This is the 5.4.94 stable release
-----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmAVVv0ACgkQONu9yGCS
 aT5vaRAAsoiWjnLU4dvziu92SDIdp+NdIZzXTT+v0FtEORbfaLjQ72XVYH3cIui7
 4ohxdMdUvlhFNRZr4B3+8GDogbL2vQMBNlODcpmVMX4iW4QUCCe/JwMt3cDogOA4
 UUTLQ78c248W3gKYE6WmelhBVee1H2XIZOUAehR7+wA2m9wmUPXK11ab917Lkold
 IHO7yW476kJdDfeISnixcZvt+vg9MHjkmRR83s6Unjwe9Ot4AWw3KkaYFYmGzLU1
 f5wZSovK76y4bpk3pkPbGw1udhubukHmUyH2bIWdb+M+ZTBKeEwkzadbxanuvlYa
 oaFPCjxE0z4Tmyqp7DhYf4OYECLvvuDBsFVxGrJGQfE5b4364SYSJVLn1J6scjei
 AjTLPtTwvB/pESX0MYNPohwTCeqqHDQbqNqqR0YtUMDfopC2JhvbibFksRvTYpRX
 ZWSi4xgaybFSsLEFvcNtjMBVJcHaOTeHYnun4xSRUrtFtbJd4fOcO6ubniIteeXr
 RIjcEo3vy0Vo/WYdn+830dZNkgASjv6Xct5N3TkaUHiAAPrhE1IzN17Rg0fQqYwT
 5QWW8Gxy0dbykQ6gvOw2BoQ12t91gaNQTtqzpy7Oxy7XpipU0xUZgboOxnblNOoS
 myFB6gdrJg2NjpUT0tK+w5Bd0Bzo5rMKGQW2hHJDLJLuLmFmO38=
 =Dtks
 -----END PGP SIGNATURE-----
gpgsig -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEdQaENiSDAlGTDEbB7G51OISzHs0FAmAXKR8ACgkQ7G51OISz
 Hs0sow/+MgTPgcNZwkU2gh5tgqeeS2hAPuPiCLXrC0QkTsfDjI89ezi3t/JwEVr0
 Ya++HsZAIWB3a/kHhQ07W0/eiln9ilVLsdeAQnRoEI61Eyyz/fR8lwuI5DydlHD6
 JZFR9lpVGVOqhEwZCrfMH09d6g4LI0H0dVQnw/KW+9gh613hPmOIRArk7uaA3yvD
 5V/1DSWD6UxcvvUAWNmoMb/k4pWf/mS3Ut/ty1R9nAZrIgxjmXBbLXWnnSx2Rywi
 dcS6Qc4vrjfUJJTULgwcVN7Icj8/dw4O+3awvFWXGXJn2vbxjxHTMjPghDXNtaT6
 VAaWhchoynqcMYCD650ErdY2gizVv8uTdk6TL6MtfHk1Q7WqBwPJo5SjU7TfskDY
 Lb3xy4JsogB4IBehhRQHhNyu1OgcnrdrQg0k7CQlgOLpRhVp3B6aSUqP0b++s/eH
 79UghbEz7ovXcjSS5SdKJB8k0+8/3+Nh/xSSB17QjLwm26dj/48Bklg5JWJx7VyQ
 1UgHT6HiFUakM3uMkACuEGX4Pbbu9GgnVA1A3jEJD+4MVjzvu1gTzP3V0B1JW8Z0
 trrr5vW6hPJnCL0MeQarak6X4tiYmmoRnS2ilFueMV2iFAo/FvkaWtOosqF5/Wx+
 ylJavT1BY7crAG0yzSDDcM5Vi4S02q7soXbsj7MXvSwdQXIe0g4=
 =vroI
 -----END PGP SIGNATURE-----

Merge tag 'v5.4.94' into 5.4-2.2.x-imx

This is the 5.4.94 stable release

Signed-off-by: Andrey Zhizhikin <andrey.zhizhikin@leica-geosystems.com>
2021-01-31 22:03:08 +00:00
Greg Kroah-Hartman 0fbca6ce41 Linux 5.4.94
Link: https://lore.kernel.org/r/20210129105910.132680016@linuxfoundation.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:11 +01:00
Eric Biggers 315cd8fc2a fs: fix lazytime expiration handling in __writeback_single_inode()
commit 1e249cb5b7 upstream.

When lazytime is enabled and an inode is being written due to its
in-memory updated timestamps having expired, either due to a sync() or
syncfs() system call or due to dirtytime_expire_interval having elapsed,
the VFS needs to inform the filesystem so that the filesystem can copy
the inode's timestamps out to the on-disk data structures.

This is done by __writeback_single_inode() calling
mark_inode_dirty_sync(), which then calls ->dirty_inode(I_DIRTY_SYNC).

However, this occurs after __writeback_single_inode() has already
cleared the dirty flags from ->i_state.  This causes two bugs:

- mark_inode_dirty_sync() redirties the inode, causing it to remain
  dirty.  This wastefully causes the inode to be written twice.  But
  more importantly, it breaks cases where sync_filesystem() is expected
  to clean dirty inodes.  This includes the FS_IOC_REMOVE_ENCRYPTION_KEY
  ioctl (as reported at
  https://lore.kernel.org/r/20200306004555.GB225345@gmail.com), as well
  as possibly filesystem freezing (freeze_super()).

- Since ->i_state doesn't contain I_DIRTY_TIME when ->dirty_inode() is
  called from __writeback_single_inode() for lazytime expiration,
  xfs_fs_dirty_inode() ignores the notification.  (XFS only cares about
  lazytime expirations, and it assumes that i_state will contain
  I_DIRTY_TIME during those.)  Therefore, lazy timestamps aren't
  persisted by sync(), syncfs(), or dirtytime_expire_interval on XFS.

Fix this by moving the call to mark_inode_dirty_sync() to earlier in
__writeback_single_inode(), before the dirty flags are cleared from
i_state.  This makes filesystems be properly notified of the timestamp
expiration, and it avoids incorrectly redirtying the inode.

This fixes xfstest generic/580 (which tests
FS_IOC_REMOVE_ENCRYPTION_KEY) when run on ext4 or f2fs with lazytime
enabled.  It also fixes the new lazytime xfstest I've proposed, which
reproduces the above-mentioned XFS bug
(https://lore.kernel.org/r/20210105005818.92978-1-ebiggers@kernel.org).

Alternatively, we could call ->dirty_inode(I_DIRTY_SYNC) directly.  But
due to the introduction of I_SYNC_QUEUED, mark_inode_dirty_sync() is the
right thing to do because mark_inode_dirty_sync() now knows not to move
the inode to a writeback list if it is currently queued for sync.

Fixes: 0ae45f63d4 ("vfs: add support for a lazytime mount option")
Cc: stable@vger.kernel.org
Depends-on: 5afced3bf2 ("writeback: Avoid skipping inode writeback")
Link: https://lore.kernel.org/r/20210112190253.64307-2-ebiggers@kernel.org
Suggested-by: Jan Kara <jack@suse.cz>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jan Kara <jack@suse.cz>
Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:11 +01:00
Jan Kara 5f8b8fccdf writeback: Drop I_DIRTY_TIME_EXPIRE
commit 5fcd57505c upstream.

The only use of I_DIRTY_TIME_EXPIRE is to detect in
__writeback_single_inode() that inode got there because flush worker
decided it's time to writeback the dirty inode time stamps (either
because we are syncing or because of age). However we can detect this
directly in __writeback_single_inode() and there's no need for the
strange propagation with I_DIRTY_TIME_EXPIRE flag.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jan Kara <jack@suse.cz>
Cc: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:11 +01:00
Mikulas Patocka 2d8848edc9 dm integrity: conditionally disable "recalculate" feature
commit 5c02406428 upstream.

Otherwise a malicious user could (ab)use the "recalculate" feature
that makes dm-integrity calculate the checksums in the background
while the device is already usable. When the system restarts before all
checksums have been calculated, the calculation continues where it was
interrupted even if the recalculate feature is not requested the next
time the dm device is set up.

Disable recalculating if we use internal_hash or journal_hash with a
key (e.g. HMAC) and we don't have the "legacy_recalculate" flag.

This may break activation of a volume, created by an older kernel,
that is not yet fully recalculated -- if this happens, the user should
add the "legacy_recalculate" flag to constructor parameters.

Cc: stable@vger.kernel.org
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reported-by: Daniel Glockner <dg@emlix.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Jean-Philippe Brucker 43546b74ce tools: Factor HOSTCC, HOSTLD, HOSTAR definitions
commit c8a950d0d3 upstream.

Several Makefiles in tools/ need to define the host toolchain variables.
Move their definition to tools/scripts/Makefile.include

Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/bpf/20201110164310.2600671-2-jean-philippe@linaro.org
Cc: Alistair Delva <adelva@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Steve French ab85b382dc SMB3.1.1: do not log warning message if server doesn't populate salt
commit 7955f105af upstream.

In the negotiate protocol preauth context, the server is not required
to populate the salt (although it is done by most servers) so do
not warn on mount.

We retain the checks (warn) that the preauth context is the minimum
size and that the salt does not exceed DataLength of the SMB response.
Although we use the defaults in the case that the preauth context
response is invalid, these checks may be useful in the future
as servers add support for additional mechanisms.

CC: Stable <stable@vger.kernel.org>
Reviewed-by: Shyam Prasad N <sprasad@microsoft.com>
Reviewed-by: Pavel Shilovsky <pshilov@microsoft.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Ard Biesheuvel 0edc78af73 arm64: mm: use single quantity to represent the PA to VA translation
commit 7bc1a0f9e1 upstream.

On arm64, the global variable memstart_addr represents the physical
address of PAGE_OFFSET, and so physical to virtual translations or
vice versa used to come down to simple additions or subtractions
involving the values of PAGE_OFFSET and memstart_addr.

When support for 52-bit virtual addressing was introduced, we had to
deal with PAGE_OFFSET potentially being outside of the region that
can be covered by the virtual range (as the 52-bit VA capable build
needs to be able to run on systems that are only 48-bit VA capable),
and for this reason, another translation was introduced, and recorded
in the global variable physvirt_offset.

However, if we go back to the original definition of memstart_addr,
i.e., the physical address of PAGE_OFFSET, it turns out that there is
no need for two separate translations: instead, we can simply subtract
the size of the unaddressable VA space from memstart_addr to make the
available physical memory appear in the 48-bit addressable VA region.

This simplifies things, but also fixes a bug on KASLR builds, which
may update memstart_addr later on in arm64_memblock_init(), but fails
to update vmemmap and physvirt_offset accordingly.

Fixes: 5383cc6efe ("arm64: mm: Introduce vabits_actual")
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Steve Capper <steve.capper@arm.com>
Link: https://lore.kernel.org/r/20201008153602.9467-2-ardb@kernel.org
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Vincenzo Frascino <vincenzo.frascino@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Gaurav Kohli b899d5b2a4 tracing: Fix race in trace_open and buffer resize call
commit bbeb97464e upstream.

Below race can come, if trace_open and resize of
cpu buffer is running parallely on different cpus
CPUX                                CPUY
				    ring_buffer_resize
				    atomic_read(&buffer->resize_disabled)
tracing_open
tracing_reset_online_cpus
ring_buffer_reset_cpu
rb_reset_cpu
				    rb_update_pages
				    remove/insert pages
resetting pointer

This race can cause data abort or some times infinte loop in
rb_remove_pages and rb_insert_pages while checking pages
for sanity.

Take buffer lock to fix this.

Link: https://lkml.kernel.org/r/1601976833-24377-1-git-send-email-gkohli@codeaurora.org

Cc: stable@vger.kernel.org
Fixes: 83f40318da ("ring-buffer: Make removal of ring buffer pages atomic")
Reported-by: Denis Efremov <efremov@linux.com>
Signed-off-by: Gaurav Kohli <gkohli@codeaurora.org>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Nicolai Stange c4a23c852e io_uring: Fix current->fs handling in io_sq_wq_submit_work()
No upstream commit, this is a fix to a stable 5.4 specific backport.

The intention of backport commit cac68d12c5 ("io_uring: grab ->fs as part
of async offload") as found in the stable 5.4 tree was to make
io_sq_wq_submit_work() to switch the workqueue task's ->fs over to the
submitting task's one during the IO operation.

However, due to a small logic error, this change turned out to not have any
actual effect. From a high level, the relevant code in
io_sq_wq_submit_work() looks like

  old_fs_struct = current->fs;
  do {
          ...
          if (req->fs != current->fs && current->fs != old_fs_struct) {
                  task_lock(current);
                  if (req->fs)
                          current->fs = req->fs;
                  else
                          current->fs = old_fs_struct;
                  task_unlock(current);
          }
          ...
  } while (req);

The if condition is supposed to cover the case that current->fs doesn't
match what's needed for processing the request, but observe how it fails
to ever evaluate to true due to the second clause:
current->fs != old_fs_struct will be false in the first iteration as per
the initialization of old_fs_struct and because this prevents current->fs
from getting replaced, the same follows inductively for all subsequent
iterations.

Fix said if condition such that
- if req->fs is set and doesn't match current->fs, the latter will be
  switched to the former
- or if req->fs is unset, the switch back to the initial old_fs_struct
  will be made, if necessary.

While at it, also correct the condition for the ->fs related cleanup right
before the return of io_sq_wq_submit_work(): currently, old_fs_struct is
restored only if it's non-NULL. It is always non-NULL though and thus, the
if-condition is rendundant. Supposedly, the motivation had been to optimize
and avoid switching current->fs back to the initial old_fs_struct in case
it is found to have the desired value already. Make it so.

Cc: stable@vger.kernel.org # v5.4
Fixes: cac68d12c5 ("io_uring: grab ->fs as part of async offload")
Reviewed-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Nicolai Stange <nstange@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Jason Gerecke 336bb7dc5a HID: wacom: Correct NULL dereference on AES pen proximity
commit 179e8e47c0 upstream.

The recent commit to fix a memory leak introduced an inadvertant NULL
pointer dereference. The `wacom_wac->pen_fifo` variable was never
intialized, resuling in a crash whenever functions tried to use it.
Since the FIFO is only used by AES pens (to buffer events from pen
proximity until the hardware reports the pen serial number) this would
have been easily overlooked without testing an AES device.

This patch converts `wacom_wac->pen_fifo` over to a pointer (since the
call to `devres_alloc` allocates memory for us) and ensures that we assign
it to point to the allocated and initalized `pen_fifo` before the function
returns.

Link: https://github.com/linuxwacom/input-wacom/issues/230
Fixes: 37309f47e2 ("HID: wacom: Fix memory leakage caused by kfifo_alloc")
CC: stable@vger.kernel.org # v4.19+
Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com>
Tested-by: Ping Cheng <ping.cheng@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Thomas Gleixner ecd62d2e9a futex: Handle faults correctly for PI futexes
commit 34b1a1ce14 upstream

fixup_pi_state_owner() tries to ensure that the state of the rtmutex,
pi_state and the user space value related to the PI futex are consistent
before returning to user space. In case that the user space value update
faults and the fault cannot be resolved by faulting the page in via
fault_in_user_writeable() the function returns with -EFAULT and leaves
the rtmutex and pi_state owner state inconsistent.

A subsequent futex_unlock_pi() operates on the inconsistent pi_state and
releases the rtmutex despite not owning it which can corrupt the RB tree of
the rtmutex and cause a subsequent kernel stack use after free.

It was suggested to loop forever in fixup_pi_state_owner() if the fault
cannot be resolved, but that results in runaway tasks which is especially
undesired when the problem happens due to a programming error and not due
to malice.

As the user space value cannot be fixed up, the proper solution is to make
the rtmutex and the pi_state consistent so both have the same owner. This
leaves the user space value out of sync. Any subsequent operation on the
futex will fail because the 10th rule of PI futexes (pi_state owner and
user space value are consistent) has been violated.

As a consequence this removes the inept attempts of 'fixing' the situation
in case that the current task owns the rtmutex when returning with an
unresolvable fault by unlocking the rtmutex which left pi_state::owner and
rtmutex::owner out of sync in a different and only slightly less dangerous
way.

Fixes: 1b7558e457 ("futexes: fix fault handling in futex_lock_pi")
Reported-by: gzobqq@gmail.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Thomas Gleixner 55ea172ce3 futex: Simplify fixup_pi_state_owner()
commit f2dac39d93 upstream

Too many gotos already and an upcoming fix would make it even more
unreadable.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Thomas Gleixner a3155c362c futex: Use pi_state_update_owner() in put_pi_state()
commit 6ccc84f917 upstream

No point in open coding it. This way it gains the extra sanity checks.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:10 +01:00
Thomas Gleixner ceb83cf9ed rtmutex: Remove unused argument from rt_mutex_proxy_unlock()
commit 2156ac1934 upstream

Nothing uses the argument. Remove it as preparation to use
pi_state_update_owner().

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:09 +01:00
Thomas Gleixner 015b6a4c25 futex: Provide and use pi_state_update_owner()
commit c5cade200a upstream

Updating pi_state::owner is done at several places with the same
code. Provide a function for it and use that at the obvious places.

This is also a preparation for a bug fix to avoid yet another copy of the
same code or alternatively introducing a completely unpenetratable mess of
gotos.

Originally-by: Peter Zijlstra <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:09 +01:00
Thomas Gleixner 65aad57cac futex: Replace pointless printk in fixup_owner()
commit 04b79c5520 upstream

If that unexpected case of inconsistent arguments ever happens then the
futex state is left completely inconsistent and the printk is not really
helpful. Replace it with a warning and make the state consistent.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:09 +01:00
Thomas Gleixner 0dae88a925 futex: Ensure the correct return value from futex_lock_pi()
commit 12bb3f7f1b upstream

In case that futex_lock_pi() was aborted by a signal or a timeout and the
task returned without acquiring the rtmutex, but is the designated owner of
the futex due to a concurrent futex_unlock_pi() fixup_owner() is invoked to
establish consistent state. In that case it invokes fixup_pi_state_owner()
which in turn tries to acquire the rtmutex again. If that succeeds then it
does not propagate this success to fixup_owner() and futex_lock_pi()
returns -EINTR or -ETIMEOUT despite having the futex locked.

Return success from fixup_pi_state_owner() in all cases where the current
task owns the rtmutex and therefore the futex and propagate it correctly
through fixup_owner(). Fixup the other callsite which does not expect a
positive return value.

Fixes: c1e2f0eaf0 ("futex: Avoid violating the 10th rule of futex")
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:09 +01:00
Wang Hai c27a2a1ecf Revert "mm/slub: fix a memory leak in sysfs_slab_add()"
commit 757fed1d08 upstream.

This reverts commit dde3c6b72a.

syzbot report a double-free bug. The following case can cause this bug.

 - mm/slab_common.c: create_cache(): if the __kmem_cache_create() fails,
   it does:

	out_free_cache:
		kmem_cache_free(kmem_cache, s);

 - but __kmem_cache_create() - at least for slub() - will have done

	sysfs_slab_add(s)
		-> sysfs_create_group() .. fails ..
		-> kobject_del(&s->kobj); .. which frees s ...

We can't remove the kmem_cache_free() in create_cache(), because other
error cases of __kmem_cache_create() do not free this.

So, revert the commit dde3c6b72a ("mm/slub: fix a memory leak in
sysfs_slab_add()") to fix this.

Reported-by: syzbot+d0bd96b4696c1ef67991@syzkaller.appspotmail.com
Fixes: dde3c6b72a ("mm/slub: fix a memory leak in sysfs_slab_add()")
Acked-by: Vlastimil Babka <vbabka@suse.cz>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-01-30 13:54:09 +01:00