android_kernel_xiaomi_sm7250/drivers/md
Saurabh Sengar 897b1450ab md: Replace snprintf with scnprintf
commit 1727fd5015d8f93474148f94e34cda5aa6ad4a43 upstream.

Current code produces a warning as shown below when total characters
in the constituent block device names plus the slashes exceeds 200.
snprintf() returns the number of characters generated from the given
input, which could cause the expression “200 – len” to wrap around
to a large positive number. Fix this by using scnprintf() instead,
which returns the actual number of characters written into the buffer.

[ 1513.267938] ------------[ cut here ]------------
[ 1513.267943] WARNING: CPU: 15 PID: 37247 at <snip>/lib/vsprintf.c:2509 vsnprintf+0x2c8/0x510
[ 1513.267944] Modules linked in:  <snip>
[ 1513.267969] CPU: 15 PID: 37247 Comm: mdadm Not tainted 5.4.0-1085-azure #90~18.04.1-Ubuntu
[ 1513.267969] Hardware name: Microsoft Corporation Virtual Machine/Virtual Machine, BIOS Hyper-V UEFI Release v4.1 05/09/2022
[ 1513.267971] RIP: 0010:vsnprintf+0x2c8/0x510
<-snip->
[ 1513.267982] Call Trace:
[ 1513.267986]  snprintf+0x45/0x70
[ 1513.267990]  ? disk_name+0x71/0xa0
[ 1513.267993]  dump_zones+0x114/0x240 [raid0]
[ 1513.267996]  ? _cond_resched+0x19/0x40
[ 1513.267998]  raid0_run+0x19e/0x270 [raid0]
[ 1513.268000]  md_run+0x5e0/0xc50
[ 1513.268003]  ? security_capable+0x3f/0x60
[ 1513.268005]  do_md_run+0x19/0x110
[ 1513.268006]  md_ioctl+0x195e/0x1f90
[ 1513.268007]  blkdev_ioctl+0x91f/0x9f0
[ 1513.268010]  block_ioctl+0x3d/0x50
[ 1513.268012]  do_vfs_ioctl+0xa9/0x640
[ 1513.268014]  ? __fput+0x162/0x260
[ 1513.268016]  ksys_ioctl+0x75/0x80
[ 1513.268017]  __x64_sys_ioctl+0x1a/0x20
[ 1513.268019]  do_syscall_64+0x5e/0x200
[ 1513.268021]  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: 766038846e ("md/raid0: replace printk() with pr_*()")
Reviewed-by: Michael Kelley <mikelley@microsoft.com>
Acked-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Signed-off-by: Saurabh Sengar <ssengar@linux.microsoft.com>
Signed-off-by: Song Liu <song@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-26 13:19:42 +02:00
..
bcache md: bcache: check the return value of kzalloc() in detached_dev_do_request() 2022-06-14 16:59:30 +02:00
persistent-data dm space map common: add bounds check to sm_ll_lookup_bitmap() 2022-01-27 09:04:28 +01:00
dm-bio-prison-v1.c
dm-bio-prison-v1.h
dm-bio-prison-v2.c
dm-bio-prison-v2.h
dm-bio-record.h
dm-bufio.c dm bufio: subtract the number of initial sectors in dm_bufio_get_device_size 2021-03-11 14:04:59 +01:00
dm-builtin.c
dm-cache-background-tracker.c
dm-cache-background-tracker.h
dm-cache-block-types.h
dm-cache-metadata.c
dm-cache-metadata.h
dm-cache-policy-internal.h
dm-cache-policy-smq.c
dm-cache-policy.c
dm-cache-policy.h
dm-cache-target.c
dm-core.h dm: fix deadlock when swapping to encrypted device 2021-03-04 09:39:57 +01:00
dm-crypt.c dm crypt: make printing of the key constant-time 2022-06-06 08:24:21 +02:00
dm-delay.c
dm-era-target.c dm era: commit metadata in postsuspend after worker stops 2022-07-02 16:27:31 +02:00
dm-exception-store.c
dm-exception-store.h
dm-flakey.c
dm-integrity.c dm integrity: fix error code in dm_integrity_ctr() 2022-06-06 08:24:21 +02:00
dm-io.c
dm-ioctl.c dm ioctl: prevent potential spectre v1 gadget 2022-04-15 14:15:02 +02:00
dm-kcopyd.c
dm-linear.c
dm-log-userspace-base.c
dm-log-userspace-transfer.c
dm-log-userspace-transfer.h
dm-log-writes.c
dm-log.c
dm-mpath.c
dm-mpath.h
dm-path-selector.c
dm-path-selector.h
dm-queue-length.c
dm-raid1.c
dm-raid.c dm raid: fix address sanitizer warning in raid_status 2022-08-25 11:15:30 +02:00
dm-region-hash.c
dm-round-robin.c
dm-rq.c dm rq: fix double free of blk_mq_tag_set in dev remove after table load fails 2021-05-22 10:59:23 +02:00
dm-rq.h
dm-service-time.c
dm-snap-persistent.c
dm-snap-transient.c
dm-snap.c dm snapshot: properly fix a crash when an origin has no snapshots 2021-06-03 08:38:04 +02:00
dm-stats.c dm stats: add cond_resched when looping over entries 2022-06-06 08:24:21 +02:00
dm-stats.h
dm-stripe.c
dm-switch.c
dm-sysfs.c
dm-table.c dm table: fix zoned iterate_devices based device capability checks 2021-03-11 14:05:01 +01:00
dm-target.c
dm-thin-metadata.c dm thin metadata: Fix use-after-free in dm_bm_set_read_only 2021-09-22 11:48:10 +02:00
dm-thin-metadata.h
dm-thin.c
dm-uevent.c
dm-uevent.h
dm-unstripe.c
dm-verity-fec.c dm verity fec: fix misaligned RS roots IO 2021-04-28 13:16:50 +02:00
dm-verity-fec.h dm verity fec: fix misaligned RS roots IO 2021-04-28 13:16:50 +02:00
dm-verity-target.c dm verity: set DM_TARGET_IMMUTABLE feature flag 2022-06-06 08:24:22 +02:00
dm-verity.h
dm-writecache.c dm writecache: set a default MAX_WRITEBACK_JOBS 2022-08-25 11:15:30 +02:00
dm-zero.c
dm-zoned-metadata.c
dm-zoned-reclaim.c
dm-zoned-target.c
dm-zoned.h
dm.c dm: return early from dm_pr_call() if DM device is suspended 2022-08-25 11:15:03 +02:00
dm.h
Kconfig
Makefile
md-bitmap.c md/bitmap: don't set sb values if can't pass sanity check 2022-06-14 16:59:15 +02:00
md-bitmap.h
md-cluster.c md/cluster: fix deadlock when node is doing resync job 2020-12-30 11:26:16 +01:00
md-cluster.h
md-faulty.c
md-linear.c
md-linear.h
md-multipath.c
md-multipath.h
md.c md: call __md_stop_writes in md_stop 2022-09-05 10:26:32 +02:00
md.h
raid0.c md: Replace snprintf with scnprintf 2022-10-26 13:19:42 +02:00
raid0.h
raid1-10.c
raid1.c md/raid1: properly indicate failure when ending a failed write request 2021-05-22 10:59:20 +02:00
raid1.h
raid5-cache.c
raid5-log.h
raid5-ppl.c
raid5.c md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d 2022-10-26 13:19:41 +02:00
raid5.h
raid10.c md-raid10: fix KASAN warning 2022-08-25 11:14:55 +02:00
raid10.h