mirror_zfs/cmd
Matthew Ahrens d8381f50d6
Read past end of argv array in zpool_do_import()
`zpool_do_import()` passes `argv[0]`, (optionally) `argv[1]`, and
`pool_specified` to `import_pools()`.  If `pool_specified==FALSE`, the
`argv[]` arguments are not used.  However, these values may be off the
end of the `argv[]` array, so loading them could dereference unmapped
memory.  This error is reported by the asan build:

```
=================================================================
==6003==ERROR: AddressSanitizer: heap-buffer-overflow
READ of size 8 at 0x6030000004a8 thread T0
    #0 0x562a078b50eb in zpool_do_import zpool_main.c:3796
    #1 0x562a078858c5 in main zpool_main.c:10709
    #2 0x7f5115231bf6 in __libc_start_main
    #3 0x562a07885eb9 in _start

0x6030000004a8 is located 0 bytes to the right of 24-byte region
allocated by thread T0 here:
    #0 0x7f5116ac6b40 in __interceptor_malloc
    #1 0x562a07885770 in main zpool_main.c:10699
    #2 0x7f5115231bf6 in __libc_start_main
```

This commit passes NULL for these arguments if they are off the end
of the `argv[]` array.

Reviewed-by: George Wilson <gwilson@delphix.com>
Reviewed-by: John Kennedy <john.kennedy@delphix.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Allan Jude <allan@klarasystems.com>
Signed-off-by: Matthew Ahrens <mahrens@delphix.com>
Closes #12339
2021-07-26 12:51:39 -07:00
..
arc_summary Added another missed case to arc_summary3 2021-06-01 15:20:50 -06:00
arcstat FreeBSD: Update usage of py-sysctl 2020-12-10 15:28:31 -08:00
dbufstat dbufstat: Fix warnings with Python 3.8 2020-12-23 15:10:35 -08:00
fsck_zfs Turn shellcheck into a normal make target. Fix new files it caught 2021-06-01 11:38:49 -07:00
mount_zfs Normalise /*FALLTHR{OUGH,U}*/ 2021-07-26 12:07:39 -07:00
raidz_test raidz_test: use only async-signal-safe functions in signal handler 2021-05-20 16:37:38 -07:00
vdev_id Turn shellcheck into a normal make target. Fix new files it caught 2021-06-01 11:38:49 -07:00
zdb Normalise /*FALLTHR{OUGH,U}*/ 2021-07-26 12:07:39 -07:00
zed ZED: Match added disk by pool/vdev GUID if found (#12217) 2021-06-30 07:37:20 -07:00
zfs Normalise /*FALLTHR{OUGH,U}*/ 2021-07-26 12:07:39 -07:00
zfs_ids_to_path zfs_ids_to_path: print correct wrong values 2021-04-11 11:58:16 -07:00
zgenhostid Prune /*NOTREACHED*/ 2021-07-26 12:07:26 -07:00
zhack Prune /*NOTREACHED*/ 2021-07-26 12:07:26 -07:00
zinject cppcheck: integrete cppcheck 2021-01-26 16:12:26 -08:00
zpool Read past end of argv array in zpool_do_import() 2021-07-26 12:51:39 -07:00
zpool_influxdb Normalise /*FALLTHR{OUGH,U}*/ 2021-07-26 12:07:39 -07:00
zstream zstream: force-install zstreamdump link 2021-05-29 20:37:05 -07:00
ztest Prune /*NOTREACHED*/ 2021-07-26 12:07:26 -07:00
zvol_id Use substantially more robust program exit status logic in zvol_id 2021-07-02 13:10:36 -07:00
zvol_wait Turn shellcheck into a normal make target. Fix new files it caught 2021-06-01 11:38:49 -07:00
Makefile.am Turn shellcheck into a normal make target. Fix new files it caught 2021-06-01 11:38:49 -07:00