Commit Graph

2713 Commits

Author SHA1 Message Date
Yonghua Huang
3348723805 dm: fix fault Injection into VirtIO console backend
CVE# CVE-2021-23905
 Add Null pointer check in init vq ring and add vq ring descriptor
 check in case cause Nullpointer exception.

Tracked-On: #5355
Signed-off-by: Liu Long <long.liu@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-02 14:39:04 +08:00
Yonghua Huang
e09ecb13eb virtio: add virtio callbacks check
CVE# CVE-2021-23904
We can only call these callbacks when they are not NULL.

Tracked-On: #5342

Signed-off-by: Jie Deng <jie.deng@intel.com>
Signed-off-by: Yonghua Huang<yonghua.huang@intel.com>
Acked-by: Wang, Yu1 <yu1.wang@intel.com>
2021-07-02 14:39:04 +08:00
Jie Deng
d74f25fde4 dm: virtio_console: read only when the virtqueue is ready.
CVE# CVE-2021-23902
The read should not continue if the virtqueue is not ready.

Tracked-On: #5544
Signed-off-by: Jie Deng <jie.deng@intel.com>
2021-07-02 14:39:04 +08:00
Yonghua Huang
9d29f5ff69 dm: validate inputs in vq_endchains
inputs shall be validated to avoid NULL pointer access.

Tracked-On: #6129
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-02 10:33:37 +08:00
Yonghua Huang
ea76e59d77 DM: xHCI: Check trb pointer before use it
The trb pointer may be NULL when get the address from user space, add
the pointer check before use the trb.

Tracked-On: #6172
Signed-off-by: Liu Long <long.liu@intel.com>
Reviewed-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2021-07-02 10:33:37 +08:00
Yonghua Huang
2b91780b4e dm: Reset virtio device before release
With virtio polling mode enabled, a timer is running in the virtio
backend service. And the timer will also be triggered if its frondend
driver didn't do the device reset in shutdown. A freed virtio device
will be accessed in the polling timer handler.

Do the virtio reset() callback specifically to clear the polling timer
before the free.

Tracked-On: #6147
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-02 10:33:37 +08:00
Yonghua Huang
65a957dff8 dm: rb: only free rb_entry when we remove this entry from the
Only free rb_entry when we remove this entry from the rb tree, otherwise, a
page fault would trigger when next rb itreation would access the freed rb_entry.

Tracked-On: #6056
Signed-off-by: Li Fei1 <fei1.li@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2021-07-02 10:33:37 +08:00
Jie Deng
2e08f32e7a dm: NULL check of vq->used in virtio_net_ping_rxq
Add a check on this place to avoid NULL access issue.

Tracked-On: #6100
Signed-off-by: Jie Deng <jie.deng@intel.com>
2021-07-02 10:33:37 +08:00
Yonghua Huang
e5f0e2e4f8 hv:fix crash issue when handling HC_NOTIFY_REQUEST_FINISH
Input 'vcpu_id‘ shall be validated properly:
- 'vcpu_id' shall be less than 'vm->hw.created_vcpus'
instead of 'MAX_VCPUS_PER_VM'.

Tracked-On: #4670
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2020-04-22 16:18:57 +08:00
Yonghua Huang
2e9028128f hv:bugfix in write protect page hypercall
This patch fixes potential hypervisor crash when calling
 hc_hcall_write_protect_page()with a crafted GPA in
 'struct wp_data' instance, e.g. an invalid GPA that is
 out of the scope of target VM's EPT address space.

Tracked-On: #4669
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2020-04-22 16:18:57 +08:00
Yonghua Huang
66d824d677 hv:unmap AP trampoline region from service VM's EPT
AP trampoline code should be accessile to hypervisor only,
 Unmap this memory region from service VM's EPT mapping
 for security reason..

Tracked-On: #4112
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2019-11-18 10:39:23 +08:00
Yonghua Huang
52a968db2f hv:refine modify_or_del_pte/pde/pdpte()function
1. Print warning message instead of panic when
     the caller try to modify the attribute for
     memory region or delete memory region that
     are not present.
  2. To avoid above warning  message for memory region
     below 1M,its attribute may be updated by Service
     VM when updating MTTR setting.

Tracked-On: #4112
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Fei Li <fei1.li@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-11-18 10:39:23 +08:00
fuyanX
62e9d9bf75 acrn-hv: code review fix lib/string.c
In lib/string.c, strncmp doesn't consider condition "n_arg=0",
just add a process to "n_arg=0".

Tracked-On: #4115
Signed-off-by: fuyanx <yanx.fu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-11-18 10:39:23 +08:00
xiaojin2
aca51c0fad tools: acrn-crashlog: refine crash complete code
This patch is to remove unused info in server.c

Tracked-On: #4111
Signed-off-by: xiaojin2 <xiaojing.liu@intel.com>
Reviewed-by: Liu, Xinwu <xinwu.liu@intel.com>
Acked-by: CHEN Gang <gang.c.chen@intel.com>
2019-11-18 10:39:23 +08:00
Yonghua Huang
c1528fd1b2 vm-manager: fix improper return value check for "strtol()"
The return value of 'strtol()' is not checked properly
 in _get_vmname_pid() @acrn_vm_ops.c and parse_opt()@acnrd.c,
 the return type of 'strtol' is 'long int', but it is assigned
 to a variable with type of 'int' and compared to "LONG_MAX"
 and "LONG_MIN", which is always false.

 This patch is to fix above error case.

Tracked-On: #4110
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Yan, Like <like.yan@intel.com>
Acked-by: Yan, Like <like.yan@intel.com>
2019-11-18 10:39:23 +08:00
Gao Junhao
87a8cd50d7 dm: refine the check of return value of snprintf
int snprintf(char *str, size_t size, const char *format, ...)
The functions snprintf() write at most size bytes (including the
terminating null byte('\0')) to str.
only when returned value of snprintf is non-negative and less than size,
the string has been completely written.

Tracked-On: #4109
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-11-18 10:39:23 +08:00
Yonghua Huang
e6e9f4da68 dm: fix mutex lock issue in tpm_rbc.c
In function crb_reg_write() in tpm_rbc.c
 'tpm_vdev->request_mutex' will potentially kept
 in locked state after crb_reg_write() returns.

Tracked-On: #4108
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Yadong Qi <yadong.qi@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-11-18 10:39:23 +08:00
Yonghua Huang
114fbe33f3 dm: close filepointer before exiting acrn_load_elf()
In acrn_load_elf(), file pointer 'fp' is kept in
 open state before exiting if 'load_elf32()' is executed,
 this patch is to fix this bug.

Tracked-On: #4107
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2019-11-18 10:39:23 +08:00
Gao Junhao
48bcd98ec6 dm: modify DIR handler reference postion
DIR handler is referenced after release, need to be adjusted before
released.

Tracked-On: #4106
Signed-off-by: Gao Junhao <junhao.gao@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-11-18 10:39:23 +08:00
Junhao Gao
cf31b41f8b dm: reduce potential crash caused by LIST_FOREACH
When removing node in list, list_foreach_safe will be safer than
LIST_FOREACH.

Tracked-On: #4104
Signed-off-by: Junhao Gao <junhao.gao@intel.com>
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-11-18 10:39:23 +08:00
Yonghua Huang
ed51cfd741 hv: fix error debug message in hcall_set_callback_vector
this patch is to fix error debug message
 for invalid 'param' case, there is no string
 variable for '%s' output, which will potenially
 trigger hypervisor crash as it may access random
 memroy address and trigger SMAP violation.

Tracked-On: #4114
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
2019-11-18 10:39:23 +08:00
Yonghua Huang
cf6ba23fd9 dm: validate the input in 'pci_emul_mem_handler()'
checking the inputs explicitly instead of using Assert.

Tracked-On: #3991
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
Reviewed-by: Shuo Liu <shuo.a.liu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-11-06 16:33:11 +08:00
Qi Yadong
21af6c84a4 hv: save/restore TSC in host's suspend/resume path
TSC would be reset to 0 when enter suspend state on some platform.
This will fail the secure timer checking in secure world because
secure world leverage the TSC as source of secure timer which should
be increased monotonously.

This patch save/restore TSC in host suspend/resume path to guarantee
the mono increasing TSC.

Note: There should no timer setup before TSC resumed.

Tracked-On: #3698
Signed-off-by: Qi Yadong <yadong.qi@intel.com>
Reviewed-by: Yin Fengwei <fengwei.yin@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2019-09-24 13:45:49 +08:00
Binbin Wu
89ef00c689 dm: vsbl: update to v1.4
Update vFastboot to v1.4.
This version remove the use of openssl.

Tracked-On: #3588
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2019-08-20 14:40:11 +08:00
Tianhua Sun
b12b492d74 hv: fix symbols not stripped from release binaries
In release environment, binary files must be stripped in
order to remove debugging code sections and symbol information
that aid attackers in the process of disassembly and reverse
engineering.
Use '-s' linking option to remove symbol table and relocation
information from release binaries.

Tracked-On: #3433
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-19 09:45:09 +08:00
Tianhua Sun
877ce914a2 hv: fix some potential array overflow risk
'pcpu_id' should be less than CONFIG_MAX_PCPU_NUM,
else 'per_cpu_data' will overflow. This commit fixes
this potential overflow issue.

Tracked-On: #3407
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-18 15:18:29 +08:00
Tianhua Sun
de125e6c6f dm: fix variable argument list read without ending with va_end
va_end() was not getting called under certain condition
after the va_start() function call taking the va_list.

Tracked-On: #3406
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-18 15:18:29 +08:00
Tianhua Sun
c0cb9c509f tools: fix variable argument list read without ending with va_end
va_end() was not getting called under certain condition
after the va_start() function call taking the va_list

Tracked-On: #3406
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Gang Chen <gang.c.chen@intel.com>
2019-07-18 15:18:29 +08:00
Tianhua Sun
21083ee09c dm: fix some possible memory leak
free memory allocated by strdup()

Tracked-On: #3405
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-07-18 15:18:29 +08:00
Tianhua Sun
835605855e dm: fix some potential memory leaks
This patch is to fix some potential memory leak issues

1, free mrp if the mmio_rb_lookup() function return 0;
2, free memory allocated by strdup in some error case handling.

Tracked-On: #3333
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-07-05 15:15:35 +08:00
Tianhua Sun
e7cfd9c561 dm: fix strncpy null-terminated issues
Fix strncpy null-terminated issues.

Tracked-On: #3332
Signed-off-by: Tianhua Sun <tianhuax.s.sun@intel.com>
Acked-by: Anthony Xu <anthony.xu@intel.com>
2019-07-05 15:15:35 +08:00
Zhao Yakui
f4daf2d127 DM: Adjust the priority related with ioreq emulation for Android Guest
When the IO/MMIO acccess on Android guest causes the trap to hypervisor,
it will be blocked until the ioreq emulation is completed.
In order to get the better performance, it will be better that the ioreq
emulation can be completed ASAP. As it is handled in SOS kernel, the
corresponding thread priority will be raised.

Tracked-On:#3242
Signed-off-by: Liu, Shuo <shuo.liu@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
2019-06-12 10:58:01 +08:00
Yin Fengwei
0a0213695e debug/release: Enable enable -g option for debug build
-g option should only be enabled for debug build and disabled
for release build.

Tracked-On: #3164
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-24 16:10:49 +08:00
Yin Fengwei
f2d654cc44 signal SIGINT: map SIGINT to watchdog reset
Map SIGINT(2) to watchdog reset.
NOTE:
We required guest to do a full reset after detect the recent last
reset type is watchdog. This is used to resume the passthru devices
in UOS.

Tracked-On: #3103
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-15 16:20:24 +08:00
Yin Fengwei
634e310f9b build: fix build issue with latest gcc
Fix build issues with gcc 9.1 version

Tracked-On: #3121
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2019-05-15 15:51:20 +08:00
Wei Liu
57ac00a61f acrn-dm: enable debug option for acrn-dm
enable acrn-dm debug option via RELEASE=0(by default)

Tracked-On: #2939
Reviewed-by: Minggui Cao <minggui.cao@intel.com>
Signed-off-by: Wei Liu <weix.w.liu@intel.com>
2019-04-19 11:14:33 +08:00
Xiaoguang Wu
8f32193d99 DM USB: xHCI: refine the failure process logic of control transfer
The old logic to process control transfer failure is not complete, this
patch is used to fix this issue.

Tracked-On: #2824
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 11:57:51 +08:00
Xiaoguang Wu
7c79f50752 DM USB: xHCI: workaround for libusb timing issue
On some platforms, the VBus will drop after suspending is done, hence
a disconnect and re-connect for device connected before suspending will
be triggered in DM. But during the stress test, when the free memory is
limited to very low level, and put huge workload to SOS, under certain
possibility, the DM will receive re-connect event first and disconnect
event later, this behavior will result of failing to emulate USB device
to UOS.

The reason is due to a timing issue from libusb. Before we could upstream
fixing patch to libusb or find some other better solution, this workaround
patch will be used to avoid errors happen.

Tracked-On: #2823
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 11:57:51 +08:00
Xiaoguang Wu
66dabd1260 DM USB: xHCI: fix an synchronization issue during resuming process
When disable slot cmd is received by device model, the operation
should be: release the pci_xhci_dev_emu variable first, and signal
xhci_vbdp_thread to wakeup later. Tho old implementation is not
right, this patch is used to fix it.

Tracked-On: #2823
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-20 11:57:51 +08:00
Yin Fengwei
d5b35aa785 acrn-dm: revert the change which apply realtime schedule to vcpu0
Applying realtime scheduler to vcpu0 thread could trigger
stability issue. So revert it here.

Tracked-On: #2717
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-19 10:36:25 +08:00
Xiaoguang Wu
3593135673 DM USB: xHCI: Fix CTS test failure
This patch fixes the failure of CTS 'USB Device Test' itme.

Tracked-On: #2800
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-18 13:30:36 +08:00
Xiaoguang Wu
c6efc67c20 DM USB: xHCI: fix issue of discarding zero sized BULK transfer
Should not disacard zero-size bulk transfer.

Tracked-On: #2800
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-18 13:30:36 +08:00
Binbin Wu
2ada1d4dbf hv: vtd: fix compile warning on UEFI platform
Fix compile warning on UEFI platform when check bus number.

Tracked-On: #2743
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2019-03-13 13:53:13 +08:00
Binbin Wu
0a9aeaa10e hv: vtd: check bus limit when add/remove device
Check bus limit when add/remove device in iommu.

Tracked-On: #2743
Signed-off-by: Binbin Wu <binbin.wu@intel.com>
2019-03-13 11:34:03 +08:00
yuhong.tao@intel.com
3e5bccd755 tools: acrnctl fix potential buffer overflow
When run 'acrnctl add', acrnctl dryruns launch script to get
vmname. Acrnctl assumes there are no more than 64 words in each
line of the script, and creates a buffer to hold 64 pointers to these
words. But we didn't check if the number of words exceed 64 limitation,
which can lead to buffer overflow. This commit fixed this potential
overflow problem.
And also refine some confusing error messages in 'acrnctl add'

Tracked-On: #2734
Acked-by: Yan Like <like.yan@intel.com>
Signed-off-by: Tao Yuhong <yuhong.tao@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-03-13 10:22:50 +08:00
Conghui Chen
2171b6d2b9 dm: usb: fix possible memory leak
fix possible memory leak for usb.

Tracked-On: #2705
Signed-off-by: Conghui Chen <conghui.chen@intel.com>
Reviewed-by: Yuan Liu <yuan1.liu@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-03-13 10:17:20 +08:00
Jie Deng
d585389554 dm: virtio-net: fix memory leak
Dynamic memory stored in 'net' allocated through function 'calloc'
should be freed correspondingly when return fail.

Tracked-On: #2704
Signed-off-by: Jie Deng <jie.deng@intel.com>
Reviewed-by: Yonghua Huang <yonghua.huang@intel.com>
2019-03-12 10:22:05 +08:00
Binbin Wu
d4f7a1e142 dm: fix typo of path for cgroup cpu tasks
typo fix:
/sys/fs/cgroup/cpu/task -> /sys/fs/cgroup/cpu/tasks

Tracked-On: #2717
Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
2019-03-11 20:02:52 +08:00
Yuan Liu
7a07dfb9c7 dm: usb: fix SWWDT_UNHANDLED issue
add a delay for usb in launch_uos.sh

Tracked-On: #2633
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-11 11:34:32 +08:00
Xiaoguang Wu
b8017080b3 DM USB: xHCI: fix an logic error during USB reset
Should not set hci_address to zero during USB reset.

Tracked-On: #2633
Signed-off-by: Xiaoguang Wu <xiaoguang.wu@intel.com>
Acked-by: Yu Wang <yu1.wang@intel.com>
2019-03-11 11:34:32 +08:00