ARC: u-boot args: check that magic number is correct
Subsystems (15)
Sasha Levin
maintainerPATCH 1/67 ARC: u-boot args: check that magic number is correct
From: Eugeniy Paltsev <[email protected]>
[ Upstream commit edb64bca50cd736c6894cc6081d5263c007ce005 ]
In case of devboards we really often disable bootloader and load Linux image in memory via JTAG. Even if kernel tries to verify uboot_tag and uboot_arg there is sill a chance that we treat some garbage in registers as valid u-boot arguments in JTAG case. E.g. it is enough to have '1' in r0 to treat any value in r2 as a boot command line.
So check that magic number passed from u-boot is correct and drop u-boot arguments otherwise. That helps to reduce the possibility of using garbage as u-boot arguments in JTAG case.
We can safely check U-boot magic value (0x0) in linux passed via r1 register as U-boot pass it from the beginning. So there is no backward-compatibility issues.
--- arch/arc/kernel/head.S | 1 + arch/arc/kernel/setup.c | 8 ++++++++ 2 files changed, 9 insertions(+)
arch/arc/kernel/head.S +1 -0
@@ -106,6 +106,7 @@ ENTRY(stext) ; r2 = pointer to uboot provided cmdline or external DTB in mem ; These are handled later in handle_uboot_args() st r0, [@uboot_tag] + st r1, [@uboot_magic] st r2, [@uboot_arg] ; setup "current" tsk and optionally cache it in dedicated r25
arch/arc/kernel/setup.c +8 -0
@@ -36,6 +36,7 @@ unsigned int intr_to_DE_cnt;/* Part of U-boot ABI: see head.S */ int __initdata uboot_tag; +int __initdata uboot_magic;char __initdata *uboot_arg;const struct machine_desc *machine_desc;
@@ -497,6 +498,8 @@ static inline bool uboot_arg_invalid(unsigned long addr)#define UBOOT_TAG_NONE 0#define UBOOT_TAG_CMDLINE 1#define UBOOT_TAG_DTB 2 +/* We always pass 0 as magic from U-boot */ +#define UBOOT_MAGIC_VALUE 0void __init handle_uboot_args (void ) {
@@ -511,6 +514,11 @@ void __init handle_uboot_args(void) goto ignore_uboot_args; } +if (uboot_magic !=UBOOT_MAGIC_VALUE ) { +pr_warn (IGNORE_ARGS "non zero uboot magic\n" ); + goto ignore_uboot_args; + } +if (uboot_tag !=UBOOT_TAG_NONE &&uboot_arg_invalid ((unsigned long )uboot_arg)) {pr_warn (IGNORE_ARGS "invalid uboot arg: '%px'\n" , uboot_arg);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 2/67 arc: hsdk_defconfig: Enable CONFIG_BLK_DEV_RAM
From: Corentin Labbe <[email protected]>
[ Upstream commit 0728aeb7ead99a9b0dac2f3c92b3752b4e02ff97 ]
We have now a HSDK device in our kernelci lab, but kernel builded via the hsdk_defconfig lacks ramfs supports, so it cannot boot kernelci jobs yet.
So this patch enable CONFIG_BLK_DEV_RAM in hsdk_defconfig.
--- arch/arc/configs/hsdk_defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arc/configs/hsdk_defconfig +1 -0
@@ -8,6 +8,7 @@ CONFIG_NAMESPACES=y # CONFIG_UTS_NS is not set # CONFIG_PID_NS is not set CONFIG_BLK_DEV_INITRD=y +CONFIG_BLK_DEV_RAM=y CONFIG_EMBEDDED=y CONFIG_PERF_EVENTS=y # CONFIG_VM_EVENT_COUNTERS is not set
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 3/67 inotify: Fix fsnotify_mark refcount leak in inotify_update_existing_watch()
In reply to Sasha LevinFrom: ZhangXiaoxu <[email protected]>
[ Upstream commit 62c9d2674b31d4c8a674bee86b7edc6da2803aea ]
Commit 4d97f7d53da7dc83 ("inotify: Add flag IN_MASK_CREATE for inotify_add_watch()") forgot to call fsnotify_put_mark() with IN_MASK_CREATE after fsnotify_find_mark()
--- fs/notify/inotify/inotify_user.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
fs/notify/inotify/inotify_user.c +5 -2
@@ -519,8 +519,10 @@ static int inotify_update_existing_watch(struct fsnotify_group *group, fsn_mark =fsnotify_find_mark (&inode->i_fsnotify_marks, group);if (!fsn_mark)return -ENOENT ; -else if (create) -return -EEXIST ; +else if (create) { + ret = -EEXIST ; + goto out; + } i_mark = container_of(fsn_mark, struct inotify_inode_mark, fsn_mark);
@@ -548,6 +550,7 @@ static int inotify_update_existing_watch(struct fsnotify_group *group,/* return the wd */ ret = i_mark->wd; +out:/* match the get from fsnotify_find_mark() */ fsnotify_put_mark (fsn_mark);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 4/67 perf/core: Restore mmap record type correctly
In reply to Sasha LevinFrom: Stephane Eranian <[email protected]>
[ Upstream commit d9c1bb2f6a2157b38e8eb63af437cb22701d31ee ]
On mmap(), perf_events generates a RECORD_MMAP record and then checks which events are interested in this record. There are currently 2 versions of mmap records: RECORD_MMAP and RECORD_MMAP2. MMAP2 is larger. The event configuration controls which version the user level tool accepts.
If the event->attr.mmap2=1 field then MMAP2 record is returned. The perf_event_mmap_output() takes care of this. It checks attr->mmap2 and corrects the record fields before putting it in the sampling buffer of the event. At the end the function restores the modified MMAP record fields.
The problem is that the function restores the size but not the type. Thus, if a subsequent event only accepts MMAP type, then it would instead receive an MMAP2 record with a size of MMAP record.
This patch fixes the problem by restoring the record type on exit.
--- kernel/events/core.c | 2 ++ 1 file changed, 2 insertions(+)
kernel/events/core.c +2 -0
@@ -7178,6 +7178,7 @@ static void perf_event_mmap_output(struct perf_event *event,struct perf_output_handle handle;struct perf_sample_data sample;int size = mmap_event->event_id.header.size; +u32 type = mmap_event->event_id.header.type;int ret;if (!perf_event_mmap_match (event, data))
@@ -7221,6 +7222,7 @@ static void perf_event_mmap_output(struct perf_event *event,perf_output_end (&handle); out: mmap_event->event_id.header.size = size; + mmap_event->event_id.header.type = type; }static void perf_event_mmap_event (struct perf_mmap_event *mmap_event)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 5/67 perf data: Don't store auxtrace index for directory data file
In reply to Sasha LevinFrom: Jiri Olsa <[email protected]>
[ Upstream commit cd3dd8dd8ff62374d90cb3f2e54b8c94106c7810 ]
We can't store the auxtrace index when we store into multiple files, because we keep only offset for it, not the file.
The auxtrace data will be processed correctly in the 'pipe' mode.
--- tools/perf/builtin-record.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/builtin-record.c +1 -1
@@ -386,7 +386,7 @@ static int record__process_auxtrace(struct perf_tool *tool,size_t padding;u8 pad[8 ] = {0 }; -if (!perf_data__is_pipe (data)) { +if (!perf_data__is_pipe (data) && !perf_data__is_dir (data)) {off_t file_offset;int fd =perf_data__fd (data);int err;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 6/67 mips: bcm47xx: Enable USB power on Netgear WNDR3400v2
In reply to Sasha LevinFrom: Petr Štetiar <[email protected]>
[ Upstream commit cdb8faa00e3fcdd0ad10add743516d616dc7d38e ]
Eric has reported on OpenWrt's bug tracking system[1], that he's not able to use USB devices on his WNDR3400v2 device after the boot, until he turns on GPIO #21 manually through sysfs.
1. https://bugs.openwrt.org/index.php?do=details&task_id=2170
--- arch/mips/bcm47xx/workarounds.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/bcm47xx/workarounds.c +1 -0
@@ -24,6 +24,7 @@ void __init bcm47xx_workarounds(void)case BCM47XX_BOARD_NETGEAR_WNR3500L :bcm47xx_workarounds_enable_usb_power (12 );break ; +case BCM47XX_BOARD_NETGEAR_WNDR3400V2 :case BCM47XX_BOARD_NETGEAR_WNDR3400_V3 :bcm47xx_workarounds_enable_usb_power (21 );break ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 7/67 ext4: avoid panic during forced reboot
In reply to Sasha LevinFrom: Jan Kara <[email protected]>
[ Upstream commit 1dc1097ff60e4105216da7cd0aa99032b039a994 ]
When admin calls "reboot -f" - i.e., does a hard system reboot by directly calling reboot(2) - ext4 filesystem mounted with errors=panic can panic the system. This happens because the underlying device gets disabled without unmounting the filesystem and thus some syscall running in parallel to reboot(2) can result in the filesystem getting IO errors.
This is somewhat surprising to the users so try improve the behavior by switching to errors=remount-ro behavior when the system is running reboot(2).
--- fs/ext4/super.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
fs/ext4/super.c +13 -3
@@ -430,6 +430,12 @@ static void ext4_journal_commit_callback(journal_t *journal, transaction_t *txn)spin_unlock (&sbi->s_md_lock); } +static bool system_going_down (void ) +{ +return system_state ==SYSTEM_HALT || system_state ==SYSTEM_POWER_OFF + || system_state ==SYSTEM_RESTART ; +} +/* Deal with the reporting of failure conditions on a filesystem such as * inconsistencies detected or read IO failures. *
@@ -460,7 +466,12 @@ static void ext4_handle_error(struct super_block *sb)if (journal)jbd2_journal_abort (journal, -EIO ); } -if (test_opt (sb,ERRORS_RO )) { +/* +* We force ERRORS_RO behavior when system is rebooting. Otherwise we +* could panic during 'reboot -f' as the underlying device got already +* disabled. +*/ +if (test_opt (sb,ERRORS_RO ) ||system_going_down ()) {ext4_msg (sb,KERN_CRIT ,"Remounting filesystem read-only" );/* * Make sure updated value of ->s_mount_flags will be visible
@@ -468,8 +479,7 @@ static void ext4_handle_error(struct super_block *sb)*/ smp_wmb (); sb->s_flags |=SB_RDONLY ; - } -if (test_opt (sb,ERRORS_PANIC )) { + }else if (test_opt (sb,ERRORS_PANIC )) {if (EXT4_SB (sb)->s_journal && !(EXT4_SB (sb)->s_journal->j_flags &JBD2_REC_ERR ))return ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 8/67 ext4: add missing brelse() in add_new_gdb_meta_bg()
In reply to Sasha LevinFrom: Lukas Czerner <[email protected]>
[ Upstream commit d64264d6218e6892edd832dc3a5a5857c2856c53 ]
Currently in add_new_gdb_meta_bg() there is a missing brelse of gdb_bh in case ext4_journal_get_write_access() fails.
Additionally kvfree() is missing in the same error path. Fix it by moving the ext4_journal_get_write_access() before the ext4 sb update as Ted suggested and release n_group_desc and gdb_bh in case it fails.
--- fs/ext4/resize.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fs/ext4/resize.c +9 -2
@@ -932,11 +932,18 @@ static int add_new_gdb_meta_bg(struct super_block *sb,memcpy (n_group_desc, o_group_desc,EXT4_SB (sb)->s_gdb_count *sizeof (struct buffer_head *)); n_group_desc[gdb_num] = gdb_bh; + +BUFFER_TRACE (gdb_bh,"get_write_access" ); + err =ext4_journal_get_write_access (handle, gdb_bh); +if (err) { +kvfree (n_group_desc); +brelse (gdb_bh); +return err; + } +EXT4_SB (sb)->s_group_desc = n_group_desc;EXT4_SB (sb)->s_gdb_count++;kvfree (o_group_desc); -BUFFER_TRACE (gdb_bh,"get_write_access" ); - err =ext4_journal_get_write_access (handle, gdb_bh);return err; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 9/67 ext4: report real fs size after failed resize
In reply to Sasha LevinFrom: Lukas Czerner <[email protected]>
[ Upstream commit 6c7328400e0488f7d49e19e02290ba343b6811b2 ]
Currently when the file system resize using ext4_resize_fs() fails it will report into log that "resized filesystem to <requested block count>". However this may not be true in the case of failure. Use the current block count as returned by ext4_blocks_count() to report the block count.
Additionally, report a warning that "error occurred during file system resize"
--- fs/ext4/resize.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
fs/ext4/resize.c +5 -1
@@ -2080,6 +2080,10 @@ out:free_flex_gd (flex_gd);if (resize_inode !=NULL )iput (resize_inode); -ext4_msg (sb,KERN_INFO ,"resized filesystem to %llu" , n_blocks_count); +if (err) +ext4_warning (sb,"error (%d) occurred during " +"file system resize" , err); +ext4_msg (sb,KERN_INFO ,"resized filesystem to %llu" , +ext4_blocks_count (es));return err; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 10/67 ALSA: echoaudio: add a check for ioremap_nocache
In reply to Sasha LevinFrom: Kangjie Lu <[email protected]>
[ Upstream commit 6ade657d6125ec3ec07f95fa51e28138aef6208f ]
In case ioremap_nocache fails, the fix releases chip and returns an error code upstream to avoid NULL pointer dereference.
--- sound/pci/echoaudio/echoaudio.c | 5 +++++ 1 file changed, 5 insertions(+)
sound/pci/echoaudio/echoaudio.c +5 -0
@@ -1954,6 +1954,11 @@ static int snd_echo_create(struct snd_card *card, } chip->dsp_registers = (volatile u32 __iomem *)ioremap_nocache (chip->dsp_registers_phys, sz); +if (!chip->dsp_registers) { +dev_err (chip->card->dev,"ioremap failed\n" ); +snd_echo_free (chip); +return -ENOMEM ; + }if (request_irq (pci->irq, snd_echo_interrupt,IRQF_SHARED ,KBUILD_MODNAME , chip)) {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 11/67 ALSA: sb8: add a check for request_region
In reply to Sasha LevinFrom: Kangjie Lu <[email protected]>
[ Upstream commit dcd0feac9bab901d5739de51b3f69840851f8919 ]
In case request_region fails, the fix returns an error code to avoid NULL pointer dereference.
--- sound/isa/sb/sb8.c | 4 ++++ 1 file changed, 4 insertions(+)
sound/isa/sb/sb8.c +4 -0
@@ -111,6 +111,10 @@ static int snd_sb8_probe(struct device *pdev, unsigned int dev)/* block the 0x388 port to avoid PnP conflicts */ acard->fm_res =request_region (0x388 ,4 ,"SoundBlaster FM" ); +if (!acard->fm_res) { + err = -EBUSY ; + goto _err; + } if (port[dev] != SNDRV_AUTO_PORT) { if ((err = snd_sbdsp_create(card, port[dev], irq[dev],
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 12/67 auxdisplay: hd44780: Fix memory leak on ->remove()
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 41c8d0adf3c4df1867d98cee4a2c4531352a33ad ]
We have to free on ->remove() the allocated resources on ->probe().
--- drivers/auxdisplay/hd44780.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/auxdisplay/hd44780.c +2 -0
@@ -280,6 +280,8 @@ static int hd44780_remove(struct platform_device *pdev)struct charlcd *lcd =platform_get_drvdata (pdev);charlcd_unregister (lcd); + +kfree (lcd);return 0 ; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 13/67 drm/udl: use drm_gem_object_put_unlocked.
In reply to Sasha LevinFrom: Dave Airlie <[email protected]>
[ Upstream commit 8f3b487685b2acf71b42bb30d68fd9271bec8695 ]
When Daniel removed struct_mutex he didn't fix this call to the unlocked variant which is required since we no longer use struct mutex.
This fixes a bunch of:
WARNING: CPU: 4 PID: 1370 at drivers/gpu/drm/drm_gem.c:931 drm_gem_object_put+0x2b/0x30 [drm] Modules linked in: udl xt_CHECKSUM ipt_MASQUERADE tun bridge stp llc nf_conntrack_netbios_ns nf_conntrack_broadcast xt_CT ip6t> CPU: 4 PID: 1370 Comm: Xorg Not tainted 5.0.0+ #2
backtraces when you plug in a udl device.
--- drivers/gpu/drm/udl/udl_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/udl/udl_gem.c +1 -1
@@ -224,7 +224,7 @@ int udl_gem_mmap(struct drm_file *file, struct drm_device *dev, *offset =drm_vma_node_offset_addr (&gobj->base.vma_node); out: -drm_gem_object_put (&gobj->base); +drm_gem_object_put_unlocked (&gobj->base); unlock:mutex_unlock (&udl->gem_lock);return ret;
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 14/67 IB/mlx4: Fix race condition between catas error reset and aliasguid flows
In reply to Sasha LevinFrom: Jack Morgenstein <[email protected]>
[ Upstream commit 587443e7773e150ae29e643ee8f41a1eed226565 ]
Code review revealed a race condition which could allow the catas error flow to interrupt the alias guid query post mechanism at random points. Thiis is fixed by doing cancel_delayed_work_sync() instead of cancel_delayed_work() during the alias guid mechanism destroy flow.
--- drivers/infiniband/hw/mlx4/alias_GUID.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/hw/mlx4/alias_GUID.c +1 -1
@@ -804,8 +804,8 @@ void mlx4_ib_destroy_alias_guid_service(struct mlx4_ib_dev *dev)unsigned long flags;for (i =0 ; i < dev->num_ports; i++) { -cancel_delayed_work (&dev->sriov.alias_guid.ports_guid[i].alias_guid_work); det = &sriov->alias_guid.ports_guid[i]; +cancel_delayed_work_sync (&det->alias_guid_work);spin_lock_irqsave (&sriov->alias_guid.ag_work_lock, flags);while (!list_empty (&det->cb_list)) { cb_ctx = list_entry(det->cb_list.next,
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 15/67 i40iw: Avoid panic when handling the inetdev event
In reply to Sasha LevinFrom: Feng Tang <[email protected]>
[ Upstream commit ec4fe4bcc584b55e24e8d1768f5510a62c0fd619 ]
There is a panic reported that on a system with x722 ethernet, when doing the operations like:
# ip link add br0 type bridge # ip link set eno1 master br0 # systemctl restart systemd-networkd
The system will panic "BUG: unable to handle kernel null pointer dereference at 0000000000000034", with call chain:
i40iw_inetaddr_event notifier_call_chain blocking_notifier_call_chain notifier_call_chain __inet_del_ifa inet_rtm_deladdr rtnetlink_rcv_msg netlink_rcv_skb rtnetlink_rcv netlink_unicast netlink_sendmsg sock_sendmsg __sys_sendto
It is caused by "local_ipaddr = ntohl(in->ifa_list->ifa_address)", while the in->ifa_list is NULL.
So add a check for the "in->ifa_list == NULL" case, and skip the ARP operation accordingly.
--- drivers/infiniband/hw/i40iw/i40iw_utils.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
drivers/infiniband/hw/i40iw/i40iw_utils.c +11 -1
@@ -173,7 +173,12 @@ int i40iw_inetaddr_event(struct notifier_block *notifier,rcu_read_lock (); in =__in_dev_get_rcu (upper_dev); - local_ipaddr =ntohl (in->ifa_list->ifa_address); + +if (!in->ifa_list) + local_ipaddr =0 ; +else + local_ipaddr =ntohl (in->ifa_list->ifa_address); +rcu_read_unlock (); }else { local_ipaddr =ntohl (ifa->ifa_address);
@@ -185,6 +190,11 @@ int i40iw_inetaddr_event(struct notifier_block *notifier,case NETDEV_UP :/* Fall through */ case NETDEV_CHANGEADDR : + +/* Just skip if no need to handle ARP cache */ +if (!local_ipaddr) +break ; + i40iw_manage_arp_cache(iwdev, netdev->dev_addr, &local_ipaddr,
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 16/67 mmc: davinci: remove extraneous __init annotation
In reply to Sasha LevinFrom: Arnd Bergmann <[email protected]>
[ Upstream commit 9ce58dd7d9da3ca0d7cb8c9568f1c6f4746da65a ]
Building with clang finds a mistaken __init tag:
WARNING: vmlinux.o(.text+0x5e4250): Section mismatch in reference from the function davinci_mmcsd_probe() to the function .init.text:init_mmcsd_host() The function davinci_mmcsd_probe() references
the function __init init_mmcsd_host().
This is often because davinci_mmcsd_probe lacks a __init
annotation or the annotation of init_mmcsd_host is wrong.
--- drivers/mmc/host/davinci_mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mmc/host/davinci_mmc.c +1 -1
@@ -1117,7 +1117,7 @@ static inline void mmc_davinci_cpufreq_deregister(struct mmc_davinci_host *host) { }#endif -static void __init init_mmcsd_host (struct mmc_davinci_host *host) +static void init_mmcsd_host (struct mmc_davinci_host *host) {mmc_davinci_reset_ctrl (host,1 );
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 17/67 ALSA: opl3: fix mismatch between snd_opl3_drum_switch definition and declaration
In reply to Sasha LevinFrom: Colin Ian King <[email protected]>
[ Upstream commit b4748e7ab731e436cf5db4786358ada5dd2db6dd ]
The function snd_opl3_drum_switch declaration in the header file has the order of the two arguments on_off and vel swapped when compared to the definition arguments of vel and on_off. Fix this by swapping them around to match the definition.
This error predates the git history, so no idea when this error was introduced.
--- sound/drivers/opl3/opl3_voice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
sound/drivers/opl3/opl3_voice.h +1 -1
@@ -41,7 +41,7 @@ void snd_opl3_timer_func(struct timer_list *t);/* Prototypes for opl3_drums.c */ void snd_opl3_load_drums (struct snd_opl3 *opl3); -void snd_opl3_drum_switch (struct snd_opl3 *opl3,int note,int on_off,int vel,struct snd_midi_channel *chan); +void snd_opl3_drum_switch (struct snd_opl3 *opl3,int note,int vel,int on_off,struct snd_midi_channel *chan);/* Prototypes for opl3_oss.c */ #if IS_ENABLED (CONFIG_SND_SEQUENCER_OSS )
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 18/67 paride/pf: cleanup queues when detection fails
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit 6ce59025f1182125e75c8d121daf44056b65dd1f ]
The driver allocates queues for all the units it potentially supports. But if we fail to detect any drives, then we fail loading the module without cleaning up those queues. This is now evident with the switch to blk-mq, though the bug has been there forever as far as I can tell.
Also fix cleanup through regular module exit.
--- drivers/block/paride/pf.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
drivers/block/paride/pf.c +11 -5
@@ -761,8 +761,12 @@ static int pf_detect(void)return 0 ;printk ("%s: No ATAPI disk detected\n" , name); -for (pf = units, unit =0 ; unit <PF_UNITS ; pf++, unit++) +for (pf = units, unit =0 ; unit <PF_UNITS ; pf++, unit++) { +blk_cleanup_queue (pf->disk->queue); + pf->disk->queue =NULL ; +blk_mq_free_tag_set (&pf->tag_set);put_disk (pf->disk); + }pi_unregister_driver (par_drv);return -1 ; }
@@ -1047,13 +1051,15 @@ static void __exit pf_exit(void)int unit;unregister_blkdev (major, name);for (pf = units, unit =0 ; unit <PF_UNITS ; pf++, unit++) { -if (!pf->present) -continue ; -del_gendisk (pf->disk); +if (pf->present) +del_gendisk (pf->disk); +blk_cleanup_queue (pf->disk->queue);blk_mq_free_tag_set (&pf->tag_set);put_disk (pf->disk); -pi_release (pf->pi); + +if (pf->present) +pi_release (pf->pi); } }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 19/67 paride/pcd: cleanup queues when detection fails
In reply to Sasha LevinFrom: Jens Axboe <[email protected]>
[ Upstream commit 81b74ac68c28fddb3589ad5d4d5e587baf4bb781 ]
The driver allocates queues for all the units it potentially supports. But if we fail to detect any drives, then we fail loading the module without cleaning up those queues. This is now evident with the switch to blk-mq, though the bug has been there forever as far as I can tell.
Also fix cleanup through regular module exit.
--- drivers/block/paride/pcd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/block/paride/pcd.c +5 -1
@@ -749,8 +749,12 @@ static int pcd_detect(void)return 0 ;printk ("%s: No CD-ROM drive found\n" , name); -for (unit =0 , cd = pcd; unit <PCD_UNITS ; unit++, cd++) +for (unit =0 , cd = pcd; unit <PCD_UNITS ; unit++, cd++) { +blk_cleanup_queue (cd->disk->queue); + cd->disk->queue =NULL ; +blk_mq_free_tag_set (&cd->tag_set);put_disk (cd->disk); + }pi_unregister_driver (par_drv);return -1 ; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 20/67 thermal/intel_powerclamp: fix __percpu declaration of worker_data
In reply to Sasha LevinFrom: Luc Van Oostenryck <[email protected]>
[ Upstream commit aa36e3616532f82a920b5ebf4e059fbafae63d88 ]
This variable is declared as:
static struct powerclamp_worker_data * __percpu worker_data;
In other words, a percpu pointer to struct ...
But this variable not used like so but as a pointer to a percpu struct powerclamp_worker_data.
So fix the declaration as:
static struct powerclamp_worker_data __percpu *worker_data;
This also quiets Sparse's warnings from __verify_pcpu_ptr(), like:
494:49: warning: incorrect type in initializer (different address spaces)
494:49: expected void const [noderef] <asn:3> *__vpp_verify
494:49: got struct powerclamp_worker_data *
--- drivers/thermal/intel/intel_powerclamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/intel_powerclamp.c +1 -1
@@ -101,7 +101,7 @@ struct powerclamp_worker_data {bool clamping; }; -static struct powerclamp_worker_data *__percpu worker_data; +static struct powerclamp_worker_data __percpu *worker_data;static struct thermal_cooling_device *cooling_dev;static unsigned long *cpu_clamping_mask;/* bit map for tracking per cpu * clamping kthread worker
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 21/67 thermal: samsung: Fix incorrect check after code merge
In reply to Sasha LevinFrom: Marek Szyprowski <[email protected]>
[ Upstream commit 3b5236cc5d086dd3ddd01113ee9255421aab9fab ]
Merge commit 19785cf93b6c ("Merge branch 'linus' ofgit://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal")
broke the code introduced by commit ffe6e16f14fa ("thermal: exynos: Reduce severity of too early temperature read"). Restore the original code from the mentioned commit to finally fix the warning message during boot:
thermal thermal_zone0: failed to read out thermal zone (-22)
--- drivers/thermal/samsung/exynos_tmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/samsung/exynos_tmu.c +1 -1
@@ -666,7 +666,7 @@ static int exynos_get_temp(void *p, int *temp)struct exynos_tmu_data *data = p;int value, ret =0 ; -if (!data || !data->tmu_read || !data->enabled) +if (!data || !data->tmu_read)return -EINVAL ;else if (!data->enabled)/*
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 22/67 thermal: bcm2835: Fix crash in bcm2835_thermal_debugfs
In reply to Sasha LevinFrom: Phil Elwell <[email protected]>
[ Upstream commit 35122495a8c6683e863acf7b05a7036b2be64c7a ]
"cat /sys/kernel/debug/bcm2835_thermal/regset" causes a NULL pointer dereference in bcm2835_thermal_debugfs. The driver makes use of the implementation details of the thermal framework to retrieve a pointer to its private data from a struct thermal_zone_device, and gets it wrong - leading to the crash. Instead, store its private data as the drvdata and retrieve the thermal_zone_device pointer from it.
--- drivers/thermal/broadcom/bcm2835_thermal.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/thermal/broadcom/bcm2835_thermal.c +4 -5
@@ -119,8 +119,7 @@ static const struct debugfs_reg32 bcm2835_thermal_regs[] = {static void bcm2835_thermal_debugfs (struct platform_device *pdev) { -struct thermal_zone_device *tz =platform_get_drvdata (pdev); -struct bcm2835_thermal_data *data = tz->devdata; +struct bcm2835_thermal_data *data =platform_get_drvdata (pdev);struct debugfs_regset32 *regset; data->debugfsdir =debugfs_create_dir ("bcm2835_thermal" ,NULL );
@@ -266,7 +265,7 @@ static int bcm2835_thermal_probe(struct platform_device *pdev) data->tz = tz; -platform_set_drvdata (pdev, tz); +platform_set_drvdata (pdev, data);/* * Thermal_zone doesn't enable hwmon as default,
@@ -290,8 +289,8 @@ err_clk:static int bcm2835_thermal_remove (struct platform_device *pdev) { -struct thermal_zone_device *tz =platform_get_drvdata (pdev); -struct bcm2835_thermal_data *data = tz->devdata; +struct bcm2835_thermal_data *data =platform_get_drvdata (pdev); +struct thermal_zone_device *tz = data->tz;debugfs_remove_recursive (data->debugfsdir);thermal_zone_of_sensor_unregister (&pdev->dev, tz);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 23/67 thermal/int340x_thermal: Add additional UUIDs
In reply to Sasha LevinFrom: Matthew Garrett <[email protected]>
[ Upstream commit 16fc8eca1975358111dbd7ce65e4ce42d1a848fb ]
Add more supported DPTF policies than the driver currently exposes.
--- .../intel/int340x_thermal/int3400_thermal.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +14 -0
@@ -22,6 +22,13 @@ enum int3400_thermal_uuid {INT3400_THERMAL_PASSIVE_1 ,INT3400_THERMAL_ACTIVE ,INT3400_THERMAL_CRITICAL , +INT3400_THERMAL_ADAPTIVE_PERFORMANCE , +INT3400_THERMAL_EMERGENCY_CALL_MODE , +INT3400_THERMAL_PASSIVE_2 , +INT3400_THERMAL_POWER_BOSS , +INT3400_THERMAL_VIRTUAL_SENSOR , +INT3400_THERMAL_COOLING_MODE , +INT3400_THERMAL_HARDWARE_DUTY_CYCLING , INT3400_THERMAL_MAXIMUM_UUID, };
@@ -29,6 +36,13 @@ static char *int3400_thermal_uuids[INT3400_THERMAL_MAXIMUM_UUID] = {"42A441D6-AE6A-462b-A84B-4A8CE79027D3" ,"3A95C389-E4B8-4629-A526-C52C88626BAE" ,"97C68AE7-15FA-499c-B8C9-5DA81D606E0A" , +"63BE270F-1C11-48FD-A6F7-3AF253FF3E2D" , +"5349962F-71E6-431D-9AE8-0A635B710AEE" , +"9E04115A-AE87-4D1C-9500-0F3E340BFE75" , +"F5A35014-C209-46A4-993A-EB56DE7530A1" , +"6ED722A7-9240-48A5-B479-31EEF723D7CF" , +"16CAF1B7-DD38-40ED-B1C1-1B8A1913D531" , + "BE84BABF-C4D4-403D-B495-3128FD44dAC1", }; struct int3400_thermal_priv {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 24/67 thermal/int340x_thermal: fix mode setting
In reply to Sasha LevinFrom: Matthew Garrett <[email protected]>
[ Upstream commit 396ee4d0cd52c13b3f6421b8d324d65da5e7e409 ]
int3400 only pushes the UUID into the firmware when the mode is flipped to "enable". The current code only exposes the mode flag if the firmware supports the PASSIVE_1 UUID, which not all machines do. Remove the restriction.
--- drivers/thermal/intel/int340x_thermal/int3400_thermal.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/thermal/intel/int340x_thermal/int3400_thermal.c +3 -4
@@ -313,10 +313,9 @@ static int int3400_thermal_probe(struct platform_device *pdev)platform_set_drvdata (pdev, priv); -if (priv->uuid_bitmap &1 <<INT3400_THERMAL_PASSIVE_1 ) { - int3400_thermal_ops.get_mode = int3400_thermal_get_mode; - int3400_thermal_ops.set_mode = int3400_thermal_set_mode; - } + int3400_thermal_ops.get_mode = int3400_thermal_get_mode; + int3400_thermal_ops.set_mode = int3400_thermal_set_mode; + priv->thermal =thermal_zone_device_register ("INT3400 Thermal" ,0 ,0 , priv, &int3400_thermal_ops, &int3400_thermal_params,0 ,0 );
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 25/67 thermal/intel_powerclamp: fix truncated kthread name
In reply to Sasha LevinFrom: Zhang Rui <[email protected]>
[ Upstream commit e925b5be5751f6a7286bbd9a4cbbc4ac90cc5fa6 ]
kthread name only allows 15 characters (TASK_COMMON_LEN is 16). Thus rename the kthreads created by intel_powerclamp driver from "kidle_inject/ + decimal cpuid" to "kidle_inj/ + decimal cpuid" to avoid truncated kthead name for cpu 100 and later.
--- drivers/thermal/intel/intel_powerclamp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/intel_powerclamp.c +1 -1
@@ -494,7 +494,7 @@ static void start_power_clamp_worker(unsigned long cpu)struct powerclamp_worker_data *w_data =per_cpu_ptr (worker_data, cpu);struct kthread_worker *worker; - worker =kthread_create_worker_on_cpu (cpu,0 ,"kidle_inject/%ld" , cpu); + worker =kthread_create_worker_on_cpu (cpu,0 ,"kidle_inj/%ld" , cpu);if (IS_ERR (worker))return ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 26/67 scsi: iscsi: flush running unbind operations when removing a session
In reply to Sasha LevinFrom: Maurizio Lombardi <[email protected]>
[ Upstream commit 165aa2bfb42904b1bec4bf2fa257c8c603c14a06 ]
In some cases, the iscsi_remove_session() function is called while an unbind_work operation is still running. This may cause a situation where sysfs objects are removed in an incorrect order, triggering a kernel warning.
[ 605.249442] ------------[ cut here ]------------ [ 605.259180] sysfs group 'power' not found for kobject 'target2:0:0' [ 605.321371] WARNING: CPU: 1 PID: 26794 at fs/sysfs/group.c:235 sysfs_remove_group+0x76/0x80 [ 605.341266] Modules linked in: dm_service_time target_core_user target_core_pscsi target_core_file target_core_iblock iscsi_target_mod target_core_mod nls_utf8 isofs ppdev bochs_drm nfit ttm libnvdimm drm_kms_helper syscopyarea sysfillrect sysimgblt joydev pcspkr fb_sys_fops drm i2c_piix4 sg parport_pc parport xfs libcrc32c dm_multipath sr_mod sd_mod cdrom ata_generic 8021q garp mrp ata_piix stp crct10dif_pclmul crc32_pclmul llc libata crc32c_intel virtio_net net_failover ghash_clmulni_intel serio_raw failover sunrpc dm_mirror dm_region_hash dm_log dm_mod be2iscsi bnx2i cnic uio cxgb4i cxgb4 libcxgbi libcxgb qla4xxx iscsi_boot_sysfs iscsi_tcp libiscsi_tcp libiscsi scsi_transport_iscsi [ 605.627479] CPU: 1 PID: 26794 Comm: kworker/u32:2 Not tainted 4.18.0-60.el8.x86_64 #1 [ 605.721401] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20180724_192412-buildhw-07.phx2.fedoraproject.org-1.fc29 04/01/2014 [ 605.823651] Workqueue: scsi_wq_2 __iscsi_unbind_session [scsi_transport_iscsi] [ 605.830940] RIP: 0010:sysfs_remove_group+0x76/0x80 [ 605.922907] Code: 48 89 df 5b 5d 41 5c e9 38 c4 ff ff 48 89 df e8 e0 bf ff ff eb cb 49 8b 14 24 48 8b 75 00 48 c7 c7 38 73 cb a7 e8 24 77 d7 ff <0f> 0b 5b 5d 41 5c c3 0f 1f 00 0f 1f 44 00 00 41 56 41 55 41 54 55 [ 606.122304] RSP: 0018:ffffbadcc8d1bda8 EFLAGS: 00010286 [ 606.218492] RAX: 0000000000000000 RBX: 0000000000000000 RCX: 0000000000000000 [ 606.326381] RDX: ffff98bdfe85eb40 RSI: ffff98bdfe856818 RDI: ffff98bdfe856818 [ 606.514498] RBP: ffffffffa7ab73e0 R08: 0000000000000268 R09: 0000000000000007 [ 606.529469] R10: 0000000000000000 R11: ffffffffa860d9ad R12: ffff98bdf978e838 [ 606.630535] R13: ffff98bdc2cd4010 R14: ffff98bdc2cd3ff0 R15: ffff98bdc2cd4000 [ 606.824707] FS: 0000000000000000(0000) GS:ffff98bdfe840000(0000) knlGS:0000000000000000 [ 607.018333] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 607.117844] CR2: 00007f84b78ac024 CR3: 000000002c00a003 CR4: 00000000003606e0 [ 607.117844] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 607.420926] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 607.524236] Call Trace: [ 607.530591] device_del+0x56/0x350 [ 607.624393] ? ata_tlink_match+0x30/0x30 [libata] [ 607.727805] ? attribute_container_device_trigger+0xb4/0xf0 [ 607.829911] scsi_target_reap_ref_release+0x39/0x50 [ 607.928572] scsi_remove_target+0x1a2/0x1d0 [ 608.017350] __iscsi_unbind_session+0xb3/0x160 [scsi_transport_iscsi] [ 608.117435] process_one_work+0x1a7/0x360 [ 608.132917] worker_thread+0x30/0x390 [ 608.222900] ? pwq_unbound_release_workfn+0xd0/0xd0 [ 608.323989] kthread+0x112/0x130 [ 608.418318] ? kthread_bind+0x30/0x30 [ 608.513821] ret_from_fork+0x35/0x40 [ 608.613909] ---[ end trace 0b98c310c8a6138c ]---
--- drivers/scsi/scsi_transport_iscsi.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/scsi/scsi_transport_iscsi.c +2 -0
@@ -2200,6 +2200,8 @@ void iscsi_remove_session(struct iscsi_cls_session *session)scsi_target_unblock (&session->dev,SDEV_TRANSPORT_OFFLINE );/* flush running scans then delete devices */ flush_work (&session->scan_work); +/* flush running unbind operations */ +flush_work (&session->unbind_work);__iscsi_unbind_session (&session->unbind_work);/* hw iscsi may not have removed all connections from session */
Signature · 8 lines
2.19.1 -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To unsubscribe from this group and stop receiving emails from it, send an email to open-iscsi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/[email protected] To post to this group, send email to open-iscsi-/JYPxA39Uh5TLH3MbocFF+G/[email protected] Visit this group at https://groups.google.com/group/open-iscsi. For more options, visit https://groups.google.com/d/optout.
Sasha Levin
maintainerPATCH 27/67 sched/cpufreq: Fix 32-bit math overflow
In reply to Sasha LevinFrom: Peter Zijlstra <[email protected]>
[ Upstream commit a23314e9d88d89d49e69db08f60b7caa470f04e1 ]
Vincent Wang reported that get_next_freq() has a mult overflow bug on 32-bit platforms in the IOWAIT boost case, since in that case {util,max} are in freq units instead of capacity units.
Solve this by moving the IOWAIT boost to capacity units. And since this means @max is constant; simplify the code.
--- kernel/sched/cpufreq_schedutil.c | 59 ++++++++++++++------------------ 1 file changed, 25 insertions(+), 34 deletions(-)
kernel/sched/cpufreq_schedutil.c +25 -34
@@ -48,10 +48,10 @@ struct sugov_cpu {bool iowait_boost_pending;unsigned int iowait_boost; -unsigned int iowait_boost_max;u64 last_update;unsigned long bw_dl; +unsigned long min;unsigned long max;/* The field below is for single-CPU policies only: */
@@ -303,8 +303,7 @@ static bool sugov_iowait_reset(struct sugov_cpu *sg_cpu, u64 time,if (delta_ns <=TICK_NSEC )return false; - sg_cpu->iowait_boost = set_iowait_boost - ? sg_cpu->sg_policy->policy->min :0 ; + sg_cpu->iowait_boost = set_iowait_boost ? sg_cpu->min :0 ; sg_cpu->iowait_boost_pending = set_iowait_boost;return true;
@@ -344,14 +343,13 @@ static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,/* Double the boost at each request */ if (sg_cpu->iowait_boost) { - sg_cpu->iowait_boost <<=1 ; -if (sg_cpu->iowait_boost > sg_cpu->iowait_boost_max) - sg_cpu->iowait_boost = sg_cpu->iowait_boost_max; + sg_cpu->iowait_boost = + min_t(unsigned int, sg_cpu->iowait_boost << 1, SCHED_CAPACITY_SCALE);return ; }/* First wakeup after IO: start with minimum boost */ - sg_cpu->iowait_boost = sg_cpu->sg_policy->policy->min; + sg_cpu->iowait_boost = sg_cpu->min; }/**
@@ -373,47 +371,38 @@ static void sugov_iowait_boost(struct sugov_cpu *sg_cpu, u64 time,* This mechanism is designed to boost high frequently IO waiting tasks, while * being more conservative on tasks which does sporadic IO operations. */ -static void sugov_iowait_apply (struct sugov_cpu *sg_cpu,u64 time, -unsigned long *util,unsigned long *max) +static unsigned long sugov_iowait_apply (struct sugov_cpu *sg_cpu,u64 time, +unsigned long util,unsigned long max) { -unsigned int boost_util, boost_max; +unsigned long boost;/* No boost currently required */ if (!sg_cpu->iowait_boost) -return ; +return util;/* Reset boost if the CPU appears to have been idle enough */ if (sugov_iowait_reset (sg_cpu, time, false)) -return ; +return util; -/* -* An IO waiting task has just woken up: -* allow to further double the boost value -*/ -if (sg_cpu->iowait_boost_pending) { - sg_cpu->iowait_boost_pending = false; - }else { +if (!sg_cpu->iowait_boost_pending) {/* -* Otherwise: reduce the boost value and disable it when we -* reach the minimum. +* No boost pending; reduce the boost value. */ sg_cpu->iowait_boost >>=1 ; -if (sg_cpu->iowait_boost < sg_cpu->sg_policy->policy->min) { +if (sg_cpu->iowait_boost < sg_cpu->min) { sg_cpu->iowait_boost =0 ; -return ; +return util; } } + sg_cpu->iowait_boost_pending = false; +/* -* Apply the current boost value: a CPU is boosted only if its current -* utilization is smaller then the current IO boost level. +* @util is already in capacity scale; convert iowait_boost +* into the same scale so we can compare. */ - boost_util = sg_cpu->iowait_boost; - boost_max = sg_cpu->iowait_boost_max; -if (*util * boost_max < *max * boost_util) { - *util = boost_util; - *max = boost_max; - } + boost = (sg_cpu->iowait_boost * max) >>SCHED_CAPACITY_SHIFT ; +return max (boost, util); }#ifdef CONFIG_NO_HZ_COMMON
@@ -460,7 +449,7 @@ static void sugov_update_single(struct update_util_data *hook, u64 time, util =sugov_get_util (sg_cpu); max = sg_cpu->max; -sugov_iowait_apply (sg_cpu, time, &util, &max); + util =sugov_iowait_apply (sg_cpu, time, util, max); next_f =get_next_freq (sg_policy, util, max);/* * Do not reduce the frequency if the CPU has not been idle
@@ -500,7 +489,7 @@ static unsigned int sugov_next_freq_shared(struct sugov_cpu *sg_cpu, u64 time) j_util =sugov_get_util (j_sg_cpu); j_max = j_sg_cpu->max; -sugov_iowait_apply (j_sg_cpu, time, &j_util, &j_max); + j_util =sugov_iowait_apply (j_sg_cpu, time, j_util, j_max);if (j_util * max > j_max * util) { util = j_util;
@@ -837,7 +826,9 @@ static int sugov_start(struct cpufreq_policy *policy)memset (sg_cpu,0 ,sizeof (*sg_cpu)); sg_cpu->cpu = cpu; sg_cpu->sg_policy = sg_policy; - sg_cpu->iowait_boost_max = policy->cpuinfo.max_freq; + sg_cpu->min = + (SCHED_CAPACITY_SCALE * policy->cpuinfo.min_freq) / + policy->cpuinfo.max_freq; }for_each_cpu (cpu, policy->cpus) {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 28/67 sched/core: Fix buffer overflow in cgroup2 property cpu.max
In reply to Sasha LevinFrom: Konstantin Khlebnikov <[email protected]>
[ Upstream commit 4c47acd824aaaa8fc6dc519fb4e08d1522105b7a ]
Add limit into sscanf format string for on-stack buffer.
--- kernel/sched/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/sched/core.c +1 -1
@@ -6941,7 +6941,7 @@ static int __maybe_unused cpu_period_quota_parse(char *buf, {char tok[21 ];/* U64_MAX */ -if (!sscanf (buf,"%s %llu" , tok, periodp)) +if (sscanf (buf,"%20s %llu" , tok, periodp) <1 )return -EINVAL ; *periodp *=NSEC_PER_USEC ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 29/67 x86/mm: Don't leak kernel addresses
In reply to Sasha LevinFrom: Matteo Croce <[email protected]>
[ Upstream commit a3151724437f54076cc10bc02b1c4f0003ae36cd ]
Since commit:
ad67b74d2469d9b8 ("printk: hash addresses printed with %p")
at boot "____ptrval____" is printed instead of actual addresses:
found SMP MP-table at [mem 0x000f5cc0-0x000f5ccf] mapped at [(____ptrval____)]
Instead of changing the print to "%px", and leaking a kernel addresses, just remove the print completely, like in:
071929dbdd865f77 ("arm64: Stop printing the virtual memory layout").
--- arch/x86/kernel/mpparse.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/mpparse.c +2 -2
@@ -598,8 +598,8 @@ static int __init smp_scan_config(unsigned long base, unsigned long length) mpf_base = base; mpf_found = true; -pr_info ("found SMP MP-table at [mem %#010lx-%#010lx] mapped at [%p]\n" , - base, base +sizeof (*mpf) -1 , mpf); +pr_info ("found SMP MP-table at [mem %#010lx-%#010lx]\n" , + base, base +sizeof (*mpf) -1 );memblock_reserve (base,sizeof (*mpf));if (mpf->physptr)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 30/67 tools/power turbostat: return the exit status of a command
In reply to Sasha LevinFrom: David Arcari <[email protected]>
[ Upstream commit 2a95496634a017c19641f26f00907af75b962f01 ]
turbostat failed to return a non-zero exit status even though the supplied command (turbostat <command>) failed. Currently when turbostat forks a command it returns zero instead of the actual exit status of the command. Modify the code to return the exit status.
--- tools/power/x86/turbostat/turbostat.c | 3 +++ 1 file changed, 3 insertions(+)
tools/power/x86/turbostat/turbostat.c +3 -0
@@ -5077,6 +5077,9 @@ int fork_it(char **argv)signal (SIGQUIT ,SIG_IGN );if (waitpid (child_pid, &status,0 ) ==-1 )err (status,"waitpid" ); + +if (WIFEXITED (status)) + status =WEXITSTATUS (status); }/* * n.b. fork_it() does not check for errors from for_all_cpus()
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 31/67 scsi: core: Also call destroy_rcu_head() for passthrough requests
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit db983f6eef57a9d78af79bc32389b7e60eb3c47d ]
cmd->rcu is initialized by scsi_initialize_rq(). For passthrough requests, blk_get_request() calls scsi_initialize_rq(). For filesystem requests, scsi_init_command() calls scsi_initialize_rq(). Make sure that destroy_rcu_head() is called for passthrough requests.
--- drivers/scsi/scsi_lib.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +8 -1
@@ -598,9 +598,16 @@ static bool scsi_end_request(struct request *req, blk_status_t error,if (!blk_rq_is_scsi (req)) {WARN_ON_ONCE (!(cmd->flags &SCMD_INITIALIZED )); cmd->flags &= ~SCMD_INITIALIZED ; -destroy_rcu_head (&cmd->rcu); } +/* +* Calling rcu_barrier() is not necessary here because the +* SCSI error handler guarantees that the function called by +* call_rcu() has been called before scsi_end_request() is +* called. +*/ +destroy_rcu_head (&cmd->rcu); +/* * In the MQ case the command gets freed by __blk_mq_end_request, * so we have to do all cleanup that depends on it earlier.
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 32/67 scsi: qla2xxx: Fix NULL pointer crash due to stale CPUID
In reply to Sasha LevinFrom: Himanshu Madhani <[email protected]>
[ Upstream commit ac444b4f0ace05d7c4c99f6b1e5b0cae0852f025 ]
This patch fixes crash due to NULL pointer derefrence because CPU pointer is not set and used by driver. Instead, driver is passes CPU as tag via ha->isp_ops->{lun_reset|target_reset}
[ 30.160780] qla2xxx [0000:a0:00.1]-8038:9: Cable is unplugged... [ 69.984045] qla2xxx [0000:a0:00.0]-8009:8: DEVICE RESET ISSUED nexus=8:0:0 cmd=00000000b0d62f46. [ 69.992849] BUG: unable to handle kernel NULL pointer dereference at 0000000000000040 [ 70.000680] PGD 0 P4D 0 [ 70.003232] Oops: 0000 [#1] SMP PTI [ 70.006727] CPU: 2 PID: 6714 Comm: sg_reset Kdump: loaded Not tainted 4.18.0-67.el8.x86_64 #1 [ 70.015258] Hardware name: NEC Express5800/T110j [N8100-2758Y]/MX32-PH0-NJ, BIOS F11 02/13/2019 [ 70.024016] RIP: 0010:blk_mq_rq_cpu+0x9/0x10 [ 70.028315] Code: 01 58 01 00 00 48 83 c0 28 48 3d 80 02 00 00 75 ab c3 0f 1f 44 00 00 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 48 8b 47 08 <8b> 40 40 c3 0f 1f 00 0f 1f 44 00 00 48 83 ec 10 48 c7 c6 20 6e 7c [ 70.047087] RSP: 0018:ffff99a481487d58 EFLAGS: 00010246 [ 70.052322] RAX: 0000000000000000 RBX: ffffffffc041b08b RCX: 0000000000000000 [ 70.059466] RDX: 0000000000000000 RSI: ffff8d10b6b16898 RDI: ffff8d10b341e400 [ 70.066615] RBP: ffffffffc03a6bd0 R08: 0000000000000415 R09: 0000000000aaaaaa [ 70.073765] R10: 0000000000000001 R11: 0000000000000001 R12: ffff8d10b341e528 [ 70.080914] R13: ffff8d10aadefc00 R14: ffff8d0f64efa998 R15: ffff8d0f64efa000 [ 70.088083] FS: 00007f90a201e540(0000) GS:ffff8d10b6b00000(0000) knlGS:0000000000000000 [ 70.096188] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 70.101959] CR2: 0000000000000040 CR3: 0000000268886005 CR4: 00000000003606e0 [ 70.109127] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000 [ 70.116277] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400 [ 70.123425] Call Trace: [ 70.125896] __qla2xxx_eh_generic_reset+0xb1/0x220 [qla2xxx] [ 70.131572] scsi_ioctl_reset+0x1f5/0x2a0 [ 70.135600] scsi_ioctl+0x18e/0x397 [ 70.139099] ? sd_ioctl+0x7c/0x100 [sd_mod] [ 70.143287] blkdev_ioctl+0x32b/0x9f0 [ 70.146954] ? __check_object_size+0xa3/0x181 [ 70.151323] block_ioctl+0x39/0x40 [ 70.154735] do_vfs_ioctl+0xa4/0x630 [ 70.158322] ? syscall_trace_enter+0x1d3/0x2c0 [ 70.162769] ksys_ioctl+0x60/0x90 [ 70.166104] __x64_sys_ioctl+0x16/0x20 [ 70.169859] do_syscall_64+0x5b/0x1b0 [ 70.173532] entry_SYSCALL_64_after_hwframe+0x65/0xca [ 70.178587] RIP: 0033:0x7f90a1b3445b [ 70.182183] Code: 0f 1e fa 48 8b 05 2d aa 2c 00 64 c7 00 26 00 00 00 48 c7 c0 ff ff ff ff c3 66 0f 1f 44 00 00 f3 0f 1e fa b8 10 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 01 c3 48 8b 0d fd a9 2c 00 f7 d8 64 89 01 48 [ 70.200956] RSP: 002b:00007fffdca88b68 EFLAGS: 00000246 ORIG_RAX: 0000000000000010 [ 70.208535] RAX: ffffffffffffffda RBX: 0000000000000003 RCX: 00007f90a1b3445b [ 70.215684] RDX: 00007fffdca88b84 RSI: 0000000000002284 RDI: 0000000000000003 [ 70.222833] RBP: 00007fffdca88ca8 R08: 00007fffdca88b84 R09: 0000000000000000 [ 70.229981] R10: 0000000000000000 R11: 0000000000000246 R12: 00007fffdca88b84 [ 70.237131] R13: 0000000000000000 R14: 000055ab09b0bd28 R15: 0000000000000000 [ 70.244284] Modules linked in: nft_chain_route_ipv4 xt_CHECKSUM nft_chain_nat_ipv4 ipt_MASQUERADE nf_nat_ipv4 nf_nat nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack libcrc32c ipt_REJECT nf_reject_ipv4 nft_counter nft_compat tun bridge stp llc nf_tables nfnetli
nk devlink sunrpc vfat fat intel_rapl intel_pmc_core x86_pkg_temp_thermal intel_powerclamp coretemp kvm_intel kvm wmi_bmof iTCO_wdt iTCO_ vendor_support irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel ipmi_ssif intel_cstate intel_uncore intel_rapl_perf ipmi_si jo ydev pcspkr ipmi_devintf sg wmi ipmi_msghandler video acpi_power_meter acpi_pad mei_me i2c_i801 mei ip_tables ext4 mbcache jbd2 sr_mod cd rom sd_mod qla2xxx ast i2c_algo_bit drm_kms_helper nvme_fc syscopyarea sysfillrect uas sysimgblt fb_sys_fops nvme_fabrics ttm
[ 70.314805] usb_storage nvme_core crc32c_intel scsi_transport_fc ahci drm libahci tg3 libata megaraid_sas pinctrl_cannonlake pinctrl_ intel [ 70.327335] CR2: 0000000000000040
--- drivers/scsi/qla2xxx/qla_os.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/qla2xxx/qla_os.c +1 -1
@@ -1459,7 +1459,7 @@ __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, goto eh_reset_failed; } err =2 ; -if (do_reset (fcport, cmd->device->lun,blk_mq_rq_cpu (cmd->request) +1 ) +if (do_reset (fcport, cmd->device->lun,1 ) !=QLA_SUCCESS ) {ql_log (ql_log_warn, vha,0x800c ,"do_reset failed for cmd=%p.\n" , cmd);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 33/67 perf stat: Fix --no-scale
In reply to Sasha LevinFrom: Andi Kleen <[email protected]>
[ Upstream commit 75998bb263bf48c1c85d78cd2d2f3a97d3747cab ]
The -c option to enable multiplex scaling has been useless for quite some time because scaling is default.
It's only useful as --no-scale to disable scaling. But the non scaling code path has bitrotted and doesn't print anything because perf output code relies on value run/ena information.
Also even when we don't want to scale a value it's still useful to show its multiplex percentage.
This patch:
- Fixes help and documentation to show --no-scale instead of -c
- Removes -c, only keeps the long option because -c doesn't support negatives.
- Enables running/enabled even with --no-scale
- And fixes some other problems in the no-scale output.
Before:
$ perf stat --no-scale -e cycles true
Performance counter stats for 'true':
<not counted> cycles
0.000984154 seconds time elapsed
After:
$ ./perf stat --no-scale -e cycles true
Performance counter stats for 'true':
706,070 cycles
0.001219821 seconds time elapsedLPU-Reference: [email protected]
--- tools/perf/Documentation/perf-stat.txt | 5 ++--- tools/perf/builtin-stat.c | 3 ++- tools/perf/util/evsel.c | 3 +-- tools/perf/util/stat.c | 12 ++++-------- 4 files changed, 9 insertions(+), 14 deletions(-)
tools/perf/Documentation/perf-stat.txt +2 -3
@@ -72,9 +72,8 @@ report:: --all-cpus:: system-wide collection from all CPUs (default if no target is specified) --c:: ---scale:: - scale/normalize counter values +--no-scale:: + Don't scale/normalize counter values -d:: --detailed::
tools/perf/builtin-stat.c +2 -1
@@ -728,7 +728,8 @@ static struct option stat_options[] = { "system-wide collection from all CPUs"),OPT_BOOLEAN ('g' ,"group" , &group,"put the counters into a counter group" ), -OPT_BOOLEAN ('c' ,"scale" , &stat_config.scale,"scale/normalize counters" ), +OPT_BOOLEAN (0 ,"scale" , &stat_config.scale, +"Use --no-scale to disable counter scaling for multiplexing" ),OPT_INCR ('v' ,"verbose" , &verbose,"be more verbose (show counter open errors, etc)" ), OPT_INTEGER('r', "repeat", &stat_config.run_count,
tools/perf/util/evsel.c +1 -2
@@ -1341,8 +1341,7 @@ void perf_counts_values__scale(struct perf_counts_values *count, scaled =1 ; count->val = (u64)((double ) count->val * count->ena / count->run +0.5 ); } - }else - count->ena = count->run =0 ; + }if (pscaled) *pscaled = scaled;
tools/perf/util/stat.c +4 -8
@@ -291,10 +291,8 @@ process_counter_values(struct perf_stat_config *config, struct perf_evsel *evselbreak ;case AGGR_GLOBAL : aggr->val += count->val; -if (config->scale) { - aggr->ena += count->ena; - aggr->run += count->run; - } + aggr->ena += count->ena; + aggr->run += count->run;case AGGR_UNSET :default :break ;
@@ -442,10 +440,8 @@ int create_perf_stat_counter(struct perf_evsel *evsel,struct perf_event_attr *attr = &evsel->attr;struct perf_evsel *leader = evsel->leader; -if (config->scale) { - attr->read_format =PERF_FORMAT_TOTAL_TIME_ENABLED | -PERF_FORMAT_TOTAL_TIME_RUNNING ; - } + attr->read_format =PERF_FORMAT_TOTAL_TIME_ENABLED | +PERF_FORMAT_TOTAL_TIME_RUNNING ;/* * The event is part of non trivial group, let's enable
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 34/67 perf list: Don't forget to drop the reference to the allocated thread_map
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 39df730b09774bd860e39ea208a48d15078236cb ]
Detected via gcc's ASan:
Direct leak of 2048 byte(s) in 64 object(s) allocated from:
6 #0 0x7f606512e370 in __interceptor_realloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee370)
7 #1 0x556b0f1d7ddd in thread_map__realloc util/thread_map.c:43
8 #2 0x556b0f1d84c7 in thread_map__new_by_tid util/thread_map.c:85
9 #3 0x556b0f0e045e in is_event_supported util/parse-events.c:2250
10 #4 0x556b0f0e1aa1 in print_hwcache_events util/parse-events.c:2382
11 #5 0x556b0f0e3231 in print_events util/parse-events.c:2514
12 #6 0x556b0ee0a66e in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
13 #7 0x556b0f01e0ae in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
14 #8 0x556b0f01e859 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
15 #9 0x556b0f01edc8 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
16 #10 0x556b0f01f71f in main /home/changbin/work/linux/tools/perf/perf.c:520
17 #11 0x7f6062ccf09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)--- tools/perf/util/parse-events.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/parse-events.c +1 -0
@@ -2271,6 +2271,7 @@ static bool is_event_supported(u8 type, unsigned config)perf_evsel__delete (evsel); } +thread_map__put (tmap);return ret; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 35/67 perf tools: Fix errors under optimization level '-Og'
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 11c1ea6f1a9bc97bf857fd12f72eacb6c69794e2 ]
Optimization level '-Og' offers a reasonable level of optimization while maintaining fast compilation and a good debugging experience. This patch tries to make it work.
$ make DEBUG=1 EXTRA_CFLAGS='-Og'
bench/epoll-ctl.c: In function ‘do_threads’:
bench/epoll-ctl.c:274:9: error: ‘ret’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
return ret;
^~~
...--- tools/lib/bpf/libbpf.c | 2 +- tools/perf/bench/epoll-ctl.c | 2 +- tools/perf/bench/epoll-wait.c | 2 +- tools/perf/tests/backward-ring-buffer.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
tools/lib/bpf/libbpf.c +1 -1
@@ -627,7 +627,7 @@ bpf_object__init_maps(struct bpf_object *obj, int flags)bool strict = !(flags &MAPS_RELAX_COMPAT );int i, map_idx, map_def_sz, nr_maps =0 ;Elf_Scn *scn; -Elf_Data *data; +Elf_Data *data =NULL ;Elf_Data *symbols = obj->efile.symbols;if (obj->efile.maps_shndx <0 )
tools/perf/bench/epoll-ctl.c +1 -1
@@ -224,7 +224,7 @@ static int do_threads(struct worker *worker, struct cpu_map *cpu)pthread_attr_t thread_attr, *attrp =NULL ;cpu_set_t cpuset;unsigned int i, j; -int ret; +int ret =0 ;if (!noaffinity)pthread_attr_init (&thread_attr);
tools/perf/bench/epoll-wait.c +1 -1
@@ -293,7 +293,7 @@ static int do_threads(struct worker *worker, struct cpu_map *cpu)pthread_attr_t thread_attr, *attrp =NULL ;cpu_set_t cpuset;unsigned int i, j; -int ret, events =EPOLLIN ; +int ret =0 , events =EPOLLIN ;if (oneshot) events |=EPOLLONESHOT ;
tools/perf/tests/backward-ring-buffer.c +1 -1
@@ -18,7 +18,7 @@ static void testcase(void)int i;for (i =0 ; i <NR_ITERS ; i++) { -char proc_name[10 ]; +char proc_name[15 ];snprintf (proc_name,sizeof (proc_name),"p:%d\n" , i);prctl (PR_SET_NAME , proc_name);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 36/67 perf config: Fix an error in the config template documentation
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 9b40dff7ba3caaf0d1919f98e136fa3400bd34aa ]
The option 'sort-order' should be 'sort_order'.
--- tools/perf/Documentation/perf-config.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/Documentation/perf-config.txt +1 -1
@@ -114,7 +114,7 @@ Given a $HOME/.perfconfig like this: [report] # Defaults - sort-order = comm,dso,symbol + sort_order = comm,dso,symbol percent-limit = 0 queue-size = 0 children = true
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 37/67 perf config: Fix a memory leak in collect_config()
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 54569ba4b06d5baedae4614bde33a25a191473ba ]
Detected with gcc's ASan:
Direct leak of 66 byte(s) in 5 object(s) allocated from:
#0 0x7ff3b1f32070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
#1 0x560c8761034d in collect_config util/config.c:597
#2 0x560c8760d9cb in get_value util/config.c:169
#3 0x560c8760dfd7 in perf_parse_file util/config.c:285
#4 0x560c8760e0d2 in perf_config_from_file util/config.c:476
#5 0x560c876108fd in perf_config_set__init util/config.c:661
#6 0x560c87610c72 in perf_config_set__new util/config.c:709
#7 0x560c87610d2f in perf_config__init util/config.c:718
#8 0x560c87610e5d in perf_config util/config.c:730
#9 0x560c875ddea0 in main /home/changbin/work/linux/tools/perf/perf.c:442
#10 0x7ff3afb8609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)--- tools/perf/util/config.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
tools/perf/util/config.c +1 -2
@@ -632,11 +632,10 @@ static int collect_config(const char *var, const char *value, } ret =set_value (item, value); -return ret; out_free:free (key); -return -1 ; +return ret; } int perf_config_set__collect(struct perf_config_set *set, const char *file_name,
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 38/67 perf build-id: Fix memory leak in print_sdt_events()
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 8bde8516893da5a5fdf06121f74d11b52ab92df5 ]
Detected with gcc's ASan:
Direct leak of 4356 byte(s) in 120 object(s) allocated from:
#0 0x7ff1a2b5a070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
#1 0x55719aef4814 in build_id_cache__origname util/build-id.c:215
#2 0x55719af649b6 in print_sdt_events util/parse-events.c:2339
#3 0x55719af66272 in print_events util/parse-events.c:2542
#4 0x55719ad1ecaa in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
#5 0x55719aec745d in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#6 0x55719aec7d1a in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#7 0x55719aec8184 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#8 0x55719aeca41a in main /home/changbin/work/linux/tools/perf/perf.c:520
#9 0x7ff1a07ae09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)--- tools/perf/util/build-id.c | 1 + tools/perf/util/parse-events.c | 1 + 2 files changed, 2 insertions(+)
tools/perf/util/build-id.c +1 -0
@@ -183,6 +183,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size)return bf; } +/* The caller is responsible to free the returned buffer. */ char *build_id_cache__origname (const char *sbuild_id) {char *linkname;
tools/perf/util/parse-events.c +1 -0
@@ -2342,6 +2342,7 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob,printf (" %-50s [%s]\n" , buf,"SDT event" );free (buf); } +free (path); }else printf (" %-50s [%s]\n" , nd->s,"SDT event" );if (nd2) {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 39/67 perf top: Delete the evlist before perf_session, fixing heap-use-after-free issue
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 0dba9e4be95b59e77060645ca8e37ca3231061f5 ]
The evlist should be destroyed before the perf session.
Detected with gcc's ASan:
=================================================================
==27350==ERROR: AddressSanitizer: heap-use-after-free on address 0x62b000002e38 at pc 0x5611da276999 bp 0x7ffce8f1d1a0 sp 0x7ffce8f1d190 WRITE of size 8 at 0x62b000002e38 thread T0
#0 0x5611da276998 in __list_del /home/work/linux/tools/include/linux/list.h:89
#1 0x5611da276d4a in __list_del_entry /home/work/linux/tools/include/linux/list.h:102
#2 0x5611da276e77 in list_del_init /home/work/linux/tools/include/linux/list.h:145
#3 0x5611da2781cd in thread__put util/thread.c:130
#4 0x5611da2cc0a8 in __thread__zput util/thread.h:68
#5 0x5611da2d2dcb in hist_entry__delete util/hist.c:1148
#6 0x5611da2cdf91 in hists__delete_entry util/hist.c:337
#7 0x5611da2ce19e in hists__delete_entries util/hist.c:365
#8 0x5611da2db2ab in hists__delete_all_entries util/hist.c:2639
#9 0x5611da2db325 in hists_evsel__exit util/hist.c:2651
#10 0x5611da1c5352 in perf_evsel__exit util/evsel.c:1304
#11 0x5611da1c5390 in perf_evsel__delete util/evsel.c:1309
#12 0x5611da1b35f0 in perf_evlist__purge util/evlist.c:124
#13 0x5611da1b38e2 in perf_evlist__delete util/evlist.c:148
#14 0x5611da069781 in cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1645
#15 0x5611da17d038 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#16 0x5611da17d577 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#17 0x5611da17d97b in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#18 0x5611da17e0e9 in main /home/changbin/work/linux/tools/perf/perf.c:520
#19 0x7fdcc970f09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
#20 0x5611d9ff35c9 in _start (/home/work/linux/tools/perf/perf+0x3e95c9) 0x62b000002e38 is located 11320 bytes inside of 27448-byte region [0x62b000000200,0x62b000006d38) freed by thread T0 here:
#0 0x7fdccb04ab70 in free (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedb70)
#1 0x5611da260df4 in perf_session__delete util/session.c:201
#2 0x5611da063de5 in __cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1300
#3 0x5611da06973c in cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1642
#4 0x5611da17d038 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#5 0x5611da17d577 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#6 0x5611da17d97b in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#7 0x5611da17e0e9 in main /home/changbin/work/linux/tools/perf/perf.c:520
#8 0x7fdcc970f09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)previously allocated by thread T0 here:
#0 0x7fdccb04b138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
#1 0x5611da26010c in zalloc util/util.h:23
#2 0x5611da260824 in perf_session__new util/session.c:118
#3 0x5611da0633a6 in __cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1192
#4 0x5611da06973c in cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1642
#5 0x5611da17d038 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#6 0x5611da17d577 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#7 0x5611da17d97b in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#8 0x5611da17e0e9 in main /home/changbin/work/linux/tools/perf/perf.c:520
#9 0x7fdcc970f09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) SUMMARY: AddressSanitizer: heap-use-after-free /home/work/linux/tools/include/linux/list.h:89 in __list_del Shadow bytes around the buggy address:
0x0c567fff8570: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c567fff8580: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c567fff8590: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c567fff85a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c567fff85b0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
=>0x0c567fff85c0: fd fd fd fd fd fd fd[fd]fd fd fd fd fd fd fd fd
0x0c567fff85d0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c567fff85e0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c567fff85f0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c567fff8600: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
0x0c567fff8610: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
==27350==ABORTING
--- tools/perf/builtin-top.c | 42 ++++++++++++++++++---------------------- 1 file changed, 19 insertions(+), 23 deletions(-)
tools/perf/builtin-top.c +19 -23
@@ -1192,23 +1192,19 @@ static int __cmd_top(struct perf_top *top)pthread_t thread, thread_process;int ret; - top->session =perf_session__new (NULL , false,NULL ); -if (top->session ==NULL ) -return -1 ; -if (!top->annotation_opts.objdump_path) { ret =perf_env__lookup_objdump (&top->session->header.env, &top->annotation_opts.objdump_path);if (ret) - goto out_delete; +return ret; } ret =callchain_param__setup_sample_type (&callchain_param);if (ret) - goto out_delete; +return ret;if (perf_session__register_idle_thread (top->session) <0 ) - goto out_delete; +return ret;if (top->nr_threads_synthesize >1 )perf_set_multithreaded ();
@@ -1224,13 +1220,18 @@ static int __cmd_top(struct perf_top *top)if (perf_hpp_list.socket) { ret =perf_env__read_cpu_topology_map (&perf_env); -if (ret <0 ) - goto out_err_cpu_topo; +if (ret <0 ) { +char errbuf[BUFSIZ ]; +const char *err =str_error_r (-ret, errbuf,sizeof (errbuf)); + +ui__error ("Could not read the CPU topology map: %s\n" , err); +return ret; + } } ret =perf_top__start_counters (top);if (ret) - goto out_delete; +return ret; ret =perf_evlist__apply_drv_configs (evlist, &pos, &err_term);if (ret) {
@@ -1257,7 +1258,7 @@ static int __cmd_top(struct perf_top *top) ret =-1 ;if (pthread_create (&thread_process,NULL , process_thread, top)) {ui__error ("Could not create process thread.\n" ); - goto out_delete; +return ret; } if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui :
@@ -1301,19 +1302,7 @@ out_join: out_join_thread:pthread_cond_signal (&top->qe.cond);pthread_join (thread_process,NULL ); -out_delete: -perf_session__delete (top->session); - top->session =NULL ; -return ret; - -out_err_cpu_topo: { -char errbuf[BUFSIZ ]; -const char *err =str_error_r (-ret, errbuf,sizeof (errbuf)); - -ui__error ("Could not read the CPU topology map: %s\n" , err); - goto out_delete; -} } static int
@@ -1644,10 +1633,17 @@ int cmd_top(int argc, const char **argv)signal (SIGWINCH , winch_sig); } + top.session =perf_session__new (NULL , false,NULL ); +if (top.session ==NULL ) { + status =-1 ; + goto out_delete_evlist; + } + status =__cmd_top (&top); out_delete_evlist:perf_evlist__delete (top.evlist); +perf_session__delete (top.session);return status; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 40/67 perf top: Fix error handling in cmd_top()
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 70c819e4bf1c5f492768b399d898d458ccdad2b6 ]
We should go to the cleanup path, to avoid leaks, detected using gcc's ASan.
--- tools/perf/builtin-top.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
tools/perf/builtin-top.c +3 -2
@@ -1622,8 +1622,9 @@ int cmd_top(int argc, const char **argv)annotation_config__init (); symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name ==NULL ); -if (symbol__init (NULL ) <0 ) -return -1 ; + status =symbol__init (NULL ); +if (status <0 ) + goto out_delete_evlist;sort__setup_elide (stdout);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 41/67 perf hist: Add missing map__put() in error case
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit cb6186aeffda4d27e56066c79e9579e7831541d3 ]
We need to map__put() before returning from failure of sample__resolve_callchain().
Detected with gcc's ASan.
--- tools/perf/util/hist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/util/hist.c +3 -1
@@ -1048,8 +1048,10 @@ int hist_entry_iter__add(struct hist_entry_iter *iter, struct addr_location *al, err =sample__resolve_callchain (iter->sample, &callchain_cursor, &iter->parent, iter->evsel, al, max_stack_depth); -if (err) +if (err) { +map__put (alm);return err; + } err = iter->ops->prepare_entry (iter, al);if (err)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 42/67 perf map: Remove map from 'names' tree in __maps__remove()
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit b49265e04410b97b31a5ee66ef6782c1b2d6cd2c ]
There are two trees for each map inserted by maps__insert(), so remove it from the 'names' tree in __maps__remove().
Detected with gcc's ASan.
--- tools/perf/util/map.c | 3 +++ 1 file changed, 3 insertions(+)
tools/perf/util/map.c +3 -0
@@ -911,6 +911,9 @@ static void __maps__remove(struct maps *maps, struct map *map) {rb_erase_init (&map->rb_node, &maps->entries);map__put (map); + +rb_erase_init (&map->rb_node_name, &maps->names); +map__put (map); }void maps__remove (struct maps *maps,struct map *map)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 43/67 perf maps: Purge all maps from the 'names' tree
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit da3a53a7390a89391bd63bead0c2e9af4c5ef3d6 ]
Add function __maps__purge_names() to purge all maps from the names tree. We need to cleanup the names tree in maps__exit().
Detected with gcc's ASan.
--- tools/perf/util/map.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
tools/perf/util/map.c +15 -0
@@ -571,10 +571,25 @@ static void __maps__purge(struct maps *maps) } } +static void __maps__purge_names (struct maps *maps) +{ +struct rb_root *root = &maps->names; +struct rb_node *next =rb_first (root); + +while (next) { + struct map *pos = rb_entry(next, struct map, rb_node_name); + + next =rb_next (&pos->rb_node_name); +rb_erase_init (&pos->rb_node_name, root); +map__put (pos); + } +} +static void maps__exit (struct maps *maps) {down_write (&maps->lock);__maps__purge (maps); +__maps__purge_names (maps);up_write (&maps->lock); }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 44/67 perf top: Fix global-buffer-overflow issue
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 1e5b0cf8672e622257df024074e6e09bfbcb7750 ]
The array str[] should have six elements.
=================================================================
==4322==ERROR: AddressSanitizer: global-buffer-overflow on address 0x56463844e300 at pc 0x564637e7ad0d bp 0x7f30c8c89d10 sp 0x7f30c8c89d00 READ of size 8 at 0x56463844e300 thread T9
#0 0x564637e7ad0c in __ordered_events__flush util/ordered-events.c:316
#1 0x564637e7b0e4 in ordered_events__flush util/ordered-events.c:338
#2 0x564637c6a57d in process_thread /home/changbin/work/linux/tools/perf/builtin-top.c:1073
#3 0x7f30d173a163 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x8163)
#4 0x7f30cfffbdee in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x11adee) 0x56463844e300 is located 32 bytes to the left of global variable 'flags' defined in 'util/trace-event-parse.c:229:26' (0x56463844e320) of size 192 0x56463844e300 is located 0 bytes to the right of global variable 'str' defined in 'util/ordered-events.c:268:28' (0x56463844e2e0) of size 32
SUMMARY: AddressSanitizer: global-buffer-overflow util/ordered-events.c:316 in __ordered_events__flush
Shadow bytes around the buggy address:
0x0ac947081c10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac947081c20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac947081c30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac947081c40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac947081c50: 00 00 00 00 00 00 00 00 f9 f9 f9 f9 00 00 00 00
=>0x0ac947081c60:[f9]f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac947081c70: 00 00 00 00 00 00 00 00 00 00 00 00 f9 f9 f9 f9
0x0ac947081c80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac947081c90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac947081ca0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
0x0ac947081cb0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
Addressable: 00
Partially addressable: 01 02 03 04 05 06 07
Heap left redzone: fa
Freed heap region: fd
Stack left redzone: f1
Stack mid redzone: f2
Stack right redzone: f3
Stack after return: f5
Stack use after scope: f8
Global redzone: f9
Global init order: f6
Poisoned by user: f7
Container overflow: fc
Array cookie: ac
Intra object redzone: bb
ASan internal: fe
Left alloca redzone: ca
Right alloca redzone: cb
Thread T9 created by T0 here:
#0 0x7f30d179de5f in __interceptor_pthread_create (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x4ae5f)
#1 0x564637c6b954 in __cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1253
#2 0x564637c7173c in cmd_top /home/changbin/work/linux/tools/perf/builtin-top.c:1642
#3 0x564637d85038 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#4 0x564637d85577 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#5 0x564637d8597b in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#6 0x564637d860e9 in main /home/changbin/work/linux/tools/perf/perf.c:520
#7 0x7f30cff0509a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)--- tools/perf/util/ordered-events.c | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/util/ordered-events.c +2 -0
@@ -270,6 +270,8 @@ static int __ordered_events__flush(struct ordered_events *oe, enum oe_flush how,"FINAL" ,"ROUND" ,"HALF " , +"TOP " , + "TIME ", };int err;bool show_progress = false;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 45/67 perf evsel: Free evsel->counts in perf_evsel__exit()
In reply to Sasha LevinFrom: Arnaldo Carvalho de Melo <[email protected]>
[ Upstream commit 42dfa451d825a2ad15793c476f73e7bbc0f9d312 ]
Using gcc's ASan, Changbin reports:
=================================================================
==7494==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 48 byte(s) in 1 object(s) allocated from:
#0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
#1 0x5625e5330a5e in zalloc util/util.h:23
#2 0x5625e5330a9b in perf_counts__new util/counts.c:10
#3 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47
#4 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505
#5 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347
#6 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47
#7 0x5625e51528e6 in run_test tests/builtin-test.c:358
#8 0x5625e5152baf in test_and_print tests/builtin-test.c:388
#9 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
#10 0x5625e515572f in cmd_test tests/builtin-test.c:722
#11 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#12 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#13 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#14 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
#15 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)Indirect leak of 72 byte(s) in 1 object(s) allocated from:
#0 0x7f0333a89138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
#1 0x5625e532560d in zalloc util/util.h:23
#2 0x5625e532566b in xyarray__new util/xyarray.c:10
#3 0x5625e5330aba in perf_counts__new util/counts.c:15
#4 0x5625e5330ca0 in perf_evsel__alloc_counts util/counts.c:47
#5 0x5625e520d8e5 in __perf_evsel__read_on_cpu util/evsel.c:1505
#6 0x5625e517a985 in perf_evsel__read_on_cpu /home/work/linux/tools/perf/util/evsel.h:347
#7 0x5625e517ad1a in test__openat_syscall_event tests/openat-syscall.c:47
#8 0x5625e51528e6 in run_test tests/builtin-test.c:358
#9 0x5625e5152baf in test_and_print tests/builtin-test.c:388
#10 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
#11 0x5625e515572f in cmd_test tests/builtin-test.c:722
#12 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#13 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#14 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#15 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
#16 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)His patch took care of evsel->prev_raw_counts, but the above backtraces are about evsel->counts, so fix that instead.
--- tools/perf/util/evsel.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/util/evsel.c +1 -0
@@ -1289,6 +1289,7 @@ void perf_evsel__exit(struct perf_evsel *evsel) {assert (list_empty (&evsel->node));assert (evsel->evlist ==NULL ); +perf_evsel__free_counts (evsel);perf_evsel__free_fd (evsel);perf_evsel__free_id (evsel);perf_evsel__free_config_terms (evsel);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 46/67 perf tests: Fix a memory leak of cpu_map object in the openat_syscall_event_on_all_cpus test
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit 93faa52e8371f0291ee1ff4994edae2b336b6233 ]
=================================================================
==7497==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 40 byte(s) in 1 object(s) allocated from:
#0 0x7f0333a88f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
#1 0x5625e5326213 in cpu_map__trim_new util/cpumap.c:45
#2 0x5625e5326703 in cpu_map__read util/cpumap.c:103
#3 0x5625e53267ef in cpu_map__read_all_cpu_map util/cpumap.c:120
#4 0x5625e5326915 in cpu_map__new util/cpumap.c:135
#5 0x5625e517b355 in test__openat_syscall_event_on_all_cpus tests/openat-syscall-all-cpus.c:36
#6 0x5625e51528e6 in run_test tests/builtin-test.c:358
#7 0x5625e5152baf in test_and_print tests/builtin-test.c:388
#8 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
#9 0x5625e515572f in cmd_test tests/builtin-test.c:722
#10 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#11 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#12 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#13 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
#14 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)--- tools/perf/tests/openat-syscall-all-cpus.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/perf/tests/openat-syscall-all-cpus.c +3 -1
@@ -45,7 +45,7 @@ int test__openat_syscall_event_on_all_cpus(struct test *test __maybe_unused, intif (IS_ERR (evsel)) {tracing_path__strerror_open_tp (errno, errbuf,sizeof (errbuf),"syscalls" ,"sys_enter_openat" );pr_debug ("%s\n" , errbuf); - goto out_thread_map_delete; + goto out_cpu_map_delete; }if (perf_evsel__open (evsel, cpus, threads) <0 ) {
@@ -119,6 +119,8 @@ out_close_fd:perf_evsel__close_fd (evsel); out_evsel_delete:perf_evsel__delete (evsel); +out_cpu_map_delete: +cpu_map__put (cpus); out_thread_map_delete:thread_map__put (threads);return err;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 47/67 perf tests: Fix memory leak by expr__find_other() in test__expr()
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit f97a8991d3b998e518f56794d879f645964de649 ]
=================================================================
==7506==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 13 byte(s) in 3 object(s) allocated from:
#0 0x7f03339d6070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
#1 0x5625e53aaef0 in expr__find_other util/expr.y:221
#2 0x5625e51bcd3f in test__expr tests/expr.c:52
#3 0x5625e51528e6 in run_test tests/builtin-test.c:358
#4 0x5625e5152baf in test_and_print tests/builtin-test.c:388
#5 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
#6 0x5625e515572f in cmd_test tests/builtin-test.c:722
#7 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#8 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#9 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#10 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
#11 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)--- tools/perf/tests/expr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
tools/perf/tests/expr.c +4 -1
@@ -19,7 +19,7 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)const char *p;const char **other;double val; -int ret; +int i, ret;struct parse_ctx ctx;int num_other;
@@ -56,6 +56,9 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)TEST_ASSERT_VAL ("find other" , !strcmp (other[1 ],"BAZ" ));TEST_ASSERT_VAL ("find other" , !strcmp (other[2 ],"BOZO" ));TEST_ASSERT_VAL ("find other" , other[3 ] ==NULL ); + +for (i =0 ; i < num_other; i++) +free ((void *)other[i]);free ((void *)other);return 0 ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 48/67 perf tests: Fix a memory leak in test__perf_evsel__tp_sched_test()
In reply to Sasha LevinFrom: Changbin Du <[email protected]>
[ Upstream commit d982b33133284fa7efa0e52ae06b88f9be3ea764 ]
=================================================================
==20875==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1160 byte(s) in 1 object(s) allocated from:
#0 0x7f1b6fc84138 in calloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xee138)
#1 0x55bd50005599 in zalloc util/util.h:23
#2 0x55bd500068f5 in perf_evsel__newtp_idx util/evsel.c:327
#3 0x55bd4ff810fc in perf_evsel__newtp /home/work/linux/tools/perf/util/evsel.h:216
#4 0x55bd4ff81608 in test__perf_evsel__tp_sched_test tests/evsel-tp-sched.c:69
#5 0x55bd4ff528e6 in run_test tests/builtin-test.c:358
#6 0x55bd4ff52baf in test_and_print tests/builtin-test.c:388
#7 0x55bd4ff543fe in __cmd_test tests/builtin-test.c:583
#8 0x55bd4ff5572f in cmd_test tests/builtin-test.c:722
#9 0x55bd4ffc4087 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
#10 0x55bd4ffc45c6 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
#11 0x55bd4ffc49ca in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
#12 0x55bd4ffc5138 in main /home/changbin/work/linux/tools/perf/perf.c:520
#13 0x7f1b6e34809a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)Indirect leak of 19 byte(s) in 1 object(s) allocated from:
#0 0x7f1b6fc83f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
#1 0x7f1b6e3ac30f in vasprintf (/lib/x86_64-linux-gnu/libc.so.6+0x8830f)--- tools/perf/tests/evsel-tp-sched.c | 1 + 1 file changed, 1 insertion(+)
tools/perf/tests/evsel-tp-sched.c +1 -0
@@ -85,5 +85,6 @@ int test__perf_evsel__tp_sched_test(struct test *test __maybe_unused, int subtesif (perf_evsel__test_field (evsel,"target_cpu" ,4 , true)) ret =-1 ; +perf_evsel__delete (evsel);return ret; }
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 49/67 ACPI / utils: Drop reference in test for device presence
In reply to Sasha LevinFrom: Andy Shevchenko <[email protected]>
[ Upstream commit 54e3aca84e571559915998aa6cc05e5ac37c043b ]
When commit 8661423eea1a ("ACPI / utils: Add new acpi_dev_present helper") introduced acpi_dev_present(), it missed the fact that bus_find_device() took a reference on the device found by it and the callers of acpi_dev_present() don't drop that reference.
Drop the reference on the device in acpi_dev_present().
--- drivers/acpi/utils.c | 1 + 1 file changed, 1 insertion(+)
drivers/acpi/utils.c +1 -0
@@ -800,6 +800,7 @@ bool acpi_dev_present(const char *hid, const char *uid, s64 hrv) match.hrv = hrv; dev =bus_find_device (&acpi_bus_type,NULL , &match, acpi_dev_match_cb); +put_device (dev);return !!dev; }EXPORT_SYMBOL (acpi_dev_present);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 50/67 PM / Domains: Avoid a potential deadlock
In reply to Sasha LevinFrom: Jiada Wang <[email protected]>
[ Upstream commit 2071ac985d37efe496782c34318dbead93beb02f ]
Lockdep warns that prepare_lock and genpd->mlock can cause a deadlock the deadlock scenario is like following:
First thread is probing cs2000cs2000_probe()
clk_register()
__clk_core_init()
clk_prepare_lock() ----> acquires prepare_lock
cs2000_recalc_rate()
i2c_smbus_read_byte_data()
rcar_i2c_master_xfer()
dma_request_chan()
rcar_dmac_of_xlate()
rcar_dmac_alloc_chan_resources()
pm_runtime_get_sync()
__pm_runtime_resume()
rpm_resume()
rpm_callback()
genpd_runtime_resume() ----> acquires genpd->mlockSecond thread is attaching any device to the same PM domain genpd_add_device()
genpd_lock() ----> acquires genpd->mlock
cpg_mssr_attach_dev()
of_clk_get_from_provider()
__of_clk_get_from_provider()
__clk_create_clk()
clk_prepare_lock() ----> acquires prepare_lockSince currently no PM provider access genpd's critical section
in .attach_dev, and .detach_dev callbacks, so there is no need to protect these two callbacks with genpd->mlock.
This patch avoids a potential deadlock by moving out .attach_dev and .detach_dev from genpd->mlock, so that genpd->mlock won't be held when prepare_lock is acquired in .attach_dev and .detach_dev
--- drivers/base/power/domain.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-)
drivers/base/power/domain.c +6 -7
@@ -1467,12 +1467,12 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,if (IS_ERR (gpd_data))return PTR_ERR (gpd_data); -genpd_lock (genpd); - ret = genpd->attach_dev ? genpd->attach_dev (genpd, dev) :0 ;if (ret) goto out; +genpd_lock (genpd); +dev_pm_domain_set (dev, &genpd->domain); genpd->device_count++;
@@ -1480,9 +1480,8 @@ static int genpd_add_device(struct generic_pm_domain *genpd, struct device *dev,list_add_tail (&gpd_data->base.list_node, &genpd->dev_list); - out:genpd_unlock (genpd); - + out:if (ret)genpd_free_dev_data (dev, gpd_data);else
@@ -1531,15 +1530,15 @@ static int genpd_remove_device(struct generic_pm_domain *genpd, genpd->device_count--; genpd->max_off_time_changed = true; -if (genpd->detach_dev) - genpd->detach_dev (genpd, dev); -dev_pm_domain_set (dev,NULL );list_del_init (&pdd->list_node);genpd_unlock (genpd); +if (genpd->detach_dev) + genpd->detach_dev (genpd, dev); +genpd_free_dev_data (dev, gpd_data);return 0 ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 51/67 blk-iolatency: #include "blk.h"
In reply to Sasha LevinFrom: Bart Van Assche <[email protected]>
[ Upstream commit 373e915cd8e84544609eced57a44fbc084f8d60f ]
This patch avoids that the following warning is reported when building with W=1:
block/blk-iolatency.c:734:5: warning: no previous prototype for 'blk_iolatency_init' [-Wmissing-prototypes]
--- block/blk-iolatency.c | 1 + 1 file changed, 1 insertion(+)
block/blk-iolatency.c +1 -0
@@ -75,6 +75,7 @@#include <linux/blk-mq.h> #include "blk-rq-qos.h" #include "blk-stat.h" +#include "blk.h" #define DEFAULT_SCALE_COOKIE 1000000U
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 52/67 drm/exynos/mixer: fix MIXER shadow registry synchronisation code
In reply to Sasha LevinFrom: Andrzej Hajda <[email protected]>
[ Upstream commit 6a3b45ada960ac475ec2b4103d43e57943b2b8d3 ]
MIXER on Exynos5 SoCs uses different synchronisation method than Exynos4 to update internal state (shadow registers).
Apparently the driver implements it incorrectly. The rule should be as follows:
- do not request updating registers until previous request was finished, ie. MXR_CFG_LAYER_UPDATE_COUNT must be 0.
- before setting registers synchronisation on VSYNC should be turned off, ie. MXR_STATUS_SYNC_ENABLE should be reset,
- after finishing MXR_STATUS_SYNC_ENABLE should be set again. The patch hopefully implements it correctly.
Below sample kernel log from page fault caused by the bug:
[ 25.670038] exynos-sysmmu 14650000.sysmmu: 14450000.mixer: PAGE FAULT occurred at 0x2247b800 [ 25.677888] ------------[ cut here ]------------ [ 25.682164] kernel BUG at ../drivers/iommu/exynos-iommu.c:450! [ 25.687971] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM [ 25.693778] Modules linked in: [ 25.696816] CPU: 5 PID: 1553 Comm: fb-release_test Not tainted 5.0.0-rc7-01157-g5f86b1566bdd #136 [ 25.705646] Hardware name: SAMSUNG EXYNOS (Flattened Device Tree) [ 25.711710] PC is at exynos_sysmmu_irq+0x1c0/0x264 [ 25.716470] LR is at lock_is_held_type+0x44/0x64
v2: added missing MXR_CFG_LAYER_UPDATE bit setting in mixer_enable_sync
--- drivers/gpu/drm/exynos/exynos_mixer.c | 110 +++++++++++++++----------- 1 file changed, 66 insertions(+), 44 deletions(-)
drivers/gpu/drm/exynos/exynos_mixer.c +66 -44
@@ -20,6 +20,7 @@#include "regs-vp.h" #include <linux/kernel.h> +#include <linux/ktime.h> #include <linux/spinlock.h> #include <linux/wait.h> #include <linux/i2c.h>
@@ -352,15 +353,62 @@ static void mixer_cfg_vp_blend(struct mixer_context *ctx, unsigned int alpha)mixer_reg_write (ctx,MXR_VIDEO_CFG , val); } -static void mixer_vsync_set_update (struct mixer_context *ctx,bool enable) +static bool mixer_is_synced (struct mixer_context *ctx) { -/* block update on vsync */ -mixer_reg_writemask (ctx,MXR_STATUS , enable ? -MXR_STATUS_SYNC_ENABLE :0 ,MXR_STATUS_SYNC_ENABLE ); +u32 base, shadow; +if (ctx->mxr_ver ==MXR_VER_16_0_33_0 || + ctx->mxr_ver ==MXR_VER_128_0_0_184 ) +return !(mixer_reg_read (ctx,MXR_CFG ) & +MXR_CFG_LAYER_UPDATE_COUNT_MASK ); + +if (test_bit (MXR_BIT_VP_ENABLED , &ctx->flags) && +vp_reg_read (ctx,VP_SHADOW_UPDATE )) +return false; + + base =mixer_reg_read (ctx,MXR_CFG ); + shadow =mixer_reg_read (ctx,MXR_CFG_S ); +if (base != shadow) +return false; + + base =mixer_reg_read (ctx,MXR_GRAPHIC_BASE (0 )); + shadow =mixer_reg_read (ctx,MXR_GRAPHIC_BASE_S (0 )); +if (base != shadow) +return false; + + base =mixer_reg_read (ctx,MXR_GRAPHIC_BASE (1 )); + shadow =mixer_reg_read (ctx,MXR_GRAPHIC_BASE_S (1 )); +if (base != shadow) +return false; + +return true; +} + +static int mixer_wait_for_sync (struct mixer_context *ctx) +{ +ktime_t timeout =ktime_add_us (ktime_get (),100000 ); + +while (!mixer_is_synced (ctx)) { +usleep_range (1000 ,2000 ); +if (ktime_compare (ktime_get (), timeout) >0 ) +return -ETIMEDOUT ; + } +return 0 ; +} + +static void mixer_disable_sync (struct mixer_context *ctx) +{ +mixer_reg_writemask (ctx,MXR_STATUS ,0 ,MXR_STATUS_SYNC_ENABLE ); +} + +static void mixer_enable_sync (struct mixer_context *ctx) +{ +if (ctx->mxr_ver ==MXR_VER_16_0_33_0 || + ctx->mxr_ver ==MXR_VER_128_0_0_184 ) +mixer_reg_writemask (ctx,MXR_CFG , ~0 ,MXR_CFG_LAYER_UPDATE ); +mixer_reg_writemask (ctx,MXR_STATUS , ~0 ,MXR_STATUS_SYNC_ENABLE );if (test_bit (MXR_BIT_VP_ENABLED , &ctx->flags)) -vp_reg_write (ctx,VP_SHADOW_UPDATE , enable ? -VP_SHADOW_UPDATE_ENABLE :0 ); +vp_reg_write (ctx,VP_SHADOW_UPDATE ,VP_SHADOW_UPDATE_ENABLE ); }static void mixer_cfg_scan (struct mixer_context *ctx,int width,int height)
@@ -498,7 +546,6 @@ static void vp_video_buffer(struct mixer_context *ctx,spin_lock_irqsave (&ctx->reg_slock, flags); -vp_reg_write (ctx,VP_SHADOW_UPDATE ,1 );/* interlace or progressive scan mode */ val = (test_bit (MXR_BIT_INTERLACE , &ctx->flags) ? ~0 :0 );vp_reg_writemask (ctx,VP_MODE , val,VP_MODE_LINE_SKIP );
@@ -553,11 +600,6 @@ static void vp_video_buffer(struct mixer_context *ctx,vp_regs_dump (ctx); } -static void mixer_layer_update (struct mixer_context *ctx) -{ -mixer_reg_writemask (ctx,MXR_CFG , ~0 ,MXR_CFG_LAYER_UPDATE ); -} -static void mixer_graph_buffer (struct mixer_context *ctx,struct exynos_drm_plane *plane) {
@@ -640,11 +682,6 @@ static void mixer_graph_buffer(struct mixer_context *ctx,mixer_cfg_layer (ctx, win, priority, true);mixer_cfg_gfx_blend (ctx, win, pixel_alpha, state->base.alpha); -/* layer update mandatory for mixer 16.0.33.0 */ -if (ctx->mxr_ver ==MXR_VER_16_0_33_0 || - ctx->mxr_ver ==MXR_VER_128_0_0_184 ) -mixer_layer_update (ctx); -spin_unlock_irqrestore (&ctx->reg_slock, flags);mixer_regs_dump (ctx);
@@ -709,7 +746,7 @@ static void mixer_win_reset(struct mixer_context *ctx)static irqreturn_t mixer_irq_handler (int irq,void *arg) {struct mixer_context *ctx = arg; -u32 val, base, shadow; +u32 val;spin_lock (&ctx->reg_slock);
@@ -723,26 +760,9 @@ static irqreturn_t mixer_irq_handler(int irq, void *arg) val &= ~MXR_INT_STATUS_VSYNC ;/* interlace scan need to check shadow register */ -if (test_bit (MXR_BIT_INTERLACE , &ctx->flags)) { -if (test_bit (MXR_BIT_VP_ENABLED , &ctx->flags) && -vp_reg_read (ctx,VP_SHADOW_UPDATE )) - goto out; - - base =mixer_reg_read (ctx,MXR_CFG ); - shadow =mixer_reg_read (ctx,MXR_CFG_S ); -if (base != shadow) - goto out; - - base =mixer_reg_read (ctx,MXR_GRAPHIC_BASE (0 )); - shadow =mixer_reg_read (ctx,MXR_GRAPHIC_BASE_S (0 )); -if (base != shadow) - goto out; - - base =mixer_reg_read (ctx,MXR_GRAPHIC_BASE (1 )); - shadow =mixer_reg_read (ctx,MXR_GRAPHIC_BASE_S (1 )); -if (base != shadow) - goto out; - } +if (test_bit (MXR_BIT_INTERLACE , &ctx->flags) + && !mixer_is_synced (ctx)) + goto out;drm_crtc_handle_vblank (&ctx->crtc->base); }
@@ -917,12 +937,14 @@ static void mixer_disable_vblank(struct exynos_drm_crtc *crtc)static void mixer_atomic_begin (struct exynos_drm_crtc *crtc) { -struct mixer_context *mixer_ctx = crtc->ctx; +struct mixer_context *ctx = crtc->ctx; -if (!test_bit (MXR_BIT_POWERED , &mixer_ctx->flags)) +if (!test_bit (MXR_BIT_POWERED , &ctx->flags))return ; -mixer_vsync_set_update (mixer_ctx, false); +if (mixer_wait_for_sync (ctx)) +dev_err (ctx->dev,"timeout waiting for VSYNC\n" ); +mixer_disable_sync (ctx); } static void mixer_update_plane(struct exynos_drm_crtc *crtc,
@@ -964,7 +986,7 @@ static void mixer_atomic_flush(struct exynos_drm_crtc *crtc)if (!test_bit (MXR_BIT_POWERED , &mixer_ctx->flags))return ; -mixer_vsync_set_update (mixer_ctx, true); +mixer_enable_sync (mixer_ctx);exynos_crtc_handle_event (crtc); }
@@ -979,7 +1001,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc)exynos_drm_pipe_clk_enable (crtc, true); -mixer_vsync_set_update (ctx, false); +mixer_disable_sync (ctx);mixer_reg_writemask (ctx,MXR_STATUS , ~0 ,MXR_STATUS_SOFT_RESET );
@@ -992,7 +1014,7 @@ static void mixer_enable(struct exynos_drm_crtc *crtc)mixer_commit (ctx); -mixer_vsync_set_update (ctx, true); +mixer_enable_sync (ctx);set_bit (MXR_BIT_POWERED , &ctx->flags); }
Signature · 6 lines
2.19.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Sasha Levin
maintainerPATCH 53/67 irqchip/stm32: Don't clear rising/falling config registers at init
In reply to Sasha LevinFrom: Fabien Dessenne <[email protected]>
[ Upstream commit 0dda09666f50eae9c5b794dd89b1fd8a8d89d714 ]
Falling and rising configuration and status registers are not banked. As they are shared with M4 co-processor, they should not be cleared at probe time, else M4 co-processor configuration will be lost.
--- drivers/irqchip/irq-stm32-exti.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/irqchip/irq-stm32-exti.c +0 -5
@@ -735,11 +735,6 @@ stm32_exti_chip_data *stm32_exti_chip_init(struct stm32_exti_host_data *h_data,*/ writel_relaxed (0 , base + stm32_bank->imr_ofst);writel_relaxed (0 , base + stm32_bank->emr_ofst); -writel_relaxed (0 , base + stm32_bank->rtsr_ofst); -writel_relaxed (0 , base + stm32_bank->ftsr_ofst); -writel_relaxed (~0UL , base + stm32_bank->rpr_ofst); -if (stm32_bank->fpr_ofst !=UNDEF_REG ) -writel_relaxed (~0UL , base + stm32_bank->fpr_ofst);pr_info ("%pOF: bank%d\n" , h_data->node, bank_idx);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 54/67 irqchip/stm32: Don't set rising configuration registers at init
In reply to Sasha LevinFrom: Fabien Dessenne <[email protected]>
[ Upstream commit 6a77623d78b307b34d4cf7886da6a907689bf388 ]
The rising configuration status register (rtsr) is not banked. As it is shared with the co-processor, it should not be written at probe time, else the co-processor configuration will be lost.
--- drivers/irqchip/irq-stm32-exti.c | 5 ----- 1 file changed, 5 deletions(-)
drivers/irqchip/irq-stm32-exti.c +0 -5
@@ -716,7 +716,6 @@ stm32_exti_chip_data *stm32_exti_chip_init(struct stm32_exti_host_data *h_data,const struct stm32_exti_bank *stm32_bank;struct stm32_exti_chip_data *chip_data;void __iomem *base = h_data->base; -u32 irqs_mask; stm32_bank = h_data->drv_data->exti_banks[bank_idx]; chip_data = &h_data->chips_data[bank_idx];
@@ -725,10 +724,6 @@ stm32_exti_chip_data *stm32_exti_chip_init(struct stm32_exti_host_data *h_data,raw_spin_lock_init (&chip_data->rlock); -/* Determine number of irqs supported */ -writel_relaxed (~0UL , base + stm32_bank->rtsr_ofst); - irqs_mask =readl_relaxed (base + stm32_bank->rtsr_ofst); -/* * This IP has no reset, so after hot reboot we should * clear registers to avoid residue
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 55/67 irqchip/mbigen: Don't clear eventid when freeing an MSI
In reply to Sasha LevinFrom: Jianguo Chen <[email protected]>
[ Upstream commit fca269f201a8d9985c0a31fb60b15d4eb57cef80 ]
mbigen_write_msg clears eventid bits of a mbigen register when free a interrupt, because msi_domain_deactivate memset struct msg to zero. Then multiple mbigen pins with zero eventid will report the same interrupt number.
The eventid clear call trace:
free_irq
__free_irq
irq_shutdown
irq_domain_deactivate_irq
__irq_domain_deactivate_irq
__irq_domain_deactivate_irq
msi_domain_deactivate
platform_msi_write_msg
mbigen_write_msg--- drivers/irqchip/irq-mbigen.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/irqchip/irq-mbigen.c +3 -0
@@ -161,6 +161,9 @@ static void mbigen_write_msg(struct msi_desc *desc, struct msi_msg *msg)void __iomem *base = d->chip_data;u32 val; +if (!msg->address_lo && !msg->address_hi) +return ; + base +=get_mbigen_vec_reg (d->hwirq); val =readl_relaxed (base);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 56/67 x86/hpet: Prevent potential NULL pointer dereference
In reply to Sasha LevinFrom: Aditya Pakki <[email protected]>
[ Upstream commit 2e84f116afca3719c9d0a1a78b47b48f75fd5724 ]
hpet_virt_address may be NULL when ioremap_nocache fail, but the code lacks a check.
Add a check to prevent NULL pointer dereference.
--- arch/x86/kernel/hpet.c | 2 ++ 1 file changed, 2 insertions(+)
arch/x86/kernel/hpet.c +2 -0
@@ -905,6 +905,8 @@ int __init hpet_enable(void)return 0 ;hpet_set_mapping (); +if (!hpet_virt_address) +return 0 ;/* * Read the period and check for a sane value:
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 57/67 x86/hyperv: Prevent potential NULL pointer dereference
In reply to Sasha LevinFrom: Kangjie Lu <[email protected]>
[ Upstream commit 534c89c22e26b183d838294f0937ee092c82ad3a ]
The page allocation in hv_cpu_init() can fail, but the code does not have a check for that.
Add a check and return -ENOMEM when the allocation fails.
[ tglx: Massaged changelog ]
--- arch/x86/hyperv/hv_init.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
arch/x86/hyperv/hv_init.c +5 -1
@@ -102,9 +102,13 @@ static int hv_cpu_init(unsigned int cpu)u64 msr_vp_index;struct hv_vp_assist_page **hvp = &hv_vp_assist_page[smp_processor_id ()];void **input_arg; +struct page *pg; input_arg = (void **)this_cpu_ptr (hyperv_pcpu_input_arg); - *input_arg =page_address (alloc_page (GFP_KERNEL )); + pg =alloc_page (GFP_KERNEL ); +if (unlikely (!pg)) +return -ENOMEM ; + *input_arg =page_address (pg);hv_get_vp_index (msr_vp_index);
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 58/67 x86/cpu/cyrix: Use correct macros for Cyrix calls on Geode processors
In reply to Sasha LevinFrom: Matthew Whitehead <[email protected]>
[ Upstream commit 18fb053f9b827bd98cfc64f2a35df8ab19745a1d ]
There are comments in processor-cyrix.h advising you to _not_ make calls using the deprecated macros in this style:
setCx86_old(CX86_CCR4, getCx86_old(CX86_CCR4) | 0x80);
This is because it expands the macro into a non-functioning calling sequence. The calling order must be:
outb(CX86_CCR2, 0x22); inb(0x23);
From the comments:
* When using the old macros a line like
* setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88);
* gets expanded to:
* do {
* outb((CX86_CCR2), 0x22);
* outb((({
* outb((CX86_CCR2), 0x22);
* inb(0x23);
* }) | 0x88), 0x23);
* } while (0);
The new macros fix this problem, so use them instead. Tested on an actual Geode processor.
--- arch/x86/kernel/cpu/cyrix.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
arch/x86/kernel/cpu/cyrix.c +7 -7
@@ -124,7 +124,7 @@ static void set_cx86_reorder(void)setCx86 (CX86_CCR3 , (ccr3 &0x0f ) |0x10 );/* enable MAPEN */ /* Load/Store Serialize to mem access disable (=reorder it) */ -setCx86_old (CX86_PCR0 ,getCx86_old (CX86_PCR0 ) & ~0x80 ); +setCx86 (CX86_PCR0 ,getCx86 (CX86_PCR0 ) & ~0x80 );/* set load/store serialize from 1GB to 4GB */ ccr3 |=0xe0 ;setCx86 (CX86_CCR3 , ccr3);
@@ -135,11 +135,11 @@ static void set_cx86_memwb(void)pr_info ("Enable Memory-Write-back mode on Cyrix/NSC processor.\n" );/* CCR2 bit 2: unlock NW bit */ -setCx86_old (CX86_CCR2 ,getCx86_old (CX86_CCR2 ) & ~0x04 ); +setCx86 (CX86_CCR2 ,getCx86 (CX86_CCR2 ) & ~0x04 );/* set 'Not Write-through' */ write_cr0 (read_cr0 () |X86_CR0_NW );/* CCR2 bit 2: lock NW bit and set WT1 */ -setCx86_old (CX86_CCR2 ,getCx86_old (CX86_CCR2 ) |0x14 ); +setCx86 (CX86_CCR2 ,getCx86 (CX86_CCR2 ) |0x14 ); }/*
@@ -153,14 +153,14 @@ static void geode_configure(void)local_irq_save (flags);/* Suspend on halt power saving and enable #SUSP pin */ -setCx86_old (CX86_CCR2 ,getCx86_old (CX86_CCR2 ) |0x88 ); +setCx86 (CX86_CCR2 ,getCx86 (CX86_CCR2 ) |0x88 ); ccr3 =getCx86 (CX86_CCR3 );setCx86 (CX86_CCR3 , (ccr3 &0x0f ) |0x10 );/* enable MAPEN */ /* FPU fast, DTE cache, Mem bypass */ -setCx86_old (CX86_CCR4 ,getCx86_old (CX86_CCR4 ) |0x38 ); +setCx86 (CX86_CCR4 ,getCx86 (CX86_CCR4 ) |0x38 );setCx86 (CX86_CCR3 , ccr3);/* disable MAPEN */ set_cx86_memwb ();
@@ -296,7 +296,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)/* GXm supports extended cpuid levels 'ala' AMD */ if (c->cpuid_level ==2 ) {/* Enable cxMMX extensions (GX1 Datasheet 54) */ -setCx86_old (CX86_CCR7 ,getCx86_old (CX86_CCR7 ) |1 ); +setCx86 (CX86_CCR7 ,getCx86 (CX86_CCR7 ) |1 );/* * GXm : 0x30 ... 0x5f GXm datasheet 51
@@ -319,7 +319,7 @@ static void init_cyrix(struct cpuinfo_x86 *c)if (dir1 >7 ) { dir0_msn++;/* M II */ /* Enable MMX extensions (App note 108) */ -setCx86_old (CX86_CCR7 ,getCx86_old (CX86_CCR7 )|1 ); +setCx86 (CX86_CCR7 ,getCx86 (CX86_CCR7 )|1 ); }else {/* A 6x86MX - it has the bug. */ set_cpu_bug (c,X86_BUG_COMA );
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 59/67 drm/nouveau/debugfs: Fix check of pm_runtime_get_sync failure
In reply to Sasha LevinFrom: YueHaibing <[email protected]>
[ Upstream commit 909e9c9c428376e2a43d178ed4b0a2d5ba9cb7d3 ]
pm_runtime_get_sync returns negative on failure.
--- drivers/gpu/drm/nouveau/nouveau_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/nouveau/nouveau_debugfs.c +1 -1
@@ -181,7 +181,7 @@ nouveau_debugfs_pstate_set(struct file *file, const char __user *ubuf, } ret =pm_runtime_get_sync (drm->dev); -if (IS_ERR_VALUE (ret) && ret != -EACCES ) +if (ret <0 && ret != -EACCES )return ret; ret =nvif_mthd (ctrl,NVIF_CONTROL_PSTATE_USER , &args,sizeof (args));pm_runtime_put_autosuspend (drm->dev);
Signature · 6 lines
2.19.1 _______________________________________________ Nouveau mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/nouveau
Sasha Levin
maintainerPATCH 60/67 iommu/vt-d: Check capability before disabling protected memory
In reply to Sasha LevinFrom: Lu Baolu <baolu.lu-VuQAYsv1563Yd54FQh9/[email protected]>
[ Upstream commit 5bb71fc790a88d063507dc5d445ab8b14e845591 ]
The spec states in 10.4.16 that the Protected Memory Enable Register should be treated as read-only for implementations not supporting protected memory regions (PLMR and PHMR fields reported as Clear in the Capability register).
--- drivers/iommu/intel-iommu.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iommu/intel-iommu.c +3 -0
@@ -1534,6 +1534,9 @@ static void iommu_disable_protect_mem_regions(struct intel_iommu *iommu)u32 pmen;unsigned long flags; +if (!cap_plmr (iommu->cap) && !cap_phmr (iommu->cap)) +return ; +raw_spin_lock_irqsave (&iommu->register_lock, flags); pmen =readl (iommu->reg +DMAR_PMEN_REG ); pmen &= ~DMA_PMEN_EPM ;
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 61/67 iommu/vt-d: Save the right domain ID used by hardware
In reply to Sasha LevinFrom: Lu Baolu <[email protected]>
[ Upstream commit 84c11e4df5aa4955acaa441f0cf1cb2e50daf64b ]
The driver sets a default domain id (FLPT_DEFAULT_DID) in the first level only pasid entry, but saves a different domain id in @sdev->did. The value saved in @sdev->did will be used to invalidate the translation caches. Hence, the driver might result in invalidating the caches with a wrong domain id.
--- drivers/iommu/intel-iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel-iommu.c +1 -1
@@ -5330,7 +5330,7 @@ int intel_iommu_enable_pasid(struct intel_iommu *iommu, struct intel_svm_dev *sd ctx_lo = context[0 ].lo; - sdev->did = domain->iommu_did[iommu->seq_id]; + sdev->did =FLPT_DEFAULT_DID ; sdev->sid =PCI_DEVID (info->bus, info->devfn);if (!(ctx_lo &CONTEXT_PASIDE )) {
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 62/67 x86/hw_breakpoints: Make default case in hw_breakpoint_arch_parse() return an error
In reply to Sasha LevinFrom: Nathan Chancellor <[email protected]>
[ Upstream commit e898e69d6b9475bf123f99b3c5d1a67bb7cb2361 ]
When building with -Wsometimes-uninitialized, Clang warns:
arch/x86/kernel/hw_breakpoint.c:355:2: warning: variable 'align' is used uninitialized whenever switch default is taken [-Wsometimes-uninitialized]
The default cannot be reached because arch_build_bp_info() initializes hw->len to one of the specified cases. Nevertheless the warning is valid and returning -EINVAL makes sure that this cannot be broken by future modifications.
--- arch/x86/kernel/hw_breakpoint.c | 1 + 1 file changed, 1 insertion(+)
arch/x86/kernel/hw_breakpoint.c +1 -0
@@ -357,6 +357,7 @@ int hw_breakpoint_arch_parse(struct perf_event *bp,#endif default :WARN_ON_ONCE (1 ); +return -EINVAL ; }/*
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 63/67 cifs: fix that return -EINVAL when do dedupe operation
In reply to Sasha LevinFrom: Xiaoli Feng <[email protected]>
[ Upstream commit b073a08016a10f01dfb0d0b6c7fa89da0d544963 ]
dedupe_file_range operations is combiled into remap_file_range. But it's always skipped for dedupe operations in function cifs_remap_file_range.
Example to test:
Before this patch:
# dd if=/dev/zero of=cifs/file bs=1M count=1 # xfs_io -c "dedupe cifs/file 4k 64k 4k" cifs/file XFS_IOC_FILE_EXTENT_SAME: Invalid argument
After this patch:
# dd if=/dev/zero of=cifs/file bs=1M count=1 # xfs_io -c "dedupe cifs/file 4k 64k 4k" cifs/file XFS_IOC_FILE_EXTENT_SAME: Operation not supported
Influence for xfstests:
generic/091
generic/112
generic/127
generic/263
These tests report this error "do_copy_range:: Invalid argument" instead of "FIDEDUPERANGE: Invalid argument". Because there are still two bugs cause these test failed.
https://bugzilla.kernel.org/show_bug.cgi?id=202935
https://bugzilla.kernel.org/show_bug.cgi?id=202785
--- fs/cifs/cifsfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/cifsfs.c +1 -1
@@ -1008,7 +1008,7 @@ static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,unsigned int xid;int rc; -if (remap_flags & ~REMAP_FILE_ADVISORY ) +if (remap_flags & ~(REMAP_FILE_DEDUP |REMAP_FILE_ADVISORY ))return -EINVAL ;cifs_dbg (FYI ,"clone range\n" );
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 64/67 fix incorrect error code mapping for OBJECTID_NOT_FOUND
In reply to Sasha LevinFrom: Steve French <[email protected]>
[ Upstream commit 85f9987b236cf46e06ffdb5c225cf1f3c0acb789 ]
It was mapped to EIO which can be confusing when user space queries for an object GUID for an object for which the server file system doesn't support (or hasn't saved one).
As Amir Goldstein suggested this is similar to ENOATTR (equivalently ENODATA in Linux errno definitions) so changing NT STATUS code mapping for OBJECTID_NOT_FOUND to ENODATA.
--- fs/cifs/smb2maperror.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
fs/cifs/smb2maperror.c +2 -1
@@ -1036,7 +1036,8 @@ static const struct status_to_posix_error smb2_error_map_table[] = { {STATUS_UNFINISHED_CONTEXT_DELETED , -EIO , "STATUS_UNFINISHED_CONTEXT_DELETED"}, {STATUS_NO_TGT_REPLY, -EIO, "STATUS_NO_TGT_REPLY"}, - {STATUS_OBJECTID_NOT_FOUND, -EIO, "STATUS_OBJECTID_NOT_FOUND"}, +/* Note that ENOATTTR and ENODATA are the same errno */ + {STATUS_OBJECTID_NOT_FOUND, -ENODATA, "STATUS_OBJECTID_NOT_FOUND"}, {STATUS_NO_IP_ADDRESSES, -EIO, "STATUS_NO_IP_ADDRESSES"}, {STATUS_WRONG_CREDENTIAL_HANDLE, -EIO, "STATUS_WRONG_CREDENTIAL_HANDLE"},
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 65/67 cifs: Fix slab-out-of-bounds when tracing SMB tcon
In reply to Sasha LevinFrom: "Paulo Alcantara (SUSE)" <[email protected]>
[ Upstream commit 68ddb496800acdb46172b4981dc3753ea9b39c25 ]
This patch fixes the following KASAN report:
[ 779.044746] BUG: KASAN: slab-out-of-bounds in string+0xab/0x180 [ 779.044750] Read of size 1 at addr ffff88814f327968 by task trace-cmd/2812
[ 779.044756] CPU: 1 PID: 2812 Comm: trace-cmd Not tainted 5.1.0-rc1+ #62 [ 779.044760] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.12.0-0-ga698c89-prebuilt.qemu.org 04/01/2014 [ 779.044761] Call Trace: [ 779.044769] dump_stack+0x5b/0x90 [ 779.044775] ? string+0xab/0x180 [ 779.044781] print_address_description+0x6c/0x23c [ 779.044787] ? string+0xab/0x180 [ 779.044792] ? string+0xab/0x180 [ 779.044797] kasan_report.cold.3+0x1a/0x32 [ 779.044803] ? string+0xab/0x180 [ 779.044809] string+0xab/0x180 [ 779.044816] ? widen_string+0x160/0x160 [ 779.044822] ? vsnprintf+0x5bf/0x7f0 [ 779.044829] vsnprintf+0x4e7/0x7f0 [ 779.044836] ? pointer+0x4a0/0x4a0 [ 779.044841] ? seq_buf_vprintf+0x79/0xc0 [ 779.044848] seq_buf_vprintf+0x62/0xc0 [ 779.044855] trace_seq_printf+0x113/0x210 [ 779.044861] ? trace_seq_puts+0x110/0x110 [ 779.044867] ? trace_raw_output_prep+0xd8/0x110 [ 779.044876] trace_raw_output_smb3_tcon_class+0x9f/0xc0 [ 779.044882] print_trace_line+0x377/0x890 [ 779.044888] ? tracing_buffers_read+0x300/0x300 [ 779.044893] ? ring_buffer_read+0x58/0x70 [ 779.044899] s_show+0x6e/0x140 [ 779.044906] seq_read+0x505/0x6a0 [ 779.044913] vfs_read+0xaf/0x1b0 [ 779.044919] ksys_read+0xa1/0x130 [ 779.044925] ? kernel_write+0xa0/0xa0 [ 779.044931] ? __do_page_fault+0x3d5/0x620 [ 779.044938] do_syscall_64+0x63/0x150 [ 779.044944] entry_SYSCALL_64_after_hwframe+0x44/0xa9 [ 779.044949] RIP: 0033:0x7f62c2c2db31 [ 779.044955] Code: fe ff ff 48 8d 3d 17 9e 09 00 48 83 ec 08 e8 96 02 02 00 66 0f 1f 44 00 00 8b 05 fa fc 2c 00 48 63 ff 85 c0 75 13 31 c0 0f 05 <48> 3d 00 f0 ff ff 77 57 f3 c3 0f 1f 44 00 00 55 53 48 89 d5 48 89 [ 779.044958] RSP: 002b:00007ffd6e116678 EFLAGS: 00000246 ORIG_RAX: 0000000000000000 [ 779.044964] RAX: ffffffffffffffda RBX: 0000560a38be9260 RCX: 00007f62c2c2db31 [ 779.044966] RDX: 0000000000002000 RSI: 00007ffd6e116710 RDI: 0000000000000003 [ 779.044966] RDX: 0000000000002000 RSI: 00007ffd6e116710 RDI: 0000000000000003 [ 779.044969] RBP: 00007f62c2ef5420 R08: 0000000000000000 R09: 0000000000000003 [ 779.044972] R10: ffffffffffffffa8 R11: 0000000000000246 R12: 00007ffd6e116710 [ 779.044975] R13: 0000000000002000 R14: 0000000000000d68 R15: 0000000000002000
[ 779.044981] Allocated by task 1257: [ 779.044987] __kasan_kmalloc.constprop.5+0xc1/0xd0 [ 779.044992] kmem_cache_alloc+0xad/0x1a0 [ 779.044997] getname_flags+0x6c/0x2a0 [ 779.045003] user_path_at_empty+0x1d/0x40 [ 779.045008] do_faccessat+0x12a/0x330 [ 779.045012] do_syscall_64+0x63/0x150 [ 779.045017] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 779.045019] Freed by task 1257: [ 779.045023] __kasan_slab_free+0x12e/0x180 [ 779.045029] kmem_cache_free+0x85/0x1b0 [ 779.045034] filename_lookup.part.70+0x176/0x250 [ 779.045039] do_faccessat+0x12a/0x330 [ 779.045043] do_syscall_64+0x63/0x150 [ 779.045048] entry_SYSCALL_64_after_hwframe+0x44/0xa9
[ 779.045052] The buggy address belongs to the object at ffff88814f326600 which belongs to the cache names_cache of size 4096 [ 779.045057] The buggy address is located 872 bytes to the right of 4096-byte region [ffff88814f326600, ffff88814f327600) [ 779.045058] The buggy address belongs to the page: [ 779.045062] page:ffffea00053cc800 count:1 mapcount:0 mapping:ffff88815b191b40 index:0x0 compound_mapcount: 0 [ 779.045067] flags: 0x200000000010200(slab|head) [ 779.045075] raw: 0200000000010200 dead000000000100 dead000000000200 ffff88815b191b40 [ 779.045081] raw: 0000000000000000 0000000000070007 00000001ffffffff 0000000000000000 [ 779.045083] page dumped because: kasan: bad access detected
[ 779.045085] Memory state around the buggy address: [ 779.045089] ffff88814f327800: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 779.045093] ffff88814f327880: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 779.045097] >ffff88814f327900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 779.045099] ^ [ 779.045103] ffff88814f327980: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 779.045107] ffff88814f327a00: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc [ 779.045109] ================================================================== [ 779.045110] Disabling lock debugging due to kernel taint
Correctly assign tree name str for smb3_tcon event.
--- fs/cifs/trace.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
fs/cifs/trace.h +3 -3
@@ -378,19 +378,19 @@ DECLARE_EVENT_CLASS(smb3_tcon_class, __field(unsigned int, xid) __field(__u32, tid) __field(__u64, sesid) - __field(const char *, unc_name) + __string(name, unc_name) __field(int, rc) ),TP_fast_assign ( __entry->xid = xid; __entry->tid = tid; __entry->sesid = sesid; - __entry->unc_name = unc_name; +__assign_str (name, unc_name); __entry->rc = rc; ), TP_printk("xid=%u sid=0x%llx tid=0x%x unc_name=%s rc=%d", __entry->xid, __entry->sesid, __entry->tid, - __entry->unc_name, __entry->rc) + __get_str(name), __entry->rc) )#define DEFINE_SMB3_TCON_EVENT (name) \
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 66/67 x86/gart: Exclude GART aperture from kcore
In reply to Sasha LevinFrom: Kairui Song <[email protected]>
[ Upstream commit ffc8599aa9763f39f6736a79da4d1575e7006f9a ]
On machines where the GART aperture is mapped over physical RAM, /proc/kcore contains the GART aperture range. Accessing the GART range via /proc/kcore results in a kernel crash.
vmcore used to have the same issue, until it was fixed with commit 2a3e83c6f96c ("x86/gart: Exclude GART aperture from vmcore")', leveraging existing hook infrastructure in vmcore to let /proc/vmcore return zeroes when attempting to read the aperture region, and so it won't read from the actual memory.
Apply the same workaround for kcore. First implement the same hook infrastructure for kcore, then reuse the hook functions introduced in the previous vmcore fix. Just with some minor adjustment, rename some functions for more general usage, and simplify the hook infrastructure a bit as there is no module usage yet.
--- arch/x86/kernel/aperture_64.c | 20 +++++++++++++------- fs/proc/kcore.c | 27 +++++++++++++++++++++++++++ include/linux/kcore.h | 2 ++ 3 files changed, 42 insertions(+), 7 deletions(-)
arch/x86/kernel/aperture_64.c +13 -7
@@ -14,6 +14,7 @@#define pr_fmt (fmt) "AGP: " fmt#include <linux/kernel.h> +#include <linux/kcore.h> #include <linux/types.h> #include <linux/init.h> #include <linux/memblock.h>
@@ -57,7 +58,7 @@ int fallback_aper_force __initdata;int fix_aperture__initdata =1 ; -#ifdef CONFIG_PROC_VMCORE +#if defined(CONFIG_PROC_VMCORE ) || defined(CONFIG_PROC_KCORE )/* * If the first kernel maps the aperture over e820 RAM, the kdump kernel will * use the same range because it will remain configured in the northbridge.
@@ -66,20 +67,25 @@ int fix_aperture __initdata = 1;*/ static unsigned long aperture_pfn_start, aperture_page_count; -static int gart_oldmem_pfn_is_ram (unsigned long pfn) +static int gart_mem_pfn_is_ram (unsigned long pfn) {return likely ((pfn < aperture_pfn_start) || (pfn >= aperture_pfn_start + aperture_page_count)); } -static void exclude_from_vmcore (u64 aper_base,u32 aper_order) +static void __init exclude_from_core (u64 aper_base,u32 aper_order) { aperture_pfn_start = aper_base >>PAGE_SHIFT ; aperture_page_count = (32 *1024 *1024 ) << aper_order >>PAGE_SHIFT ; -WARN_ON (register_oldmem_pfn_is_ram (&gart_oldmem_pfn_is_ram)); +#ifdef CONFIG_PROC_VMCORE +WARN_ON (register_oldmem_pfn_is_ram (&gart_mem_pfn_is_ram)); +#endif +#ifdef CONFIG_PROC_KCORE +WARN_ON (register_mem_pfn_is_ram (&gart_mem_pfn_is_ram)); +#endif }#else -static void exclude_from_vmcore (u64 aper_base,u32 aper_order) +static void exclude_from_core (u64 aper_base,u32 aper_order) { }#endif
@@ -474,7 +480,7 @@ out:* may have allocated the range over its e820 RAM * and fixed up the northbridge */ -exclude_from_vmcore (last_aper_base, last_aper_order); +exclude_from_core (last_aper_base, last_aper_order);return 1 ; }
@@ -520,7 +526,7 @@ out:* overlap with the first kernel's memory. We can't access the * range through vmcore even though it should be part of the dump. */ -exclude_from_vmcore (aper_alloc, aper_order); +exclude_from_core (aper_alloc, aper_order);/* Fix up the north bridges */ for (i =0 ; i < amd_nb_bus_dev_ranges[i].dev_limit; i++) {
fs/proc/kcore.c +27 -0
@@ -54,6 +54,28 @@ static LIST_HEAD(kclist_head);static DECLARE_RWSEM (kclist_lock);static int kcore_need_update =1 ; +/* +* Returns > 0 for RAM pages, 0 for non-RAM pages, < 0 on error +* Same as oldmem_pfn_is_ram in vmcore +*/ +static int (*mem_pfn_is_ram)(unsigned long pfn); + +int __init register_mem_pfn_is_ram (int (*fn)(unsigned long pfn)) +{ +if (mem_pfn_is_ram) +return -EBUSY ; + mem_pfn_is_ram = fn; +return 0 ; +} + +static int pfn_is_ram (unsigned long pfn) +{ +if (mem_pfn_is_ram) +return mem_pfn_is_ram (pfn); +else +return 1 ; +} +/* This doesn't grab kclist_lock, so it should only be used at init time. */ void __init kclist_add (struct kcore_list *new,void *addr,size_t size,int type)
@@ -465,6 +487,11 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) goto out; } m =NULL ;/* skip the list anchor */ + }else if (!pfn_is_ram (__pa (start) >>PAGE_SHIFT )) { +if (clear_user (buffer, tsz)) { + ret = -EFAULT ; + goto out; + } }else if (m->type ==KCORE_VMALLOC ) {vread (buf, (char *)start, tsz);/* we have to zero-fill user buffer even if no read */
include/linux/kcore.h +2 -0
@@ -44,6 +44,8 @@ void kclist_add_remap(struct kcore_list *m, void *addr, void *vaddr, size_t sz) m->vaddr = (unsigned long )vaddr; kclist_add(m, addr, sz, KCORE_REMAP); } + +extern int __init register_mem_pfn_is_ram (int (*fn)(unsigned long pfn));#else static inline void kclist_add (struct kcore_list *new,void *addr,size_t size,int type)
Signature · 1 line
2.19.1
Sasha Levin
maintainerPATCH 67/67 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
@@ -999,6 +999,13 @@ resizefs_out: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