Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1919215

Summary: double free in ex_argdelete() when input craft vimscript file
Product: [Fedora] Fedora Reporter: 1vanChen <houyunsong>
Component: vimAssignee: Red Hat Product Security <security-response-team>
Status: CLOSED ERRATA QA Contact:
Severity: high Docs Contact:
Priority: unspecified    
Version: rawhideCC: gchamoul, mcascell, zdohnal
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: vim-8.2.2529-1.fc33 vim-8.2.2541-1.fc33 vim-8.2.2541-1.fc32 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-20 01:26:01 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
poc
none
reduced poc file none

Description 1vanChen 2021-01-22 12:13:24 UTC
Created attachment 1749723 [details]
poc

To Reproduce

```shell
vim -u NONE -X -Z -e -s -S poc -c :qa!
```

Debug Info

```shell
/src/vim# src/vim -u NONE -X -Z -e -s -S ../poc -c :qa!
=================================================================
==18589==ERROR: AddressSanitizer: attempting double-free on 0x602000009630 in thread T0:
    #0 0x49733d in free (/src/vim/src/vim+0x49733d)
    #1 0x6cfd9b in vim_free /src/vim/src/misc2.c:1807:2
    #2 0x4cac5e in ex_argdelete /src/vim/src/arglist.c:807:3
    #3 0x5d277b in do_one_cmd /src/vim/src/ex_docmd.c:2588:2
    #4 0x5cc8b8 in do_cmdline /src/vim/src/ex_docmd.c:1003:17
    #5 0x4d14d2 in apply_autocmds_group /src/vim/src/autocmd.c:2109:2
    #6 0x4d363d in apply_autocmds /src/vim/src/autocmd.c:1621:12
    #7 0x5bd62e in do_ecmd /src/vim/src/ex_cmds.c:2726:6
    #8 0x4ca0a2 in do_argfile /src/vim/src/arglist.c:692:6
    #9 0x4c9c1d in ex_next /src/vim/src/arglist.c:727:2
    #10 0x5d277b in do_one_cmd /src/vim/src/ex_docmd.c:2588:2
    #11 0x5cc8b8 in do_cmdline /src/vim/src/ex_docmd.c:1003:17
    #12 0x7ec3ee in do_source /src/vim/src/scriptfile.c:1401:5
    #13 0x7eb03d in cmd_source /src/vim/src/scriptfile.c:971:14
    #14 0x7eaf1e in ex_source /src/vim/src/scriptfile.c:997:2
    #15 0x5d277b in do_one_cmd /src/vim/src/ex_docmd.c:2588:2
    #16 0x5cc8b8 in do_cmdline /src/vim/src/ex_docmd.c:1003:17
    #17 0x5cf181 in do_cmdline_cmd /src/vim/src/ex_docmd.c:592:12
    #18 0x9c0df7 in exe_commands /src/vim/src/main.c:3056:2
    #19 0x9bfc44 in vim_main2 /src/vim/src/main.c:760:2
    #20 0x9bd071 in main /src/vim/src/main.c:412:12
    #21 0x7ffff6cba83f in __libc_start_main /build/glibc-e6zv40/glibc-2.23/csu/../csu/libc-start.c:291
    #22 0x41d768 in _start (/src/vim/src/vim+0x41d768)

0x602000009630 is located 0 bytes inside of 2-byte region [0x602000009630,0x602000009632)
freed by thread T0 here:
    #0 0x49733d in free (/src/vim/src/vim+0x49733d)
    #1 0x6cfd9b in vim_free /src/vim/src/misc2.c:1807:2
    #2 0x4cac5e in ex_argdelete /src/vim/src/arglist.c:807:3
    #3 0x5d277b in do_one_cmd /src/vim/src/ex_docmd.c:2588:2
    #4 0x5cc8b8 in do_cmdline /src/vim/src/ex_docmd.c:1003:17
    #5 0x4d14d2 in apply_autocmds_group /src/vim/src/autocmd.c:2109:2
    #6 0x4d363d in apply_autocmds /src/vim/src/autocmd.c:1621:12
    #7 0x4de4c9 in buflist_new /src/vim/src/buffer.c:2215:6
    #8 0x4e5012 in buflist_add /src/vim/src/buffer.c:3501:11
    #9 0x4c7e54 in alist_add /src/vim/src/arglist.c:188:6
    #10 0x4c7cb0 in alist_set /src/vim/src/arglist.c:157:6
    #11 0x4c8aa0 in do_arglist /src/vim/src/arglist.c:458:6
    #12 0x4c9bc2 in ex_next /src/vim/src/arglist.c:721:10
    #13 0x5d277b in do_one_cmd /src/vim/src/ex_docmd.c:2588:2
    #14 0x5cc8b8 in do_cmdline /src/vim/src/ex_docmd.c:1003:17
    #15 0x7ec3ee in do_source /src/vim/src/scriptfile.c:1401:5
    #16 0x7eb03d in cmd_source /src/vim/src/scriptfile.c:971:14
    #17 0x7eaf1e in ex_source /src/vim/src/scriptfile.c:997:2
    #18 0x5d277b in do_one_cmd /src/vim/src/ex_docmd.c:2588:2
    #19 0x5cc8b8 in do_cmdline /src/vim/src/ex_docmd.c:1003:17
    #20 0x5cf181 in do_cmdline_cmd /src/vim/src/ex_docmd.c:592:12
    #21 0x9c0df7 in exe_commands /src/vim/src/main.c:3056:2
    #22 0x9bfc44 in vim_main2 /src/vim/src/main.c:760:2
    #23 0x9bd071 in main /src/vim/src/main.c:412:12
    #24 0x7ffff6cba83f in __libc_start_main /build/glibc-e6zv40/glibc-2.23/csu/../csu/libc-start.c:291

previously allocated by thread T0 here:
    #0 0x4975bd in malloc (/src/vim/src/vim+0x4975bd)
    #1 0x6ce307 in lalloc /src/vim/src/misc2.c:925:11
    #2 0x6ce2dd in alloc /src/vim/src/misc2.c:828:12
    #3 0x623668 in addfile /src/vim/src/filepath.c:3948:9
    #4 0x62203b in gen_expand_wildcards /src/vim/src/filepath.c
    #5 0x6216ef in expand_wildcards /src/vim/src/filepath.c:3018:14
    #6 0x4c89a8 in do_arglist /src/vim/src/arglist.c:443:6
    #7 0x4c9bc2 in ex_next /src/vim/src/arglist.c:721:10
    #8 0x5d277b in do_one_cmd /src/vim/src/ex_docmd.c:2588:2
    #9 0x5cc8b8 in do_cmdline /src/vim/src/ex_docmd.c:1003:17
    #10 0x7ec3ee in do_source /src/vim/src/scriptfile.c:1401:5
    #11 0x7eb03d in cmd_source /src/vim/src/scriptfile.c:971:14
    #12 0x7eaf1e in ex_source /src/vim/src/scriptfile.c:997:2
    #13 0x5d277b in do_one_cmd /src/vim/src/ex_docmd.c:2588:2
    #14 0x5cc8b8 in do_cmdline /src/vim/src/ex_docmd.c:1003:17
    #15 0x5cf181 in do_cmdline_cmd /src/vim/src/ex_docmd.c:592:12
    #16 0x9c0df7 in exe_commands /src/vim/src/main.c:3056:2
    #17 0x9bfc44 in vim_main2 /src/vim/src/main.c:760:2
    #18 0x9bd071 in main /src/vim/src/main.c:412:12
    #19 0x7ffff6cba83f in __libc_start_main /build/glibc-e6zv40/glibc-2.23/csu/../csu/libc-start.c:291

SUMMARY: AddressSanitizer: double-free (/src/vim/src/vim+0x49733d) in free
==18589==ABORTING
```



Environment:

- version : commit e2edc2ed4a9a229870b1e1811b0ecf045b84e429
- OS: Ubuntu 16.04



Additional context

compile argument:

```shell
#!/bin/bash -eux
export CC="clang-11"
export CXX="clang-11++"
export LDFLAGS="-fsanitize=address"
export CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer"
export CXXFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer"
cd /src/vim/ && ./configure --with-features=huge --enable-gui=none && make
```



Credit: 1vanChen of NSFOCUS Security Team

Comment 1 Zdenek Dohnal 2021-01-25 05:44:30 UTC
Hi,

thank you for reporting the issue!

I'll pass the issue to security team and report it upstream.

Comment 3 1vanChen 2021-01-26 06:16:50 UTC
Created attachment 1750766 [details]
reduced poc file

Simplified sample is provided

Comment 4 Mauro Matteo Cascella 2021-02-15 19:06:33 UTC
Please refer to https://bugzilla.redhat.com/show_bug.cgi?id=1919212#c4.

Comment 5 Fedora Update System 2021-02-18 09:34:17 UTC
FEDORA-2021-164265f25a has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-164265f25a

Comment 6 Fedora Update System 2021-02-18 09:35:02 UTC
FEDORA-2021-01b3981cc5 has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2021-01b3981cc5

Comment 7 Fedora Update System 2021-02-19 01:59:51 UTC
FEDORA-2021-01b3981cc5 has been pushed to the Fedora 32 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-01b3981cc5`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-01b3981cc5

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 8 Fedora Update System 2021-02-19 02:03:47 UTC
FEDORA-2021-164265f25a has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-164265f25a`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-164265f25a

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 9 Fedora Update System 2021-02-20 01:26:01 UTC
FEDORA-2021-164265f25a has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 10 Fedora Update System 2021-02-22 07:45:20 UTC
FEDORA-2021-5be90ab004 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-5be90ab004

Comment 11 Fedora Update System 2021-02-22 08:02:46 UTC
FEDORA-2021-fb090f432a has been submitted as an update to Fedora 32. https://bodhi.fedoraproject.org/updates/FEDORA-2021-fb090f432a

Comment 12 Fedora Update System 2021-02-24 21:39:45 UTC
FEDORA-2021-fb090f432a has been pushed to the Fedora 32 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-fb090f432a`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-fb090f432a

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 13 Fedora Update System 2021-02-24 21:55:06 UTC
FEDORA-2021-5be90ab004 has been pushed to the Fedora 33 testing repository.
Soon you'll be able to install the update with the following command:
`sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-5be90ab004`
You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-5be90ab004

See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.

Comment 14 Fedora Update System 2021-02-26 01:09:04 UTC
FEDORA-2021-5be90ab004 has been pushed to the Fedora 33 stable repository.
If problem still persists, please make note of it in this bug report.

Comment 15 Fedora Update System 2021-03-08 20:13:48 UTC
FEDORA-2021-fb090f432a has been pushed to the Fedora 32 stable repository.
If problem still persists, please make note of it in this bug report.