많은 컴퓨터에서 강화된 usercopy로 인해 Linux >= 4.8의 lshw segfaults

많은 컴퓨터에서 강화된 usercopy로 인해 Linux >= 4.8의 lshw segfaults

우리는 맞춤형 제작을 사용합니다opsi.orgbootimage를 사용하여 고객의 클라이언트 컴퓨터에 Windows를 자동으로 설치합니다. 이 부팅 이미지의 사용자 영역은 우리가 일부 수정한 업스트림 부팅 이미지와 Ubuntu에서 가져온 커널을 기반으로 합니다.

Ubuntu yakkety에서 커널을 Linux 4.8.0-42.45로 업그레이드한 이후로 고객으로부터 세그폴트 때문에 설치가 중단된다는 불만이 접수되기 시작했습니다 lshw.

[7] [Apr 27 23:29:08] Expecting compressed data from server (JSONRPC.py|660)
[5] [Apr 27 23:29:08] Running hardware inventory (setup.py|140)
[7] [Apr 27 23:29:08] Command 'lshw' found at: '/usr/bin/lshw' (Posix.py|640)
[6] [Apr 27 23:29:08] Executing: /usr/bin/lshw -xml 2>/dev/null (Posix.py|660)
[6] [Apr 27 23:29:08] Using encoding 'UTF-8' (Posix.py|691)
[7] [Apr 27 23:29:08] Exit code: 139 (Posix.py|748)
[2] [Apr 27 23:29:09] Traceback: (Logger.py|742)
[2] [Apr 27 23:29:09]      line 1390 in '<module>' in file '/usr/local/bin/master.py' (Logger.py|742)
[2] [Apr 27 23:29:09]      line 141 in '<module>' in file '/tmp/setup.py' (Logger.py|742)
[2] [Apr 27 23:29:09]      line 2482 in 'auditHardware' in file '/usr/lib/pymodules/python2.6/OPSI/System/Posix.py' (Logger.py|742)
[2] [Apr 27 23:29:09]      line 2526 in 'hardwareInventory' in file '/usr/lib/pymodules/python2.6/OPSI/System/Posix.py' (Logger.py|742)
[2] [Apr 27 23:29:09]      line 755 in 'execute' in file '/usr/lib/pymodules/python2.6/OPSI/System/Posix.py' (Logger.py|742)
[2] [Apr 27 23:29:09]      ==>>> Command '/usr/bin/lshw -xml 2>/dev/null' failed (139):
 (master.py|1438)

동시에 다음 오류가 기록됩니다 dmesg.

[   69.852348] usercopy: kernel memory exposure attempt detected from c0080000 (dma-kmalloc-512) (4096 bytes)
[   69.852365] ------------[ cut here ]------------
[   69.852367] kernel BUG at /build/linux-7qXOmc/linux-4.8.0/mm/usercopy.c:75!
[   69.852370] invalid opcode: 0000 [#1] SMP
[   69.852371] Modules linked in: arc4 md4 nls_utf8 cifs fscache joydev rtsx_usb_ms memstick snd_hda_intel rtsx_usb_sdmmc snd_hda_codec snd_hda_core acer_wmi snd_hwdep rtsx_usb r8169 fjes video sparse_keymap snd_pcm mii mei_txe wmi input_leds snd_timer mac_hid snd mei lpc_ich ahci libahci intel_smartconnect soundcore
[   69.852399] CPU: 0 PID: 1528 Comm: lshw Not tainted 4.8.0-42-generic #45-Ubuntu
[   69.852400] Hardware name: Acer Extensa 2508/Extensa 2508, BIOS V1.10 12/15/2014
[   69.852402] task: f6d16f00 task.stack: f6cc6000
[   69.852405] EIP: 0060:[<dd1f7543>] EFLAGS: 00010282 CPU: 0
[   69.852411] EIP is at __check_object_size+0x123/0x12c
[   69.852413] EAX: 0000005e EBX: c0080000 ECX: 00000247 EDX: 00000247
[   69.852414] ESI: 00001000 EDI: dda5944f EBP: f6cc7ee0 ESP: f6cc7eb8
[   69.852416]  DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[   69.852418] CR0: 80050033 CR2: bf910000 CR3: 36883e40 CR4: 001006f0
[   69.852419] Stack:
[   69.852420]  dda5f86c dda628ce dda97569 c0080000 f1402080 00001000 c0081000 c0080000
[   69.852427]  00090000 00001000 f6cc7f1c dd5074d6 00000000 00001000 bf900678 00010000
[   69.852434]  00080000 00000000 00090000 00000000 00090000 00000000 dd507430 f6cc7f60
[   69.852440] Call Trace:
[   69.852447]  [<dd5074d6>] read_mem+0xa6/0x1f0
[   69.852451]  [<dd507430>] ? write_mem+0x1f0/0x1f0
[   69.852454]  [<dd1fb15f>] __vfs_read+0x1f/0x50
[   69.852457]  [<dd1fb85f>] vfs_read+0x7f/0x140
[   69.852461]  [<dd80a0a0>] ? down_write+0x10/0x40
[   69.852465]  [<dd1fc9e9>] SyS_read+0x49/0xb0
[   69.852469]  [<dd0037cd>] do_fast_syscall_32+0x8d/0x140
[   69.852472]  [<dd80c07a>] sysenter_past_esp+0x47/0x75
[   69.852473] Code: 89 74 24 14 0f 44 ca ba ce 28 a6 dd 89 44 24 10 0f 44 d7 89 5c 24 0c 89 4c 24 08 89 54 24 04 c7 04 24 6c f8 a5 dd e8 15 91 f8 ff <0f> 0b b8 97 28 a6 dd eb b9 55 89 e5 57 56 53 83 ec 1c 3e 8d 74
[   69.852516] EIP: [<dd1f7543>] __check_object_size+0x123/0x12c SS:ESP 0068:f6cc7eb8
[   69.852523] ---[ end trace 5b12719d45b0befe ]---

나는 Linux에 버그가 있거나 lshw하드웨어에 이상한 점이 있다고 가정합니다. 하지만 문제는 많은 시스템에 영향을 미치므로 결함이 있는 하드웨어는 제외됩니다. 이 문제는 Linux >= 4.8에서만 발생하는 것 같습니다. 최소한 Linux 4.4는 영향을 받지 않습니다. 이는 아마도 Linux 4.8에 usercopy 강화 기능이 도입되었기 때문일 것입니다.

문제가 모든 컴퓨터에 영향을 미치지는 않습니다. 예를 들어 내 VirtualBox VM에서는 제대로 작동합니다. 현재 테스트 중인 영향을 받는 컴퓨터는 Acer Extensa 2508 노트북입니다. 우리는 lshw아마도 꽤 오래된 버전을 사용합니다 .

root@testnb:~# uname -a
Linux testnb 4.8.0-42-generic #45-Ubuntu SMP Wed Mar 8 20:05:25 UTC 2017 i686 GNU/Linux
root@testnb:~# lshw -version
B.02.14
root@testnb:~# lshw
Segmentation fault

이것이 원인일지도 모른다고 의심하여 lshw​​Debian jessie에서 02.17-1.1을 정적으로 컴파일했지만 그것도 작동하지 않습니다.

root@testnb:~# uname -a
Linux testnb 4.8.0-42-generic #45-Ubuntu SMP Wed Mar 8 20:05:25 UTC 2017 i686 GNU/Linux
root@testnb:~# ./lshw-02.17-static -version
B.02.17
root@testnb:~# ./lshw-02.17-static 
Segmentation fault

좀 더 최근의 Ubuntu yakkety에서 Linux 4.8 패키지를 사용해 보았습니다.

root@testnb:~# uname -a
Linux testnb 4.8.0-49-generic #52-Ubuntu SMP Thu Apr 20 09:39:42 UTC 2017 i686 GNU/Linux
root@testnb:~# lshw
Segmentation fault
root@testnb:~# ./lshw-02.17-static 
Segmentation fault

Ubuntu zesty의 Linux 4.10:

root@testnb:~# uname -a
Linux testnb 4.10.0-20-generic #22-Ubuntu SMP Thu Apr 20 09:22:16 UTC 2017 i686 GNU/Linux
root@testnb:~# lshw
Segmentation fault
root@testnb:~# ./lshw-02.17-static 
Segmentation fault

나는 지금 무엇을 해야할지 모르겠다. 어떤 아이디어가 있나요?

편집: 로그에서 영향을 받는 컴퓨터 목록을 정리했습니다.

martin@dogmeat ~/pssh/lshw-segfault-bootimage/output % cat *.out | sed 's/.*DMI: //' | sort | uniq
Acer Extensa 2508/Extensa 2508, BIOS V1.09 10/24/2014 (Posix.py|741)
Acer Extensa 2508/Extensa 2508, BIOS V1.10 12/15/2014 (Posix.py|741)
Dell Inc. Latitude D630                   /0KU184, BIOS A17 01/04/2010 (Posix.py|741)
Dell Inc. Latitude E5500                  /0DW634, BIOS A15 11/05/2009 (Posix.py|741)
Dell Inc. Vostro 1015                     /047MWF, BIOS A03 09/01/2010 (Posix.py|741)
FUJITSU ESPRIMO P910/D3162-A1, BIOS V4.6.5.3 R1.19.0 for D3162-A1x 12/17/2012 (Posix.py|741)
FUJITSU ESPRIMO P910/D3162-A1, BIOS V4.6.5.3 R1.22.0 for D3162-A1x 10/15/2013 (Posix.py|741)
Hewlett-Packard HP Compaq 6730b (GW687AV)/30DD, BIOS 68PDD Ver. F.10 07/31/2009 (Posix.py|741)
Hewlett-Packard HP Compaq 8510p /30C5, BIOS 68MVD Ver. F.0F 02/05/2008 (Posix.py|741)
Hewlett-Packard HP EliteBook 2540p/7008, BIOS 68CSU Ver. F.24 09/12/2013 (Posix.py|741)
Hewlett-Packard HP EliteBook 8470p/179B, BIOS 68ICF Ver. F.42 05/20/2013 (Posix.py|741)
Hewlett-Packard HP ProBook 4720s/1411, BIOS 68AZZ Ver. F.0B 09/16/2010 (Posix.py|741)
IBM 1860W25/1860W25, BIOS 70ET40WW (1.04 ) 06/02/2005 (Posix.py|741)
IBM 1860WR7/1860WR7, BIOS 70ET66WW (1.26 ) 05/18/2006 (Posix.py|741)
LENOVO 80ES/Lenovo B50-30, BIOS 9CCN21WW(V1.06) 04/09/2014 (Posix.py|741)
Quanta TW8/SW8/DW8/TW8/SW8/DW8, BIOS A3B92 10/07/2008 (Posix.py|741)
To Be Filled By O.E.M. To Be Filled By O.E.M./ALiveNF6G-GLAN, BIOS P1.70 03/06/2009 (Posix.py|741)
TOSHIBA Satellite Pro R50-B/Satellite Pro R50-B, BIOS Version 1.40   09/25/2014 (Posix.py|741)
TOSHIBA TECRA M10/Portable PC, BIOS Version 3.00 09/08/2009 (Posix.py|741)

EDIT2: lshwDebian Stretch에서 시도했으며 최신 버전은상류:

root@testnb:~# uname -a
Linux testnb 4.8.0-42-generic #45-Ubuntu SMP Wed Mar 8 20:05:25 UTC 2017 i686 GNU/Linux
root@testnb:~# ./lshw-02.18-static 
Segmentation fault
root@testnb:~# ./lshw-static-b1eab6372d 
Segmentation fault

EDIT3: 이제 VirtualBox VM에서 깨끗한 Linux 배포판(Ubuntu 17.04 라이브 CD)을 사용하여 이를 테스트했으며 이 문제가 그곳에서 재현 가능한지 확인할 수 있습니다.오직32비트 사용 lshw:

  • 64비트 Live CD를 사용한 첫 번째 시도 - 내장된 lshw기능은 작동합니다.

    root@ubuntu:~# uname -a
    Linux ubuntu 4.10.0-19-generic #21-Ubuntu SMP Thu Apr 6 17:04:57 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
    
    root@ubuntu:~# dpkg -l | grep lshw
    ii  lshw                                            02.18-0.1ubuntu3                            amd64        information about hardware configuration
    
    root@ubuntu:~# lshw | wc -l
    231
    
  • 내 정적 32비트 빌드 중 하나 lshw는 다음과 같습니다.

    root@ubuntu:~# ./lshw-02.18-static
    Segmentation fault
    
  • 32비트 Live CD를 사용한 두 번째 시도 - 이제 내장된 CD도 lshw작동하지 않습니다.

    root@ubuntu:~# uname -a
    Linux ubuntu 4.10.0-19-generic #21-Ubuntu SMP Thu Apr 6 17:03:14 UTC 2017 i686 i686 i686 GNU/Linux
    
    root@ubuntu:~# dpkg -l | grep lshw
    ii  lshw                                           02.18-0.1ubuntu3                            i386         information about hardware configuration
    
    root@ubuntu:~# lshw
    Segmentation fault
    
  • lshw루트 권한 없이 실행하면 분할 오류가 발생하지 않습니다 .

    ubuntu@ubuntu:~$ lshw | wc -l
    WARNING: you should run this program as super-user.
    WARNING: output may be incomplete or inaccurate, you should run this program as super-user.
    168
    

우리는 서로 다른 두 대의 컴퓨터(하나는 ASUSTeK H170-PRO/USB 3.1 메인보드, 다른 하나는 ASUSTeK P8H77-M 메인보드)와 여러 가지 VM 유형(Microsoft Windows -> Windows 7(32비트), Microsoft Windows -> Windows 10(64비트), Linux -> Ubuntu(32비트)에서 문제가 항상 재현됩니다.

편집 4: 어떤 이유에서인지 이제 VirtualBox에서 부팅 이미지 관련 문제를 재현하는 데 문제가 있습니다. 어쩌면 VM 구성에 따라 달라질 수 있습니까? 하지만 Acer Extensa 2508 시스템에서는 여전히 확실히 재현 가능합니다. 이 문제는 의 32비트 빌드에만 영향을 미치는 것으로 보이므로 이제 64비트를 지원하는 시스템에서 lshw정적 64비트 빌드와 함께 64비트 부팅 이미지를 사용하여 문제를 해결합니다 .lshw

업스트림 버그 보고서:http://www.ezix.org/project/ticket/750

관련 정보