gpio: pxa: handle corner case of unprobed device
Subsystems (11)
Sasha Levin
maintainerPATCH 1/21 gpio: pxa: handle corner case of unprobed device
From: Robert Jarzmik <[email protected]>
[ Upstream commit 9ce3ebe973bf4073426f35f282c6b955ed802765 ]
In the corner case where the gpio driver probe fails, for whatever reason, the suspend and resume handlers will still be called as they have to be registered as syscore operations. This applies as well when no probe was called while the driver has been built in the kernel.
Nicolas tracked this in :
https://bugzilla.kernel.org/show_bug.cgi?id=200905
Therefore, add a failsafe in these function, and test if a proper probe succeeded and the driver is functional.
--- drivers/gpio/gpio-pxa.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/gpio/gpio-pxa.c +6 -0
@@ -774,6 +774,9 @@ static int pxa_gpio_suspend(void)struct pxa_gpio_bank *c;int gpio; +if (!pchip) +return 0 ; +for_each_gpio_bank (gpio, c, pchip) { c->saved_gplr =readl_relaxed (c->regbase +GPLR_OFFSET ); c->saved_gpdr =readl_relaxed (c->regbase +GPDR_OFFSET );
@@ -792,6 +795,9 @@ static void pxa_gpio_resume(void)struct pxa_gpio_bank *c;int gpio; +if (!pchip) +return ; +for_each_gpio_bank (gpio, c, pchip) {/* restore level with set/clear */ writel_relaxed (c->saved_gplr, c->regbase +GPSR_OFFSET );
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 2/21 rsi: improve kernel thread handling to fix kernel panic
From: Siva Rebbagondla <[email protected]>
[ Upstream commit 4c62764d0fc21a34ffc44eec1210038c3a2e4473 ]
While running regressions, observed below kernel panic when sdio disconnect called. This is because of, kthread_stop() is taking care of wait_for_completion() by default. When wait_for_completion triggered in kthread_stop and as it was done already, giving kernel panic. Hence, removing redundant wait_for_completion() from rsi_kill_thread().
... skipping ...
BUG: unable to handle kernel NULL pointer dereference at (null) IP: [<ffffffff810a63df>] exit_creds+0x1f/0x50 PGD 0 Oops: 0002 [#1] SMP CPU: 0 PID: 6502 Comm: rmmod Tainted: G OE 4.15.9-Generic #154-Ubuntu Hardware name: Dell Inc. Edge Gateway 3003/ , BIOS 01.00.00 04/17/2017 Stack: ffff88007392e600 ffff880075847dc0 ffffffff8108160a 0000000000000000 ffff88007392e600 ffff880075847de8 ffffffff810a484b ffff880076127000 ffff88003cd3a800 ffff880074f12a00 ffff880075847e28 ffffffffc09bed15 Call Trace: [<ffffffff8108160a>] __put_task_struct+0x5a/0x140 [<ffffffff810a484b>] kthread_stop+0x10b/0x110 [<ffffffffc09bed15>] rsi_disconnect+0x2f5/0x300 [ven_rsi_sdio] [<ffffffff81578bcb>] ? __pm_runtime_resume+0x5b/0x80 [<ffffffff816f0918>] sdio_bus_remove+0x38/0x100 [<ffffffff8156cc64>] __device_release_driver+0xa4/0x150 [<ffffffff8156d7a5>] driver_detach+0xb5/0xc0 [<ffffffff8156c6c5>] bus_remove_driver+0x55/0xd0 [<ffffffff8156dfbc>] driver_unregister+0x2c/0x50 [<ffffffff816f0b8a>] sdio_unregister_driver+0x1a/0x20 [<ffffffffc09bf0f5>] rsi_module_exit+0x15/0x30 [ven_rsi_sdio] [<ffffffff8110cad8>] SyS_delete_module+0x1b8/0x210 [<ffffffff81851dc8>] entry_SYSCALL_64_fastpath+0x1c/0xbb
--- drivers/net/wireless/rsi/rsi_common.h | 1 - 1 file changed, 1 deletion(-)
drivers/net/wireless/rsi/rsi_common.h +0 -1
@@ -75,7 +75,6 @@ static inline int rsi_kill_thread(struct rsi_thread *handle)atomic_inc (&handle->thread_done);rsi_set_event (&handle->event); -wait_for_completion (&handle->completion);return kthread_stop (handle->task); }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 3/21 9p: do not trust pdu content for stat item size
In reply to Sasha LevinFrom: Gertjan Halkes <[email protected]>
[ Upstream commit 2803cf4379ed252894f046cb8812a48db35294e3 ]
v9fs_dir_readdir() could deadloop if a struct was sent with a size set to -2
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88021
--- fs/9p/vfs_dir.c | 8 +++----- net/9p/protocol.c | 3 ++- 2 files changed, 5 insertions(+), 6 deletions(-)
fs/9p/vfs_dir.c +3 -5
@@ -105,7 +105,6 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)int err =0 ;struct p9_fid *fid;int buflen; -int reclen =0 ;struct p9_rdir *rdir;struct kvec kvec;
@@ -138,11 +137,10 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)while (rdir->head < rdir->tail) { err =p9stat_read (fid->clnt, rdir->buf + rdir->head, rdir->tail - rdir->head, &st); -if (err) { +if (err <=0 ) {p9_debug (P9_DEBUG_VFS ,"returned %d\n" , err);return -EIO ; } - reclen = st.size+2 ; over = !dir_emit (ctx, st.name,strlen (st.name),v9fs_qid2ino (&st.qid),dt_type (&st));
@@ -150,8 +148,8 @@ static int v9fs_dir_readdir(struct file *file, struct dir_context *ctx)if (over)return 0 ; - rdir->head += reclen; - ctx->pos += reclen; + rdir->head += err; + ctx->pos += err; } } }
net/9p/protocol.c +2 -1
@@ -570,9 +570,10 @@ int p9stat_read(struct p9_client *clnt, char *buf, int len, struct p9_wstat *st)if (ret) {p9_debug (P9_DEBUG_9P ,"<<< p9stat_read failed: %d\n" , ret);trace_9p_protocol_dump (clnt, &fake_pdu); +return ret; } -return ret; +return fake_pdu.offset; }EXPORT_SYMBOL (p9stat_read);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 4/21 9p locks: add mount option for lock retry interval
In reply to Sasha LevinFrom: Dinu-Razvan Chis-Serban <[email protected]>
[ Upstream commit 5e172f75e51e3de1b4274146d9b990f803cb5c2a ]
The default P9_LOCK_TIMEOUT can be too long for some users exporting a local file system to a guest VM (30s), make this configurable at mount time.
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195727
--- fs/9p/v9fs.c | 21 +++++++++++++++++++++ fs/9p/v9fs.h | 1 + fs/9p/vfs_file.c | 6 +++++- 3 files changed, 27 insertions(+), 1 deletion(-)
fs/9p/v9fs.c +21 -0
@@ -59,6 +59,8 @@ enum { Opt_cache_loose, Opt_fscache, Opt_mmap,/* Access options */ Opt_access, Opt_posixacl, +/* Lock timeout option */ + Opt_locktimeout,/* Error token */ Opt_err };
@@ -78,6 +80,7 @@ static const match_table_t tokens = { {Opt_cachetag, "cachetag=%s"}, {Opt_access, "access=%s"}, {Opt_posixacl, "posixacl"}, + {Opt_locktimeout, "locktimeout=%u"}, {Opt_err, NULL} };
@@ -126,6 +129,7 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)#ifdef CONFIG_9P_FSCACHE v9ses->cachetag =NULL ;#endif + v9ses->session_lock_timeout =P9_LOCK_TIMEOUT ;if (!opts)return 0 ;
@@ -298,6 +302,23 @@ static int v9fs_parse_options(struct v9fs_session_info *v9ses, char *opts)#endif break ; +case Opt_locktimeout: + r =match_int (&args[0 ], &option); +if (r <0 ) { +p9_debug (P9_DEBUG_ERROR , +"integer field, but no integer?\n" ); + ret = r; +continue ; + } +if (option <1 ) { +p9_debug (P9_DEBUG_ERROR , +"locktimeout must be a greater than zero integer.\n" ); + ret = -EINVAL ; +continue ; + } + v9ses->session_lock_timeout = (long )option *HZ ; +break ; +default :continue ; }
fs/9p/v9fs.h +1 -0
@@ -116,6 +116,7 @@ struct v9fs_session_info {struct list_head slist;/* list of sessions registered with v9fs */ struct backing_dev_info bdi;struct rw_semaphore rename_sem; +long session_lock_timeout;/* retry interval for blocking locks */ };/* cache_validity flags */
fs/9p/vfs_file.c +5 -1
@@ -154,6 +154,7 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)uint8_t status =P9_LOCK_ERROR ;int res =0 ;unsigned char fl_type; +struct v9fs_session_info *v9ses; fid = filp->private_data;BUG_ON (fid ==NULL );
@@ -189,6 +190,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)if (IS_SETLKW (cmd)) flock.flags =P9_LOCK_FLAGS_BLOCK ; + v9ses =v9fs_inode2v9ses (file_inode (filp)); +/* * if its a blocked request and we get P9_LOCK_BLOCKED as the status * for lock request, keep on trying
@@ -202,7 +205,8 @@ static int v9fs_file_do_lock(struct file *filp, int cmd, struct file_lock *fl)break ;if (status ==P9_LOCK_BLOCKED && !IS_SETLKW (cmd))break ; -if (schedule_timeout_interruptible (P9_LOCK_TIMEOUT ) !=0 ) +if (schedule_timeout_interruptible (v9ses->session_lock_timeout) + !=0 )break ;/* * p9_client_lock_dotl overwrites flock.client_id with the
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 5/21 f2fs: fix to do sanity check with current segment number
In reply to Sasha LevinFrom: Chao Yu <[email protected]>
[ Upstream commit 042be0f849e5fc24116d0afecfaf926eed5cac63 ]
https://bugzilla.kernel.org/show_bug.cgi?id=200219
Reproduction way:
- mount image
- run poc code
- umount image
F2FS-fs (loop1): Bitmap was wrongly set, blk:15364
------------[ cut here ]------------ kernel BUG at /home/yuchao/git/devf2fs/segment.c:2061! invalid opcode: 0000 [#1] PREEMPT SMP CPU: 2 PID: 17686 Comm: umount Tainted: G W O 4.18.0-rc2+ #39 Hardware name: innotek GmbH VirtualBox/VirtualBox, BIOS VirtualBox 12/01/2006 EIP: update_sit_entry+0x459/0x4e0 [f2fs] Code: e8 1c b5 fd ff 0f 0b 0f 0b 8b 45 e4 c7 44 24 08 9c 7a 6c f8 c7 44 24 04 bc 4a 6c f8 89 44 24 0c 8b 06 89 04 24 e8 f7 b4 fd ff <0f> 0b 8b 45 e4 0f b6 d2 89 54 24 10 c7 44 24 08 60 7a 6c f8 c7 44 EAX: 00000032 EBX: 000000f8 ECX: 00000002 EDX: 00000001 ESI: d7177000 EDI: f520fe68 EBP: d6477c6c ESP: d6477c34 DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068 EFLAGS: 00010282 CR0: 80050033 CR2: b7fbe000 CR3: 2a99b3c0 CR4: 000406f0 Call Trace: f2fs_allocate_data_block+0x124/0x580 [f2fs] do_write_page+0x78/0x150 [f2fs] f2fs_do_write_node_page+0x25/0xa0 [f2fs] __write_node_page+0x2bf/0x550 [f2fs] f2fs_sync_node_pages+0x60e/0x6d0 [f2fs] ? sync_inode_metadata+0x2f/0x40 ? f2fs_write_checkpoint+0x28f/0x7d0 [f2fs] ? up_write+0x1e/0x80 f2fs_write_checkpoint+0x2a9/0x7d0 [f2fs] ? mark_held_locks+0x5d/0x80 ? _raw_spin_unlock_irq+0x27/0x50 kill_f2fs_super+0x68/0x90 [f2fs] deactivate_locked_super+0x3d/0x70 deactivate_super+0x40/0x60 cleanup_mnt+0x39/0x70 __cleanup_mnt+0x10/0x20 task_work_run+0x81/0xa0 exit_to_usermode_loop+0x59/0xa7 do_fast_syscall_32+0x1f5/0x22c entry_SYSENTER_32+0x53/0x86 EIP: 0xb7f95c51 Code: c1 1e f7 ff ff 89 e5 8b 55 08 85 d2 8b 81 64 cd ff ff 74 02 89 02 5d c3 8b 0c 24 c3 8b 1c 24 c3 90 51 52 55 89 e5 0f 34 cd 80 <5d> 5a 59 c3 90 90 90 90 8d 76 00 58 b8 77 00 00 00 cd 80 90 8d 76 EAX: 00000000 EBX: 0871ab90 ECX: bfb2cd00 EDX: 00000000 ESI: 00000000 EDI: 0871ab90 EBP: 0871ab90 ESP: bfb2cd7c DS: 007b ES: 007b FS: 0000 GS: 0033 SS: 007b EFLAGS: 00000246 Modules linked in: f2fs(O) crc32_generic bnep rfcomm bluetooth ecdh_generic snd_intel8x0 snd_ac97_codec ac97_bus snd_pcm snd_seq_midi snd_seq_midi_event snd_rawmidi snd_seq pcbc joydev aesni_intel snd_seq_device aes_i586 snd_timer crypto_simd snd cryptd soundcore mac_hid serio_raw video i2c_piix4 parport_pc ppdev lp parport hid_generic psmouse usbhid hid e1000 [last unloaded: f2fs] ---[ end trace d423f83982cfcdc5 ]---
The reason is, different log headers using the same segment, once one log's next block address is used by another log, it will cause panic as above.
Main area: 24 segs, 24 secs 24 zones
- COLD data: 0, 0, 0 - WARM data: 1, 1, 1 - HOT data: 20, 20, 20 - Dir dnode: 22, 22, 22
- File dnode: 22, 22, 22
- Indir nodes: 21, 21, 21
So this patch adds sanity check to detect such condition to avoid this issue.
--- fs/f2fs/super.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-)
fs/f2fs/super.c +33 -1
@@ -1489,7 +1489,7 @@ int sanity_check_ckpt(struct f2fs_sb_info *sbi)unsigned int segment_count_main;unsigned int cp_pack_start_sum, cp_payload;block_t user_block_count; -int i; +int i, j; total =le32_to_cpu (raw_super->segment_count); fsmeta =le32_to_cpu (raw_super->segment_count_ckpt);
@@ -1530,11 +1530,43 @@ int sanity_check_ckpt(struct f2fs_sb_info *sbi)if (le32_to_cpu (ckpt->cur_node_segno[i]) >= main_segs ||le16_to_cpu (ckpt->cur_node_blkoff[i]) >= blocks_per_seg)return 1 ; +for (j = i +1 ; j <NR_CURSEG_NODE_TYPE ; j++) { +if (le32_to_cpu (ckpt->cur_node_segno[i]) == +le32_to_cpu (ckpt->cur_node_segno[j])) { +f2fs_msg (sbi->sb,KERN_ERR , +"Node segment (%u, %u) has the same " +"segno: %u" , i, j, +le32_to_cpu (ckpt->cur_node_segno[i])); +return 1 ; + } + } }for (i =0 ; i <NR_CURSEG_DATA_TYPE ; i++) {if (le32_to_cpu (ckpt->cur_data_segno[i]) >= main_segs ||le16_to_cpu (ckpt->cur_data_blkoff[i]) >= blocks_per_seg)return 1 ; +for (j = i +1 ; j <NR_CURSEG_DATA_TYPE ; j++) { +if (le32_to_cpu (ckpt->cur_data_segno[i]) == +le32_to_cpu (ckpt->cur_data_segno[j])) { +f2fs_msg (sbi->sb,KERN_ERR , +"Data segment (%u, %u) has the same " +"segno: %u" , i, j, +le32_to_cpu (ckpt->cur_data_segno[i])); +return 1 ; + } + } + } +for (i =0 ; i <NR_CURSEG_NODE_TYPE ; i++) { +for (j = i; j <NR_CURSEG_DATA_TYPE ; j++) { +if (le32_to_cpu (ckpt->cur_node_segno[i]) == +le32_to_cpu (ckpt->cur_data_segno[j])) { +f2fs_msg (sbi->sb,KERN_ERR , +"Data segment (%u) and Data segment (%u)" +" has the same segno: %u" , i, j, +le32_to_cpu (ckpt->cur_node_segno[i])); +return 1 ; + } + } } sit_bitmap_size =le32_to_cpu (ckpt->sit_ver_bitmap_bytesize);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 6/21 serial: uartps: console_setup() can't be placed to init section
In reply to Sasha LevinFrom: Michal Simek <[email protected]>
[ Upstream commit 4bb1ce2350a598502b23088b169e16b43d4bc639 ]
When console device is rebinded, console_setup() is called again. But marking it as __init means that function will be clear after boot is complete. If console device is binded again console_setup() is not found and error "Unable to handle kernel paging request at virtual address" is reported.
--- drivers/tty/serial/xilinx_uartps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/tty/serial/xilinx_uartps.c +1 -1
@@ -1261,7 +1261,7 @@ static void cdns_uart_console_write(struct console *co, const char *s,* * Return: 0 on success, negative errno otherwise. */ -static int __init cdns_uart_console_setup (struct console *co,char *options) +static int cdns_uart_console_setup (struct console *co,char *options) {struct uart_port *port = &cdns_uart_port[co->index];int baud =9600 ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 7/21 HID: i2c-hid: override HID descriptors for certain devices
In reply to Sasha LevinFrom: Julian Sax <[email protected]>
[ Upstream commit 9ee3e06610fdb8a601cde59c92089fb6c1deb4aa ]
A particular touchpad (SIPODEV SP1064) refuses to supply the HID descriptors. This patch provides the framework for overriding these descriptors based on DMI data. It also includes the descriptors for said touchpad, which were extracted by listening to the traffic of the windows filter driver, as well as the DMI data for the laptops known to use this device.
Relevant Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1526312
---
drivers/hid/i2c-hid/Makefile | 3 +
.../hid/i2c-hid/{i2c-hid.c => i2c-hid-core.c} | 56 ++-
drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c | 376 ++++++++++++++++++
drivers/hid/i2c-hid/i2c-hid.h | 20 +
4 files changed, 437 insertions(+), 18 deletions(-)
rename drivers/hid/i2c-hid/{i2c-hid.c => i2c-hid-core.c} (96%)
create mode 100644 drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c
create mode 100644 drivers/hid/i2c-hid/i2c-hid.hdrivers/hid/i2c-hid/Makefile +3 -0
@@ -3,3 +3,6 @@ # obj-$(CONFIG_I2C_HID) += i2c-hid.o + +i2c-hid-objs = i2c-hid-core.o +i2c-hid-$(CONFIG_DMI) += i2c-hid-dmi-quirks.o
drivers/hid/i2c-hid/i2c-hid-core.c renamed from drivers/hid/i2c-hid/i2c-hid.c +38 -18
88 lines not on this page · raw message
drivers/hid/i2c-hid/i2c-hid-dmi-quirks.c new file +376 -0
376 lines not on this page · raw message
drivers/hid/i2c-hid/i2c-hid.h new file +20 -0
@@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ + +#ifndef I2C_HID_H +#define I2C_HID_H + + +#ifdef CONFIG_DMI +struct i2c_hid_desc *i2c_hid_get_dmi_i2c_hid_desc_override (uint8_t *i2c_name); +char *i2c_hid_get_dmi_hid_report_desc_override (uint8_t *i2c_name, +unsigned int *size); +#else +static inline struct i2c_hid_desc + *i2c_hid_get_dmi_i2c_hid_desc_override (uint8_t *i2c_name) +{return NULL ; } +static inline char *i2c_hid_get_dmi_hid_report_desc_override (uint8_t *i2c_name, +unsigned int *size) +{return NULL ; } +#endif + +#endif
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 8/21 ARM: samsung: Limit SAMSUNG_PM_CHECK config option to non-Exynos platforms
In reply to Sasha LevinFrom: Bartlomiej Zolnierkiewicz <[email protected]>
[ Upstream commit 6862fdf2201ab67cd962dbf0643d37db909f4860 ]
"S3C2410 PM Suspend Memory CRC" feature (controlled by SAMSUNG_PM_CHECK config option) is incompatible with highmem (uses phys_to_virt() instead of proper mapping) which is used by the majority of Exynos boards. The issue manifests itself in OOPS on affected boards, i.e. on Odroid-U3 I got the following one:
Unable to handle kernel paging request at virtual address f0000000 pgd = 1c0f9bb4 [f0000000] *pgd=00000000 Internal error: Oops: 5 [#1] PREEMPT SMP ARM [<c0458034>] (crc32_le) from [<c0121f8c>] (s3c_pm_makecheck+0x34/0x54) [<c0121f8c>] (s3c_pm_makecheck) from [<c0121efc>] (s3c_pm_run_res+0x74/0x8c) [<c0121efc>] (s3c_pm_run_res) from [<c0121ecc>] (s3c_pm_run_res+0x44/0x8c) [<c0121ecc>] (s3c_pm_run_res) from [<c01210b8>] (exynos_suspend_enter+0x64/0x148) [<c01210b8>] (exynos_suspend_enter) from [<c018893c>] (suspend_devices_and_enter+0x9ec/0xe74) [<c018893c>] (suspend_devices_and_enter) from [<c0189534>] (pm_suspend+0x770/0xc04) [<c0189534>] (pm_suspend) from [<c0186ce8>] (state_store+0x6c/0xcc) [<c0186ce8>] (state_store) from [<c09db434>] (kobj_attr_store+0x14/0x20) [<c09db434>] (kobj_attr_store) from [<c02fa63c>] (sysfs_kf_write+0x4c/0x50) [<c02fa63c>] (sysfs_kf_write) from [<c02f97a4>] (kernfs_fop_write+0xfc/0x1e4) [<c02f97a4>] (kernfs_fop_write) from [<c027b198>] (__vfs_write+0x2c/0x140) [<c027b198>] (__vfs_write) from [<c027b418>] (vfs_write+0xa4/0x160) [<c027b418>] (vfs_write) from [<c027b5d8>] (ksys_write+0x40/0x8c) [<c027b5d8>] (ksys_write) from [<c0101000>] (ret_fast_syscall+0x0/0x28)
Add PLAT_S3C24XX, ARCH_S3C64XX and ARCH_S5PV210 dependencies to SAMSUNG_PM_CHECK config option to hide it on Exynos platforms.
--- arch/arm/plat-samsung/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/plat-samsung/Kconfig +1 -1
@@ -258,7 +258,7 @@ config S3C_PM_DEBUG_LED_SMDK config SAMSUNG_PM_CHECK bool "S3C2410 PM Suspend Memory CRC" - depends on PM + depends on PM && (PLAT_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210) select CRC32 help Enable the PM code's memory area checksum over sleep. This option
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 9/21 ACPI / SBS: Fix GPE storm on recent MacBookPro's
In reply to Sasha LevinFrom: Ronald Tschalär <[email protected]>
[ Upstream commit ca1721c5bee77105829cbd7baab8ee0eab85b06d ]
On Apple machines, plugging-in or unplugging the power triggers a GPE for the EC. Since these machines expose an SBS device, this GPE ends up triggering the acpi_sbs_callback(). This in turn tries to get the status of the SBS charger. However, on MBP13,* and MBP14,* machines, performing the smbus-read operation to get the charger's status triggers the EC's GPE again. The result is an endless re-triggering and handling of that GPE, consuming significant CPU resources (> 50% in irq).
In the end this is quite similar to commit 3031cddea633 (ACPI / SBS:
Don't assume the existence of an SBS charger), except that on the above machines a status of all 1's is returned. And like there, we just want ignore the charger here.
--- drivers/acpi/sbs.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/acpi/sbs.c +6 -2
@@ -443,9 +443,13 @@ static int acpi_ac_get_present(struct acpi_sbs *sbs)/* * The spec requires that bit 4 always be 1. If it's not set, assume -* that the implementation doesn't support an SBS charger +* that the implementation doesn't support an SBS charger. +* +* And on some MacBooks a status of 0xffff is always returned, no +* matter whether the charger is plugged in or not, which is also +* wrong, so ignore the SBS charger for those too. */ -if (!((status >>4 ) &0x1 )) +if (!((status >>4 ) &0x1 ) || status ==0xffff )return -ENODEV ; sbs->charger_present = (status >>15 ) &0x1 ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 10/21 cifs: fallback to older infolevels on findfirst queryinfo retry
In reply to Sasha LevinFrom: Steve French <[email protected]>
[ Upstream commit 3b7960caceafdfc2cdfe2850487f8d091eb41144 ]
In cases where queryinfo fails, we have cases in cifs (vers=1.0) where with backupuid mounts we retry the query info with findfirst. This doesn't work to some NetApp servers which don't support WindowsXP (and later) infolevel 261 (SMB_FIND_FILE_ID_FULL_DIR_INFO) so in this case use other info levels (in this case it will usually be level 257, SMB_FIND_FILE_DIRECTORY_INFO).
(Also fixes some indentation)
See kernel bugzilla 201435
--- fs/cifs/inode.c | 67 +++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 30 deletions(-)
fs/cifs/inode.c +37 -30
@@ -771,43 +771,50 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, }else if ((rc == -EACCES ) &&backup_cred (cifs_sb) && (strcmp (server->vals->version_string,SMB1_VERSION_STRING ) ==0 )) { -/* -* For SMB2 and later the backup intent flag is already -* sent if needed on open and there is no path based -* FindFirst operation to use to retry with -*/ +/* +* For SMB2 and later the backup intent flag is already +* sent if needed on open and there is no path based +* FindFirst operation to use to retry with +*/ - srchinf =kzalloc (sizeof (struct cifs_search_info ), -GFP_KERNEL ); -if (srchinf ==NULL ) { - rc = -ENOMEM ; - goto cgii_exit; - } + srchinf =kzalloc (sizeof (struct cifs_search_info ), +GFP_KERNEL ); +if (srchinf ==NULL ) { + rc = -ENOMEM ; + goto cgii_exit; + } - srchinf->endOfSearch = false; + srchinf->endOfSearch = false; +if (tcon->unix_ext) + srchinf->info_level =SMB_FIND_FILE_UNIX ; +else if ((tcon->ses->capabilities & + tcon->ses->server->vals->cap_nt_find) ==0 ) + srchinf->info_level =SMB_FIND_FILE_INFO_STANDARD ; +else if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM ) srchinf->info_level =SMB_FIND_FILE_ID_FULL_DIR_INFO ; +else /* no srvino useful for fallback to some netapp */ + srchinf->info_level =SMB_FIND_FILE_DIRECTORY_INFO ; - srchflgs =CIFS_SEARCH_CLOSE_ALWAYS | -CIFS_SEARCH_CLOSE_AT_END | -CIFS_SEARCH_BACKUP_SEARCH ; + srchflgs =CIFS_SEARCH_CLOSE_ALWAYS | +CIFS_SEARCH_CLOSE_AT_END | +CIFS_SEARCH_BACKUP_SEARCH ; - rc =CIFSFindFirst (xid, tcon, full_path, - cifs_sb,NULL , srchflgs, srchinf, false); -if (!rc) { - data = - (FILE_ALL_INFO *)srchinf->srch_entries_start; + rc =CIFSFindFirst (xid, tcon, full_path, + cifs_sb,NULL , srchflgs, srchinf, false); +if (!rc) { + data = (FILE_ALL_INFO *)srchinf->srch_entries_start; -cifs_dir_info_to_fattr (&fattr, - (FILE_DIRECTORY_INFO *)data, cifs_sb); - fattr.cf_uniqueid =le64_to_cpu ( - ((SEARCH_ID_FULL_DIR_INFO *)data)->UniqueId); - validinum = true; +cifs_dir_info_to_fattr (&fattr, + (FILE_DIRECTORY_INFO *)data, cifs_sb); + fattr.cf_uniqueid =le64_to_cpu ( + ((SEARCH_ID_FULL_DIR_INFO *)data)->UniqueId); + validinum = true; -cifs_buf_release (srchinf->ntwrk_buf_start); - } -kfree (srchinf); -if (rc) - goto cgii_exit; +cifs_buf_release (srchinf->ntwrk_buf_start); + } +kfree (srchinf); +if (rc) + goto cgii_exit; }else goto cgii_exit;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 11/21 kernel: hung_task.c: disable on suspend
In reply to Sasha LevinFrom: Vitaly Kuznetsov <[email protected]>
[ Upstream commit a1c6ca3c6de763459a6e93b644ec6518c890ba1c ]
It is possible to observe hung_task complaints when system goes to suspend-to-idle state:
# echo freeze > /sys/power/state
PM: Syncing filesystems ... done.
Freezing user space processes ... (elapsed 0.001 seconds) done. OOM killer disabled.
Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done. sd 0:0:0:0: [sda] Synchronizing SCSI cache
INFO: task bash:1569 blocked for more than 120 seconds.
Not tainted 4.19.0-rc3_+ #687
"echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
bash D 0 1569 604 0x00000000
Call Trace:
? __schedule+0x1fe/0x7e0
schedule+0x28/0x80
suspend_devices_and_enter+0x4ac/0x750
pm_suspend+0x2c0/0x310Register a PM notifier to disable the detector on suspend and re-enable back on wakeup.
--- kernel/hung_task.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
kernel/hung_task.c +29 -1
@@ -15,6 +15,7 @@#include <linux/lockdep.h> #include <linux/export.h> #include <linux/sysctl.h> +#include <linux/suspend.h> #include <linux/utsname.h> #include <trace/events/sched.h>
@@ -221,6 +222,28 @@ void reset_hung_task_detector(void) }EXPORT_SYMBOL_GPL (reset_hung_task_detector); +static bool hung_detector_suspended; + +static int hungtask_pm_notify (struct notifier_block *self, +unsigned long action,void *hcpu) +{ +switch (action) { +case PM_SUSPEND_PREPARE : +case PM_HIBERNATION_PREPARE : +case PM_RESTORE_PREPARE : + hung_detector_suspended = true; +break ; +case PM_POST_SUSPEND : +case PM_POST_HIBERNATION : +case PM_POST_RESTORE : + hung_detector_suspended = false; +break ; +default : +break ; + } +return NOTIFY_OK ; +} +/* * kthread which checks for tasks stuck in D state */
@@ -235,7 +258,8 @@ static int watchdog(void *dummy)long t =hung_timeout_jiffies (hung_last_checked, timeout);if (t <=0 ) { -if (!atomic_xchg (&reset_hung_task,0 )) +if (!atomic_xchg (&reset_hung_task,0 ) && + !hung_detector_suspended)check_hung_uninterruptible_tasks (timeout); hung_last_checked = jiffies;continue ;
@@ -249,6 +273,10 @@ static int watchdog(void *dummy)static int __init hung_task_init (void ) {atomic_notifier_chain_register (&panic_notifier_list, &panic_block); + +/* Disable hung task detector on suspend */ +pm_notifier (hungtask_pm_notify,0 ); + watchdog_task =kthread_run (watchdog,NULL ,"khungtaskd" );return 0 ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 12/21 crypto: sha256/arm - fix crash bug in Thumb2 build
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit 69216a545cf81b2b32d01948f7039315abaf75a0 ]
The SHA256 code we adopted from the OpenSSL project uses a rather peculiar way to take the address of the round constant table: it takes the address of the sha256_block_data_order() routine, and substracts a constant known quantity to arrive at the base of the table, which is emitted by the same assembler code right before the routine's entry point.
However, recent versions of binutils have helpfully changed the behavior of references emitted via an ADR instruction when running in Thumb2 mode: it now takes the Thumb execution mode bit into account, which is bit 0 af the address. This means the produced table address also has bit 0 set, and so we end up with an address value pointing 1 byte past the start of the table, which results in crashes such as
Unable to handle kernel paging request at virtual address bf825000 pgd = 42f44b11 [bf825000] *pgd=80000040206003, *pmd=5f1bd003, *pte=00000000 Internal error: Oops: 207 [#1] PREEMPT SMP THUMB2 Modules linked in: sha256_arm(+) sha1_arm_ce sha1_arm ... CPU: 7 PID: 396 Comm: cryptomgr_test Not tainted 5.0.0-rc6+ #144 Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 PC is at sha256_block_data_order+0xaaa/0xb30 [sha256_arm] LR is at __this_module+0x17fd/0xffffe800 [sha256_arm] pc : [<bf820bca>] lr : [<bf824ffd>] psr: 800b0033 sp : ebc8bbe8 ip : faaabe1c fp : 2fdd3433 r10: 4c5f1692 r9 : e43037df r8 : b04b0a5a r7 : c369d722 r6 : 39c3693e r5 : 7a013189 r4 : 1580d26b r3 : 8762a9b0 r2 : eea9c2cd r1 : 3e9ab536 r0 : 1dea4ae7 Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA Thumb Segment user Control: 70c5383d Table: 6b8467c0 DAC: dbadc0de Process cryptomgr_test (pid: 396, stack limit = 0x69e1fe23) Stack: (0xebc8bbe8 to 0xebc8c000) ... unwind: Unknown symbol address bf820bca unwind: Index not found bf820bca Code: 441a ea80 40f9 440a (f85e) 3b04 ---[ end trace e560cce92700ef8a ]---
Given that this affects older kernels as well, in case they are built with a recent toolchain, apply a minimal backportable fix, which is to emit another non-code label at the start of the routine, and reference that instead. (This is similar to the current upstream state of this file in OpenSSL)
--- arch/arm/crypto/sha256-armv4.pl | 3 ++- arch/arm/crypto/sha256-core.S_shipped | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/crypto/sha256-armv4.pl +2 -1
@@ -205,10 +205,11 @@ K256: .global sha256_block_data_order .type sha256_block_data_order,%function sha256_block_data_order: +.Lsha256_block_data_order: #if __ARM_ARCH__<7 sub r3,pc,#8 @ sha256_block_data_order #else - adr r3,sha256_block_data_order + adr r3,.Lsha256_block_data_order #endif #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) ldr r12,.LOPENSSL_armcap
arch/arm/crypto/sha256-core.S_shipped +2 -1
@@ -86,10 +86,11 @@ K256: .global sha256_block_data_order .type sha256_block_data_order,%function sha256_block_data_order: +.Lsha256_block_data_order: #if __ARM_ARCH__<7 sub r3,pc,#8 @ sha256_block_data_order #else - adr r3,sha256_block_data_order + adr r3,.Lsha256_block_data_order #endif #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) ldr r12,.LOPENSSL_armcap
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 13/21 crypto: sha512/arm - fix crash bug in Thumb2 build
In reply to Sasha LevinFrom: Ard Biesheuvel <[email protected]>
[ Upstream commit c64316502008064c158fa40cc250665e461b0f2a ]
The SHA512 code we adopted from the OpenSSL project uses a rather peculiar way to take the address of the round constant table: it takes the address of the sha256_block_data_order() routine, and substracts a constant known quantity to arrive at the base of the table, which is emitted by the same assembler code right before the routine's entry point.
However, recent versions of binutils have helpfully changed the behavior of references emitted via an ADR instruction when running in Thumb2 mode: it now takes the Thumb execution mode bit into account, which is bit 0 af the address. This means the produced table address also has bit 0 set, and so we end up with an address value pointing 1 byte past the start of the table, which results in crashes such as
Unable to handle kernel paging request at virtual address bf825000 pgd = 42f44b11 [bf825000] *pgd=80000040206003, *pmd=5f1bd003, *pte=00000000 Internal error: Oops: 207 [#1] PREEMPT SMP THUMB2 Modules linked in: sha256_arm(+) sha1_arm_ce sha1_arm ... CPU: 7 PID: 396 Comm: cryptomgr_test Not tainted 5.0.0-rc6+ #144 Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 PC is at sha256_block_data_order+0xaaa/0xb30 [sha256_arm] LR is at __this_module+0x17fd/0xffffe800 [sha256_arm] pc : [<bf820bca>] lr : [<bf824ffd>] psr: 800b0033 sp : ebc8bbe8 ip : faaabe1c fp : 2fdd3433 r10: 4c5f1692 r9 : e43037df r8 : b04b0a5a r7 : c369d722 r6 : 39c3693e r5 : 7a013189 r4 : 1580d26b r3 : 8762a9b0 r2 : eea9c2cd r1 : 3e9ab536 r0 : 1dea4ae7 Flags: Nzcv IRQs on FIQs on Mode SVC_32 ISA Thumb Segment user Control: 70c5383d Table: 6b8467c0 DAC: dbadc0de Process cryptomgr_test (pid: 396, stack limit = 0x69e1fe23) Stack: (0xebc8bbe8 to 0xebc8c000) ... unwind: Unknown symbol address bf820bca unwind: Index not found bf820bca Code: 441a ea80 40f9 440a (f85e) 3b04 ---[ end trace e560cce92700ef8a ]---
Given that this affects older kernels as well, in case they are built with a recent toolchain, apply a minimal backportable fix, which is to emit another non-code label at the start of the routine, and reference that instead. (This is similar to the current upstream state of this file in OpenSSL)
--- arch/arm/crypto/sha512-armv4.pl | 3 ++- arch/arm/crypto/sha512-core.S_shipped | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
arch/arm/crypto/sha512-armv4.pl +2 -1
@@ -267,10 +267,11 @@ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) .global sha512_block_data_order .type sha512_block_data_order,%function sha512_block_data_order: +.Lsha512_block_data_order: #if __ARM_ARCH__<7 sub r3,pc,#8 @ sha512_block_data_order #else - adr r3,sha512_block_data_order + adr r3,.Lsha512_block_data_order #endif #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) ldr r12,.LOPENSSL_armcap
arch/arm/crypto/sha512-core.S_shipped +2 -1
@@ -134,10 +134,11 @@ WORD64(0x5fcb6fab,0x3ad6faec, 0x6c44198c,0x4a475817) .global sha512_block_data_order .type sha512_block_data_order,%function sha512_block_data_order: +.Lsha512_block_data_order: #if __ARM_ARCH__<7 sub r3,pc,#8 @ sha512_block_data_order #else - adr r3,sha512_block_data_order + adr r3,.Lsha512_block_data_order #endif #if __ARM_MAX_ARCH__>=7 && !defined(__KERNEL__) ldr r12,.LOPENSSL_armcap
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 14/21 iommu/dmar: Fix buffer overflow during PCI bus notification
In reply to Sasha LevinFrom: Julia Cartwright <[email protected]>
[ Upstream commit cffaaf0c816238c45cd2d06913476c83eb50f682 ]
Commit 57384592c433 ("iommu/vt-d: Store bus information in RMRR PCI device path") changed the type of the path data, however, the change in path type was not reflected in size calculations. Update to use the correct type and prevent a buffer overflow.
This bug manifests in systems with deep PCI hierarchies, and can lead to an overflow of the static allocated buffer (dmar_pci_notify_info_buf), or can lead to overflow of slab-allocated data.
BUG: KASAN: global-out-of-bounds in dmar_alloc_pci_notify_info+0x1d5/0x2e0
Write of size 1 at addr ffffffff90445d80 by task swapper/0/1
CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.14.87-rt49-02406-gd0a0e96 #1
Call Trace:
? dump_stack+0x46/0x59
? print_address_description+0x1df/0x290
? dmar_alloc_pci_notify_info+0x1d5/0x2e0
? kasan_report+0x256/0x340
? dmar_alloc_pci_notify_info+0x1d5/0x2e0
? e820__memblock_setup+0xb0/0xb0
? dmar_dev_scope_init+0x424/0x48f
? __down_write_common+0x1ec/0x230
? dmar_dev_scope_init+0x48f/0x48f
? dmar_free_unused_resources+0x109/0x109
? cpumask_next+0x16/0x20
? __kmem_cache_create+0x392/0x430
? kmem_cache_create+0x135/0x2f0
? e820__memblock_setup+0xb0/0xb0
? intel_iommu_init+0x170/0x1848
? _raw_spin_unlock_irqrestore+0x32/0x60
? migrate_enable+0x27a/0x5b0
? sched_setattr+0x20/0x20
? migrate_disable+0x1fc/0x380
? task_rq_lock+0x170/0x170
? try_to_run_init_process+0x40/0x40
? locks_remove_file+0x85/0x2f0
? dev_prepare_static_identity_mapping+0x78/0x78
? rt_spin_unlock+0x39/0x50
? lockref_put_or_lock+0x2a/0x40
? dput+0x128/0x2f0
? __rcu_read_unlock+0x66/0x80
? __fput+0x250/0x300
? __rcu_read_lock+0x1b/0x30
? mntput_no_expire+0x38/0x290
? e820__memblock_setup+0xb0/0xb0
? pci_iommu_init+0x25/0x63
? pci_iommu_init+0x25/0x63
? do_one_initcall+0x7e/0x1c0
? initcall_blacklisted+0x120/0x120
? kernel_init_freeable+0x27b/0x307
? rest_init+0xd0/0xd0
? kernel_init+0xf/0x120
? rest_init+0xd0/0xd0
? ret_from_fork+0x1f/0x40
The buggy address belongs to the variable:
dmar_pci_notify_info_buf+0x40/0x60--- drivers/iommu/dmar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/dmar.c +1 -1
@@ -143,7 +143,7 @@ dmar_alloc_pci_notify_info(struct pci_dev *dev, unsigned long event)for (tmp = dev; tmp; tmp = tmp->bus->self) level++; - size =sizeof (*info) + level *sizeof (struct acpi_dmar_pci_path ); + size =sizeof (*info) + level *sizeof (info->path[0 ]);if (size <=sizeof (dmar_pci_notify_info_buf)) { info = (struct dmar_pci_notify_info *)dmar_pci_notify_info_buf; }else {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 15/21 soc/tegra: pmc: Drop locking from tegra_powergate_is_powered()
In reply to Sasha LevinFrom: Dmitry Osipenko <[email protected]>
[ Upstream commit b6e1fd17a38bd1d97c11d69fd3207b3ef9bfa4b3 ]
This fixes splats like the one below if CONFIG_DEBUG_ATOMIC_SLEEP=y and machine (Tegra30) booted with SMP=n or all secondary CPU's are put offline. Locking isn't needed because it protects atomic operation.
BUG: sleeping function called from invalid context at kernel/locking/mutex.c:254 in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper/0 CPU: 0 PID: 0 Comm: swapper/0 Tainted: G C 4.18.0-next-20180821-00180-gc3ebb6544e44-dirty #823 Hardware name: NVIDIA Tegra SoC (Flattened Device Tree) [<c01134f4>] (unwind_backtrace) from [<c010db2c>] (show_stack+0x20/0x24) [<c010db2c>] (show_stack) from [<c0bd0f3c>] (dump_stack+0x94/0xa8) [<c0bd0f3c>] (dump_stack) from [<c0151df8>] (___might_sleep+0x13c/0x174) [<c0151df8>] (___might_sleep) from [<c0151ea0>] (__might_sleep+0x70/0xa8) [<c0151ea0>] (__might_sleep) from [<c0bec2b8>] (mutex_lock+0x2c/0x70) [<c0bec2b8>] (mutex_lock) from [<c0589844>] (tegra_powergate_is_powered+0x44/0xa8) [<c0589844>] (tegra_powergate_is_powered) from [<c0581a60>] (tegra30_cpu_rail_off_ready+0x30/0x74) [<c0581a60>] (tegra30_cpu_rail_off_ready) from [<c0122244>] (tegra30_idle_lp2+0xa0/0x108) [<c0122244>] (tegra30_idle_lp2) from [<c0853438>] (cpuidle_enter_state+0x140/0x540) [<c0853438>] (cpuidle_enter_state) from [<c08538a4>] (cpuidle_enter+0x40/0x4c) [<c08538a4>] (cpuidle_enter) from [<c01595e0>] (call_cpuidle+0x30/0x48) [<c01595e0>] (call_cpuidle) from [<c01599f8>] (do_idle+0x238/0x28c) [<c01599f8>] (do_idle) from [<c0159d28>] (cpu_startup_entry+0x28/0x2c) [<c0159d28>] (cpu_startup_entry) from [<c0be76c8>] (rest_init+0xd8/0xdc) [<c0be76c8>] (rest_init) from [<c1200f50>] (start_kernel+0x41c/0x430)
--- drivers/soc/tegra/pmc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/soc/tegra/pmc.c +1 -7
@@ -512,16 +512,10 @@ EXPORT_SYMBOL(tegra_powergate_power_off);*/ int tegra_powergate_is_powered (unsigned int id) { -int status; -if (!tegra_powergate_is_valid (id))return -EINVAL ; -mutex_lock (&pmc->powergates_lock); - status =tegra_powergate_state (id); -mutex_unlock (&pmc->powergates_lock); - -return status; +return tegra_powergate_state (id); }/**
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 16/21 ext4: prohibit fstrim in norecovery mode
In reply to Sasha LevinFrom: "Darrick J. Wong" <[email protected]>
[ Upstream commit 18915b5873f07e5030e6fb108a050fa7c71c59fb ]
The ext4 fstrim implementation uses the block bitmaps to find free space that can be discarded. If we haven't replayed the journal, the bitmaps will be stale and we absolutely *cannot* use stale metadata to zap the underlying storage.
--- fs/ext4/ioctl.c | 7 +++++++ 1 file changed, 7 insertions(+)
fs/ext4/ioctl.c +7 -0
@@ -749,6 +749,13 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)if (!blk_queue_discard (q))return -EOPNOTSUPP ; +/* +* We haven't replayed the journal, so we cannot use our +* block-bitmap-guided storage zapping commands. +*/ +if (test_opt (sb,NOLOAD ) &&ext4_has_feature_journal (sb)) +return -EROFS ; +if (copy_from_user (&range, (struct fstrim_range __user *)arg,sizeof (range)))return -EFAULT ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 17/21 lkdtm: Add tests for NULL pointer dereference
In reply to Sasha LevinFrom: Christophe Leroy <[email protected]>
[ Upstream commit 59a12205d3c32aee4c13ca36889fdf7cfed31126 ]
Introduce lkdtm tests for NULL pointer dereference: check access or exec at NULL address, since these errors tend to be reported differently from the general fault error text. For example from x86:
pr_alert("BUG: unable to handle kernel %s at %px\n",
address < PAGE_SIZE ? "NULL pointer dereference" : "paging request", (void *)address);
--- drivers/misc/lkdtm.h | 2 ++ drivers/misc/lkdtm_core.c | 2 ++ drivers/misc/lkdtm_perms.c | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+)
drivers/misc/lkdtm.h +2 -0
@@ -40,7 +40,9 @@ void lkdtm_EXEC_KMALLOC(void);void lkdtm_EXEC_VMALLOC (void );void lkdtm_EXEC_RODATA (void );void lkdtm_EXEC_USERSPACE (void ); +void lkdtm_EXEC_NULL (void );void lkdtm_ACCESS_USERSPACE (void ); +void lkdtm_ACCESS_NULL (void );/* lkdtm_rodata.c */ void lkdtm_rodata_do_nothing (void );
drivers/misc/lkdtm_core.c +2 -0
@@ -214,7 +214,9 @@ struct crashtype crashtypes[] = {CRASHTYPE (EXEC_VMALLOC ),CRASHTYPE (EXEC_RODATA ),CRASHTYPE (EXEC_USERSPACE ), +CRASHTYPE (EXEC_NULL ),CRASHTYPE (ACCESS_USERSPACE ), +CRASHTYPE (ACCESS_NULL ),CRASHTYPE (WRITE_RO ),CRASHTYPE (WRITE_RO_AFTER_INIT ), CRASHTYPE(WRITE_KERN),
drivers/misc/lkdtm_perms.c +18 -0
@@ -160,6 +160,11 @@ void lkdtm_EXEC_USERSPACE(void)vm_munmap (user_addr,PAGE_SIZE ); } +void lkdtm_EXEC_NULL (void ) +{ +execute_location (NULL ,CODE_AS_IS ); +} +void lkdtm_ACCESS_USERSPACE (void ) {unsigned long user_addr, tmp =0 ;
@@ -191,6 +196,19 @@ void lkdtm_ACCESS_USERSPACE(void)vm_munmap (user_addr,PAGE_SIZE ); } +void lkdtm_ACCESS_NULL (void ) +{ +unsigned long tmp; +unsigned long *ptr = (unsigned long *)NULL ; + +pr_info ("attempting bad read at %px\n" , ptr); + tmp = *ptr; + tmp +=0xc0dec0de ; + +pr_info ("attempting bad write at %px\n" , ptr); + *ptr = tmp; +} +void __init lkdtm_perms_init (void ) {/* Make sure we can write to __ro_after_init values during __init */
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 18/21 ARM: 8839/1: kprobe: make patch_lock a raw_spinlock_t
In reply to Sasha LevinFrom: Yang Shi <[email protected]>
[ Upstream commit 143c2a89e0e5fda6c6fd08d7bc1126438c19ae90 ]
When running kprobe on -rt kernel, the below bug is caught:
|BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:931 |in_atomic(): 1, irqs_disabled(): 128, pid: 14, name: migration/0 |Preemption disabled at:[<802f2b98>] cpu_stopper_thread+0xc0/0x140 |CPU: 0 PID: 14 Comm: migration/0 Tainted: G O 4.8.3-rt2 #1 |Hardware name: Freescale LS1021A |[<8025a43c>] (___might_sleep) |[<80b5b324>] (rt_spin_lock) |[<80b5c31c>] (__patch_text_real) |[<80b5c3ac>] (patch_text_stop_machine) |[<802f2920>] (multi_cpu_stop)
Since patch_text_stop_machine() is called in stop_machine() which disables IRQ, sleepable lock should be not used in this atomic context,
so replace patch_lock to raw lock.
--- arch/arm/kernel/patch.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/arm/kernel/patch.c +3 -3
@@ -15,7 +15,7 @@ struct patch {unsigned int insn; }; -static DEFINE_SPINLOCK (patch_lock); +static DEFINE_RAW_SPINLOCK (patch_lock);static void __kprobes *patch_map (void *addr,int fixmap,unsigned long *flags) __acquires(&patch_lock)
@@ -32,7 +32,7 @@ static void __kprobes *patch_map(void *addr, int fixmap, unsigned long *flags)return addr;if (flags) -spin_lock_irqsave (&patch_lock, *flags); +raw_spin_lock_irqsave (&patch_lock, *flags);else __acquire (&patch_lock);
@@ -47,7 +47,7 @@ static void __kprobes patch_unmap(int fixmap, unsigned long *flags)clear_fixmap (fixmap);if (flags) -spin_unlock_irqrestore (&patch_lock, *flags); +raw_spin_unlock_irqrestore (&patch_lock, *flags);else __release (&patch_lock); }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 19/21 appletalk: Fix use-after-free in atalk_proc_exit
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit 6377f787aeb945cae7abbb6474798de129e1f3ac ]
KASAN report this:
BUG: KASAN: use-after-free in pde_subdir_find+0x12d/0x150 fs/proc/generic.c:71
Read of size 8 at addr ffff8881f41fe5b0 by task syz-executor.0/2806
CPU: 0 PID: 2806 Comm: syz-executor.0 Not tainted 5.0.0-rc7+ #45
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1ubuntu1 04/01/2014
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0xfa/0x1ce lib/dump_stack.c:113
print_address_description+0x65/0x270 mm/kasan/report.c:187
kasan_report+0x149/0x18d mm/kasan/report.c:317
pde_subdir_find+0x12d/0x150 fs/proc/generic.c:71
remove_proc_entry+0xe8/0x420 fs/proc/generic.c:667
atalk_proc_exit+0x18/0x820 [appletalk]
atalk_exit+0xf/0x5a [appletalk]
__do_sys_delete_module kernel/module.c:1018 [inline]
__se_sys_delete_module kernel/module.c:961 [inline]
__x64_sys_delete_module+0x3dc/0x5e0 kernel/module.c:961
do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x462e99
Code: f7 d8 64 89 02 b8 ff ff ff ff c3 66 0f 1f 44 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 c7 c1 bc ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007fb2de6b9c58 EFLAGS: 00000246 ORIG_RAX: 00000000000000b0
RAX: ffffffffffffffda RBX: 000000000073bf00 RCX: 0000000000462e99
RDX: 0000000000000000 RSI: 0000000000000000 RDI: 00000000200001c0
RBP: 0000000000000002 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000246 R12: 00007fb2de6ba6bc
R13: 00000000004bccaa R14: 00000000006f6bc8 R15: 00000000ffffffff
Allocated by task 2806:
set_track mm/kasan/common.c:85 [inline]
__kasan_kmalloc.constprop.3+0xa0/0xd0 mm/kasan/common.c:496
slab_post_alloc_hook mm/slab.h:444 [inline]
slab_alloc_node mm/slub.c:2739 [inline]
slab_alloc mm/slub.c:2747 [inline]
kmem_cache_alloc+0xcf/0x250 mm/slub.c:2752
kmem_cache_zalloc include/linux/slab.h:730 [inline]
__proc_create+0x30f/0xa20 fs/proc/generic.c:408
proc_mkdir_data+0x47/0x190 fs/proc/generic.c:469
0xffffffffc10c01bb
0xffffffffc10c0166
do_one_initcall+0xfa/0x5ca init/main.c:887
do_init_module+0x204/0x5f6 kernel/module.c:3460
load_module+0x66b2/0x8570 kernel/module.c:3808
__do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902
do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
Freed by task 2806:
set_track mm/kasan/common.c:85 [inline]
__kasan_slab_free+0x130/0x180 mm/kasan/common.c:458
slab_free_hook mm/slub.c:1409 [inline]
slab_free_freelist_hook mm/slub.c:1436 [inline]
slab_free mm/slub.c:2986 [inline]
kmem_cache_free+0xa6/0x2a0 mm/slub.c:3002
pde_put+0x6e/0x80 fs/proc/generic.c:647
remove_proc_entry+0x1d3/0x420 fs/proc/generic.c:684
0xffffffffc10c031c
0xffffffffc10c0166
do_one_initcall+0xfa/0x5ca init/main.c:887
do_init_module+0x204/0x5f6 kernel/module.c:3460
load_module+0x66b2/0x8570 kernel/module.c:3808
__do_sys_finit_module+0x238/0x2a0 kernel/module.c:3902
do_syscall_64+0x147/0x600 arch/x86/entry/common.c:290
entry_SYSCALL_64_after_hwframe+0x49/0xbe
The buggy address belongs to the object at ffff8881f41fe500
which belongs to the cache proc_dir_entry of size 256
The buggy address is located 176 bytes inside of
256-byte region [ffff8881f41fe500, ffff8881f41fe600)
The buggy address belongs to the page:
page:ffffea0007d07f80 count:1 mapcount:0 mapping:ffff8881f6e69a00 index:0x0
flags: 0x2fffc0000000200(slab)
raw: 02fffc0000000200 dead000000000100 dead000000000200 ffff8881f6e69a00
raw: 0000000000000000 00000000800c000c 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
Memory state around the buggy address:
ffff8881f41fe480: fb fb fb fb fb fb fb fb fc fc fc fc fc fc fc fc
ffff8881f41fe500: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
>ffff8881f41fe580: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
^
ffff8881f41fe600: fc fc fc fc fc fc fc fc fb fb fb fb fb fb fb fb
ffff8881f41fe680: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fbIt should check the return value of atalk_proc_init fails, otherwise atalk_exit will trgger use-after-free in pde_subdir_find while unload the module.This patch fix error cleanup path of atalk_init
--- include/linux/atalk.h | 2 +- net/appletalk/atalk_proc.c | 2 +- net/appletalk/ddp.c | 37 ++++++++++++++++++++++++++------ net/appletalk/sysctl_net_atalk.c | 5 ++++- 4 files changed, 37 insertions(+), 9 deletions(-)
include/linux/atalk.h +1 -1
@@ -150,7 +150,7 @@ extern int sysctl_aarp_retransmit_limit;extern int sysctl_aarp_resolve_time;#ifdef CONFIG_SYSCTL -extern void atalk_register_sysctl (void ); +extern int atalk_register_sysctl (void );extern void atalk_unregister_sysctl (void );#else #define atalk_register_sysctl () do { } while(0)
net/appletalk/atalk_proc.c +1 -1
@@ -293,7 +293,7 @@ int __init atalk_proc_init(void) goto out; } -void __exit atalk_proc_exit(void) +void atalk_proc_exit (void ) {remove_proc_entry ("interface" , atalk_proc_dir);remove_proc_entry ("route" , atalk_proc_dir);
net/appletalk/ddp.c +31 -6
@@ -1912,12 +1912,16 @@ static const char atalk_err_snap[] __initconst =/* Called by proto.c on kernel start up */ static int __init atalk_init (void ) { -int rc =proto_register (&ddp_proto,0 ); +int rc; -if (rc !=0 ) + rc =proto_register (&ddp_proto,0 ); +if (rc) goto out; - (void )sock_register (&atalk_family_ops); + rc =sock_register (&atalk_family_ops); +if (rc) + goto out_proto; + ddp_dl =register_snap_client (ddp_snap_id, atalk_rcv);if (!ddp_dl)printk (atalk_err_snap);
@@ -1925,12 +1929,33 @@ static int __init atalk_init(void)dev_add_pack (<alk_packet_type);dev_add_pack (&ppptalk_packet_type); -register_netdevice_notifier (&ddp_notifier); + rc =register_netdevice_notifier (&ddp_notifier); +if (rc) + goto out_sock; +aarp_proto_init (); -atalk_proc_init (); -atalk_register_sysctl (); + rc =atalk_proc_init (); +if (rc) + goto out_aarp; + + rc =atalk_register_sysctl (); +if (rc) + goto out_proc; out:return rc; +out_proc: +atalk_proc_exit (); +out_aarp: +aarp_cleanup_module (); +unregister_netdevice_notifier (&ddp_notifier); +out_sock: +dev_remove_pack (&ppptalk_packet_type); +dev_remove_pack (<alk_packet_type); +unregister_snap_client (ddp_dl); +sock_unregister (PF_APPLETALK ); +out_proto: +proto_unregister (&ddp_proto); + goto out; }module_init (atalk_init);
net/appletalk/sysctl_net_atalk.c +4 -1
@@ -44,9 +44,12 @@ static struct ctl_table atalk_table[] = {static struct ctl_table_header *atalk_table_header; -void atalk_register_sysctl (void ) +int __init atalk_register_sysctl (void ) { atalk_table_header =register_net_sysctl (&init_net,"net/appletalk" , atalk_table); +if (!atalk_table_header) +return -ENOMEM ; +return 0 ; }void atalk_unregister_sysctl (void )
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 20/21 lib/div64.c: off by one in shift
In reply to Sasha LevinFrom: Stanislaw Gruszka <[email protected]>
[ Upstream commit cdc94a37493135e355dfc0b0e086d84e3eadb50d ]
fls counts bits starting from 1 to 32 (returns 0 for zero argument). If we add 1 we shift right one bit more and loose precision from divisor, what cause function incorect results with some numbers.
Corrected code was tested in user-space, see bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=202391
--- lib/div64.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/div64.c +2 -2
@@ -102,7 +102,7 @@ u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder) quot =div_u64_rem (dividend, divisor, &rem32); *remainder = rem32; }else { -int n =1 +fls (high); +int n =fls (high); quot =div_u64 (dividend >> n, divisor >> n);if (quot !=0 )
@@ -140,7 +140,7 @@ u64 div64_u64(u64 dividend, u64 divisor)if (high ==0 ) { quot =div_u64 (dividend, divisor); }else { -int n =1 +fls (high); +int n =fls (high); quot =div_u64 (dividend >> n, divisor >> n);if (quot !=0 )
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 21/21 include/linux/swap.h: use offsetof() instead of custom __swapoffset macro
In reply to Sasha LevinFrom: Pi-Hsun Shih <[email protected]>
[ Upstream commit a4046c06be50a4f01d435aa7fe57514818e6cc82 ]
Use offsetof() to calculate offset of a field to take advantage of compiler built-in version when possible, and avoid UBSAN warning when compiling with Clang:
UBSAN: Undefined behaviour in mm/swapfile.c:3010:38 member access within null pointer of type 'union swap_header' CPU: 6 PID: 1833 Comm: swapon Tainted: G S 4.19.23 #43 Call trace: dump_backtrace+0x0/0x194 show_stack+0x20/0x2c __dump_stack+0x20/0x28 dump_stack+0x70/0x94 ubsan_epilogue+0x14/0x44 ubsan_type_mismatch_common+0xf4/0xfc __ubsan_handle_type_mismatch_v1+0x34/0x54 __se_sys_swapon+0x654/0x1084 __arm64_sys_swapon+0x1c/0x24 el0_svc_common+0xa8/0x150 el0_svc_compat_handler+0x2c/0x38 el0_svc_compat+0x8/0x18
--- include/linux/swap.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/swap.h +2 -2
@@ -135,9 +135,9 @@ struct swap_extent {/* * Max bad pages in the new format.. */ -#define __swapoffset (x) ((unsigned long)&((union swap_header *)0)->x)#define MAX_SWAP_BADPAGES \ - ((__swapoffset(magic.magic) - __swapoffset(info.badpages)) / sizeof(int)) + ((offsetof(union swap_header, magic.magic) - \ + offsetof(union swap_header, info.badpages)) / sizeof(int))enum {SWP_USED = (1 <<0 ),/* is slot in swap_info[] used? */
Signature · 1 line
2.19.1