DivestOS/Patches/Linux_CVEs/CVE-2017-0445/ANY/0004.patch
2017-11-07 17:32:46 -05:00

182 lines
6.0 KiB
Diff

From fe160e51f02ee5db529c2e84ac8364c89cce005e Mon Sep 17 00:00:00 2001
From: Andrew Chant <achant@google.com>
Date: Tue, 6 Dec 2016 20:59:01 -0800
Subject: [PATCH] input: synaptics_dsx: remove some sysfs nodes.
Remove most sysfs entrypoints to fw_update module.
Retains check_fw, which is triggered from an
init script.
BUG: 32769717
Change-Id: I710cb37a8b5382dce7aa6a1d8748be5853a18a7a
Signed-off-by: Andrew Chant <achant@google.com>
---
drivers/input/touchscreen/Kconfig | 10 ++++++++++
drivers/input/touchscreen/synaptics_fw_update.c | 20 ++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index a42fea5862af2..64266998c2290 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -1019,6 +1019,16 @@ config TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE
To compile this driver as a module, choose M here: the
module will be called synaptics_dsx_fw_update.
+config TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
+ bool "Synaptics DSX firmware update extra sysfs attributes"
+ depends on TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE
+ help
+ Say Y here to enable support for extra sysfs attributes
+ supporting firmware update in a development environment.
+ This does not affect the core or other subsystem attributes.
+
+ If unsure, say N.
+
config SECURE_TOUCH
bool "Secure Touch"
depends on (TOUCHSCREEN_ATMEL_MXT || TOUCHSCREEN_SYNAPTICS_I2C_RMI4 || \
diff --git a/drivers/input/touchscreen/synaptics_fw_update.c b/drivers/input/touchscreen/synaptics_fw_update.c
index 8891f1c836684..360e455a5a51b 100644
--- a/drivers/input/touchscreen/synaptics_fw_update.c
+++ b/drivers/input/touchscreen/synaptics_fw_update.c
@@ -1331,6 +1331,7 @@ static int fwu_do_write_config(void)
return retval;
}
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
static int fwu_start_write_config(void)
{
int retval;
@@ -1383,6 +1384,7 @@ static int fwu_start_write_config(void)
return retval;
}
+#endif
static int fwu_do_write_lockdown(bool reset)
{
@@ -1430,6 +1432,7 @@ static int fwu_do_write_lockdown(bool reset)
return retval;
}
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
static int fwu_start_write_lockdown(void)
{
if (parse_header())
@@ -1533,6 +1536,7 @@ static int fwu_do_read_config(void)
exit:
return retval;
}
+#endif
static int fwu_do_reflash(void)
{
@@ -1767,6 +1771,7 @@ int synaptics_fw_updater(void)
}
EXPORT_SYMBOL(synaptics_fw_updater);
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
static ssize_t fwu_sysfs_show_image(struct file *data_file,
struct kobject *kobj, struct bin_attribute *attributes,
char *buf, loff_t pos, size_t count)
@@ -2021,6 +2026,7 @@ static ssize_t fwu_sysfs_write_lockdown_store(struct device *dev,
mutex_unlock(&fwu_sysfs_mutex);
return retval;
}
+#endif
static ssize_t fwu_sysfs_check_fw_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
@@ -2044,6 +2050,7 @@ static ssize_t fwu_sysfs_check_fw_store(struct device *dev,
return count;
}
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
static ssize_t fwu_sysfs_write_config_store(struct device *dev,
struct device_attribute *attr, const char *buf, size_t count)
{
@@ -2265,6 +2272,7 @@ static ssize_t fwu_sysfs_package_id_show(struct device *dev,
(pkg_id[1] << 8) | pkg_id[0],
(pkg_id[3] << 8) | pkg_id[2]);
}
+#endif
static int synaptics_rmi4_debug_dump_info(struct seq_file *m, void *v)
{
@@ -2298,6 +2306,7 @@ static void synaptics_rmi4_fwu_attn(struct synaptics_rmi4_data *rmi4_data,
return;
}
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
static struct bin_attribute dev_attr_data = {
.attr = {
.name = "data",
@@ -2307,8 +2316,10 @@ static struct bin_attribute dev_attr_data = {
.read = fwu_sysfs_show_image,
.write = fwu_sysfs_store_image,
};
+#endif
static struct device_attribute attrs[] = {
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
__ATTR(fw_name, S_IRUGO | S_IWUSR | S_IWGRP,
fwu_sysfs_image_name_show,
fwu_sysfs_image_name_store),
@@ -2318,9 +2329,11 @@ static struct device_attribute attrs[] = {
__ATTR(update_fw, S_IWUSR | S_IWGRP,
NULL,
fwu_sysfs_do_reflash_store),
+#endif
__ATTR(check_fw, S_IWUSR | S_IWGRP,
NULL,
fwu_sysfs_check_fw_store),
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
__ATTR(writeconfig, S_IWUSR | S_IWGRP,
NULL,
fwu_sysfs_write_config_store),
@@ -2360,6 +2373,7 @@ static struct device_attribute attrs[] = {
__ATTR(package_id, S_IRUGO,
fwu_sysfs_package_id_show,
synaptics_rmi4_store_error),
+#endif
};
@@ -2470,6 +2484,7 @@ static int synaptics_rmi4_fwu_init(struct synaptics_rmi4_data *rmi4_data)
INIT_DELAYED_WORK(&fwu->fwu_work, synaptics_rmi4_fwu_work);
#endif
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
retval = sysfs_create_bin_file(&rmi4_data->i2c_client->dev.kobj,
&dev_attr_data);
if (retval < 0) {
@@ -2478,6 +2493,7 @@ static int synaptics_rmi4_fwu_init(struct synaptics_rmi4_data *rmi4_data)
__func__);
goto exit_free_mem;
}
+#endif
for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) {
retval = sysfs_create_file(&rmi4_data->i2c_client->dev.kobj,
@@ -2511,7 +2527,9 @@ static int synaptics_rmi4_fwu_init(struct synaptics_rmi4_data *rmi4_data)
&attrs[attr_count].attr);
}
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
sysfs_remove_bin_file(&rmi4_data->input_dev->dev.kobj, &dev_attr_data);
+#endif
exit_free_mem:
kfree(fwu->fn_ptr);
@@ -2528,7 +2546,9 @@ static void synaptics_rmi4_fwu_remove(struct synaptics_rmi4_data *rmi4_data)
{
unsigned char attr_count;
+#ifdef CONFIG_TOUCHSCREEN_SYNAPTICS_DSX_FW_UPDATE_EXTRA_SYSFS
sysfs_remove_bin_file(&rmi4_data->input_dev->dev.kobj, &dev_attr_data);
+#endif
for (attr_count = 0; attr_count < ARRAY_SIZE(attrs); attr_count++) {
sysfs_remove_file(&rmi4_data->input_dev->dev.kobj,