mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-08 21:22:09 -04:00
input: misc: Validate input pattern count in pattern_s_dbgfs_write
Add a check for number of input patterns detected in string read from userspace in pattern_s_dbgfs_write() API, to avoid out-of-bounds write in a local array. Change-Id: Ic35561ae34f95c67fbd54ae4db4a7174342f45f4 Signed-off-by: Jishnu Prakash <quic_jprakash@quicinc.com>
This commit is contained in:
parent
6c5f5fe18a
commit
7ce6eef9ba
1 changed files with 6 additions and 1 deletions
|
|
@ -1,7 +1,7 @@
|
|||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
|
||||
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
* Copyright (c) 2022-2023, Qualcomm Innovation Center, Inc. All rights reserved.
|
||||
*/
|
||||
|
||||
#include <linux/atomic.h>
|
||||
|
|
@ -3035,6 +3035,11 @@ static ssize_t pattern_s_dbgfs_write(struct file *fp,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
if (i >= ARRAY_SIZE(tmp)) {
|
||||
pr_err("too many patterns in input string\n");
|
||||
rc = -EINVAL;
|
||||
goto exit;
|
||||
}
|
||||
tmp[i++] = val;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue