Re: [patch 00/12] thermal/x86_pkg_temp: Sanitize yet another hotplug and locking trainwreck

From: Pandruvada, Srinivas
Date: Mon Nov 21 2016 - 15:02:20 EST


On Fri, 2016-11-18 at 00:03 +0000, Thomas Gleixner wrote:
> We solely intended to convert that driver to the hotplug state
> machine and
> stumbled over a large pile of insanities, which are all interwoven
> with the
> package management:

Thanks Thomas for fixes.
But I did a very simple test on 4.9.0-rc5 on a client machine, just
rmmod and read zone, it will cause crash. I have not tested on a multi-
socket system, which is also required where the real test of Âlast cpu
on a package goes offline can be tested.

$ uname -a
Linux xxx 4.9.0-rc5+ #47 SMP Mon Nov 21 11:30:56 PST 2016 x86_64 x86_64
x86_64 GNU/Linux

$ pwd
/sys/devices/virtual/thermal/thermal_zone8
$ cat typeÂ
x86_pkg_temp
$ cat tempÂ
43000
$ lsmod | grep x86
x86_pkg_temp_thermalÂÂÂÂ16384ÂÂ0
aes_x86_64ÂÂÂÂÂÂÂÂÂÂÂÂÂ20480ÂÂ1 aesni_intel
$ sudo rmmod x86_pkg_temp_thermal
$ cd ../thermal_zone8

Zone is not removed on rmmod!!!, so any read on zone will cause crash

$ ls
available_policiesÂÂk_dÂÂÂk_pu ÂÂpowerÂÂÂÂÂÂsustainable_power
trip_point_0_typeÂÂtype
emul_temp ÂÂÂÂk_iÂÂÂoffsetÂÂslopeÂÂÂÂÂÂtemp trip_
point_1_tempÂÂuevent
integral_cutoffÂÂÂÂÂk_poÂÂpolicyÂÂsubsystemÂÂtrip_point_0_temp t
rip_point_1_type
spandruvada@spandruv-mobl2:/sys/devices/virtual/thermal/thermal_zone8$
cat tempÂ
Killed
spandruvada@spandruv-mobl2:/sys/devices/virtual/thermal/thermal_zone8$Â




[ÂÂ116.726989] BUG: unable to handle kernel paging request at
ffffffffa07b8010
[ÂÂ116.727103] IP: [<ffffffff81677cdd>]
thermal_zone_get_temp+0x3d/0x100
[ÂÂ116.727192] PGD 2e0d067Â
[ÂÂ116.727224] PUD 2e0e063Â
[ÂÂ116.727259] PMD 14266c067Â
[ÂÂ116.727278] PTE 0

[ÂÂ116.727328] Oops: 0000 [#1] SMP
[ÂÂ116.727368] Modules linked in: rfcomm vmw_vsock_vmci_transport vsock
vmw_vmci asix usbnet mii binfmt_misc bnep hid_sensor_rotation
hid_sensor_als hid_sensor_incl_3d hid_sensor_accel_3d
hid_sensor_magn_3d hid_sensor_gyro_3d hid_sensor_trigger
hid_sensor_custom joydev hid_sensor_iio_common pn544_mei hid_rmi
mei_phy hid_multitouch pn544 hci hid_sensor_hub nfc intel_rapl
nls_iso8859_1 uvcvideo coretemp crct10dif_pclmul crc32_pclmul
ghash_clmulni_intel videobuf2_vmalloc videobuf2_memops aesni_intel
videobuf2_v4l2 option aes_x86_64 usb_wwan videobuf2_core lrw usbserial
gf128mul glue_helper ablk_helper videodev btusb cryptd btrtl btbcm
iwlwifi btintel serio_raw bluetooth intel_pch_thermal cfg80211
snd_hda_codec_hdmi snd_hda_codec_realtek snd_hda_codec_generic
snd_hda_intel battery snd_hda_codec snd_hda_core
[ÂÂ116.728433]ÂÂwinbond_cir int3403_thermal rc_core snd_hwdep
snd_seq_midi snd_pcm snd_seq_midi_event mac_hid snd_rawmidi dw_dmac
int3402_thermal snd_seq 8250_dw i2c_designware_platform snd_seq_device
spi_pxa2xx_platform i2c_designware_core snd_timer int3400_thermal
acpi_thermal_rel snd mei_me processor_thermal_device mei
int340x_thermal_zone lpc_ich intel_soc_dts_iosf soundcore nfsd
auth_rpcgss kvm_intel nfs_acl lockd kvm grace irqbypass sunrpc cuse
parport_pc ppdev lp parport autofs4 hid_generic usbhid i915
i2c_algo_bit drm_kms_helper syscopyarea sysfillrect sysimgblt
fb_sys_fops drm ahci libahci video i2c_hid hid sdhci_acpi sdhci [last
unloaded: x86_pkg_temp_thermal]
[ÂÂ116.729342] CPU: 1 PID: 2431 Comm: cat Not tainted 4.9.0-rc5+ #47
[ÂÂ116.729413] Hardware name: Intel Corporation Shark Bay Client
platform/Harris Beach SDS, BIOS HSWLPTU1.86C.0133.R00.1309172123
09/17/2013
[ÂÂ116.729547] task: ffff880124288000 task.stack: ffffc90000cf4000
[ÂÂ116.729614] RIP: 0010:[<ffffffff81677cdd>]ÂÂ[<ffffffff81677cdd>]
thermal_zone_get_temp+0x3d/0x100
[ÂÂ116.729721] RSP: 0018:ffffc90000cf7cd8ÂÂEFLAGS: 00010287
[ÂÂ116.729783] RAX: 00000000ffffffea RBX: ffff880114de2000 RCX:
ffff88010f89d4c0
[ÂÂ116.729862] RDX: ffffffffa07b8000 RSI: ffffc90000cf7d1c RDI:
ffff880114c5a000
[ÂÂ116.729942] RBP: ffffc90000cf7d08 R08: 0000000000000000 R09:
0000000000000000
[ÂÂ116.730021] R10: 000000001cffdcff R11: 0000000000000001 R12:
ffff880114c5a028
[ÂÂ116.730101] R13: ffffffff81a7aab0 R14: ffff880113a53800 R15:
ffff88012fdcc200
[ÂÂ116.730182] FS:ÂÂ00007f40bf57e700(0000) GS:ffff88014f280000(0000)
knlGS:0000000000000000
[ÂÂ116.730272] CS:ÂÂ0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ÂÂ116.730337] CR2: ffffffffa07b8010 CR3: 0000000010130000 CR4:
00000000001406e0
[ÂÂ116.730418] DR0: 0000000000000000 DR1: 0000000000000000 DR2:
0000000000000000
[ÂÂ116.730497] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7:
0000000000000400
[ÂÂ116.730576] Stack:
[ÂÂ116.730603]ÂÂ0000000000000282 ffffffff7fffffff ffff880114de2000
ffff880114c5a028
[ÂÂ116.736697]ÂÂffffffff81a7aab0 ffff880113a53800 ffffc90000cf7d28
ffffffff8167826e
[ÂÂ116.742680]ÂÂ0000000000000246 ffffffff81f19e20 ffffc90000cf7d48
ffffffff8154c910
[ÂÂ116.748607] Call Trace:
[ÂÂ116.754349]ÂÂ[<ffffffff8167826e>] temp_show+0x1e/0x40
[ÂÂ116.759705]ÂÂ[<ffffffff8154c910>] dev_attr_show+0x20/0x50
[ÂÂ116.764841]ÂÂ[<ffffffff812a50c1>] ? sysfs_file_ops+0x41/0x60
[ÂÂ116.769056]ÂÂ[<ffffffff812a5411>] sysfs_kf_seq_show+0xc1/0x120
[ÂÂ116.773282]ÂÂ[<ffffffff812a39f6>] kernfs_seq_show+0x26/0x30
[ÂÂ116.777457]ÂÂ[<ffffffff8124995f>] seq_read+0xcf/0x380
[ÂÂ116.781649]ÂÂ[<ffffffff812a4a4b>] kernfs_fop_read+0x11b/0x1a0
[ÂÂ116.785727]ÂÂ[<ffffffff81221968>] __vfs_read+0x28/0x110
[ÂÂ116.789796]ÂÂ[<ffffffff813526ab>] ?
security_file_permission+0x9b/0xc0
[ÂÂ116.793605]ÂÂ[<ffffffff81221dee>] ? rw_verify_area+0x4e/0xb0
[ÂÂ116.795640]ÂÂ[<ffffffff81221ee3>] vfs_read+0x93/0x130
[ÂÂ116.797212]ÂÂ[<ffffffff812232e9>] SyS_read+0x49/0xa0
[ÂÂ116.798715]ÂÂ[<ffffffff81003bfe>] do_syscall_64+0x6e/0x180
[ÂÂ116.800224]ÂÂ[<ffffffff8181c234>]
entry_SYSCALL64_slow_path+0x25/0x25
[ÂÂ116.801709] Code: 41 54 53 48 83 ec 10 48 85 ff c7 45 d8 ff ff ff 7f
0f 84 a3 00 00 00 48 81 ff 00 f0 ff ff 0f 87 96 00 00 00 48 8b 97 a0 04
00 00 <48> 83 7a 10 00 0f 84 84 00 00 00 4c 8d b7 30 05 00 00 48 89 fbÂ
[ÂÂ116.803334] RIPÂÂ[<ffffffff81677cdd>]
thermal_zone_get_temp+0x3d/0x100
[ÂÂ116.804877]ÂÂRSP <ffffc90000cf7cd8>
[ÂÂ116.806378] CR2: ffffffffa07b8010
[ÂÂ116.815516] ---[ end trace 593a281d67d382bb ]---


Thanks,
Srinivas