Skip to content
This repository has been archived by the owner on Nov 13, 2019. It is now read-only.

Commit

Permalink
Merge tag 'LA.UM.7.4.r1-03900-8x98.0' into neutrino-msm-mata-4.4
Browse files Browse the repository at this point in the history
"LA.UM.7.4.r1-03900-8x98.0"

* tag 'LA.UM.7.4.r1-03900-8x98.0':
  msm: ipa3: Fix to validate the user inputs
  icnss: NULL terminate the fw build timestamp string
  xfrm: validate template mode
  defconfig: msm: Disable EXT2 and EXT3 FS configs for MSM8998
  msm:ipa:Prevent rt rule deletion if rt rule id is invalid
  msm: kgsl: create sysfs entries to expose memory usage

Signed-off-by: Adam W. Willis <return.of.octobot@gmail.com>
  • Loading branch information
0ctobot committed Nov 10, 2018
2 parents d5634a3 + e31c601 commit a9968a6
Show file tree
Hide file tree
Showing 12 changed files with 174 additions and 11 deletions.
4 changes: 1 addition & 3 deletions arch/arm/configs/msmcortex_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -484,9 +484,7 @@ CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_MSM_TZ_LOG=y
CONFIG_SENSORS_SSC=y
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT3_FS=y
CONFIG_EXT4_FS=y
CONFIG_EXT4_FS_SECURITY=y
CONFIG_FUSE_FS=y
CONFIG_MSDOS_FS=y
Expand Down
4 changes: 1 addition & 3 deletions arch/arm64/configs/msmcortex-perf_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -609,9 +609,7 @@ CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_MSM_TZ_LOG=y
CONFIG_SENSORS_SSC=y
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT3_FS=y
CONFIG_EXT4_FS=y
CONFIG_EXT4_FS_SECURITY=y
CONFIG_EXT4_ENCRYPTION=y
CONFIG_EXT4_FS_ENCRYPTION=y
Expand Down
4 changes: 1 addition & 3 deletions arch/arm64/configs/msmcortex_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,7 @@ CONFIG_ANDROID=y
CONFIG_ANDROID_BINDER_IPC=y
CONFIG_MSM_TZ_LOG=y
CONFIG_SENSORS_SSC=y
CONFIG_EXT2_FS=y
CONFIG_EXT2_FS_XATTR=y
CONFIG_EXT3_FS=y
CONFIG_EXT4_FS=y
CONFIG_EXT4_FS_SECURITY=y
CONFIG_EXT4_ENCRYPTION=y
CONFIG_EXT4_FS_ENCRYPTION=y
Expand Down
11 changes: 10 additions & 1 deletion drivers/gpu/msm/kgsl.c
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ static void kgsl_mem_entry_detach_process(struct kgsl_mem_entry *entry)

type = kgsl_memdesc_usermem_type(&entry->memdesc);
entry->priv->stats[type].cur -= entry->memdesc.size;

if (type != KGSL_MEM_ENTRY_ION)
entry->priv->gpumem_mapped -= entry->memdesc.mapsize;

spin_unlock(&entry->priv->mem_lock);

kgsl_mmu_put_gpuaddr(&entry->memdesc);
Expand Down Expand Up @@ -4166,13 +4170,18 @@ static int
kgsl_gpumem_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
{
struct kgsl_mem_entry *entry = vma->vm_private_data;
int ret;

if (!entry)
return VM_FAULT_SIGBUS;
if (!entry->memdesc.ops || !entry->memdesc.ops->vmfault)
return VM_FAULT_SIGBUS;

return entry->memdesc.ops->vmfault(&entry->memdesc, vma, vmf);
ret = entry->memdesc.ops->vmfault(&entry->memdesc, vma, vmf);
if ((ret == 0) || (ret == VM_FAULT_NOPAGE))
entry->priv->gpumem_mapped += PAGE_SIZE;

return ret;
}

static void
Expand Down
2 changes: 2 additions & 0 deletions drivers/gpu/msm/kgsl_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ struct kgsl_context {
* @kobj: Pointer to a kobj for the sysfs directory for this process
* @debug_root: Pointer to the debugfs root for this process
* @stats: Memory allocation statistics for this process
* @gpumem_mapped: KGSL memory mapped in the process address space
* @syncsource_idr: sync sources created by this process
* @syncsource_lock: Spinlock to protect the syncsource idr
* @fd_count: Counter for the number of FDs for this process
Expand All @@ -438,6 +439,7 @@ struct kgsl_process_private {
uint64_t cur;
uint64_t max;
} stats[KGSL_MEM_ENTRY_MAX];
uint64_t gpumem_mapped;
struct idr syncsource_idr;
spinlock_t syncsource_lock;
int fd_count;
Expand Down
75 changes: 75 additions & 0 deletions drivers/gpu/msm/kgsl_sharedmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,75 @@ struct mem_entry_stats {

static void kgsl_cma_unlock_secure(struct kgsl_memdesc *memdesc);

static ssize_t
imported_mem_show(struct kgsl_process_private *priv,
int type, char *buf)
{
struct kgsl_mem_entry *entry;
uint64_t imported_mem = 0;
int id = 0;

spin_lock(&priv->mem_lock);
for (entry = idr_get_next(&priv->mem_idr, &id); entry;
id++, entry = idr_get_next(&priv->mem_idr, &id)) {

int egl_surface_count = 0, egl_image_count = 0;
struct kgsl_memdesc *m;

if (kgsl_mem_entry_get(entry) == 0)
continue;
spin_unlock(&priv->mem_lock);

m = &entry->memdesc;
if (kgsl_memdesc_usermem_type(m) == KGSL_MEM_ENTRY_ION) {
kgsl_get_egl_counts(entry, &egl_surface_count,
&egl_image_count);

if (kgsl_memdesc_get_memtype(m) ==
KGSL_MEMTYPE_EGL_SURFACE)
imported_mem += m->size;
else if (egl_surface_count == 0) {
uint64_t size = m->size;

do_div(size, (egl_image_count ?
egl_image_count : 1));
imported_mem += size;
}
}

kgsl_mem_entry_put(entry);
spin_lock(&priv->mem_lock);
}
spin_unlock(&priv->mem_lock);

return scnprintf(buf, PAGE_SIZE, "%llu\n", imported_mem);
}

static ssize_t
gpumem_mapped_show(struct kgsl_process_private *priv,
int type, char *buf)
{
return scnprintf(buf, PAGE_SIZE, "%llu\n",
priv->gpumem_mapped);
}

static ssize_t
gpumem_unmapped_show(struct kgsl_process_private *priv, int type, char *buf)
{
if (priv->gpumem_mapped > priv->stats[type].cur)
return -EIO;

return scnprintf(buf, PAGE_SIZE, "%llu\n",
priv->stats[type].cur - priv->gpumem_mapped);
}

static struct kgsl_mem_entry_attribute debug_memstats[] = {
__MEM_ENTRY_ATTR(0, imported_mem, imported_mem_show),
__MEM_ENTRY_ATTR(0, gpumem_mapped, gpumem_mapped_show),
__MEM_ENTRY_ATTR(KGSL_MEM_ENTRY_KERNEL, gpumem_unmapped,
gpumem_unmapped_show),
};

/**
* Show the current amount of memory allocated for the given memtype
*/
Expand Down Expand Up @@ -220,7 +289,13 @@ void kgsl_process_init_sysfs(struct kgsl_device *device,
&mem_stats[i].max_attr.attr))
WARN(1, "Couldn't create sysfs file '%s'\n",
mem_stats[i].max_attr.attr.name);
}

for (i = 0; i < ARRAY_SIZE(debug_memstats); i++) {
if (sysfs_create_file(&private->kobj,
&debug_memstats[i].attr))
WARN(1, "Couldn't create sysfs file '%s'\n",
debug_memstats[i].attr.name);
}
}

Expand Down
14 changes: 14 additions & 0 deletions drivers/platform/msm/ipa/ipa_v2/ipa_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ enum nat_table_type {
#define NAT_TABLE_ENTRY_SIZE_BYTE 32
#define NAT_INTEX_TABLE_ENTRY_SIZE_BYTE 4

/*
* Max NAT table entries is limited 1000 entries.
* Limit the memory size required by user to prevent kernel memory starvation
*/
#define IPA_TABLE_MAX_ENTRIES 1000
#define MAX_ALLOC_NAT_SIZE (IPA_TABLE_MAX_ENTRIES * NAT_TABLE_ENTRY_SIZE_BYTE)

static int ipa_nat_vma_fault_remap(
struct vm_area_struct *vma, struct vm_fault *vmf)
{
Expand Down Expand Up @@ -270,6 +277,13 @@ int ipa2_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
goto bail;
}

if (mem->size > MAX_ALLOC_NAT_SIZE) {
IPAERR("Trying allocate more size = %zu, Max allowed = %d\n",
mem->size, MAX_ALLOC_NAT_SIZE);
result = -EPERM;
goto bail;
}

if (mem->size <= 0 ||
nat_ctx->is_dev_init == true) {
IPAERR_RL("Invalid Parameters or device is already init\n");
Expand Down
23 changes: 23 additions & 0 deletions drivers/platform/msm/ipa/ipa_v2/ipa_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1342,6 +1342,8 @@ int ipa2_reset_rt(enum ipa_ip_type ip, bool user_only)
struct ipa_rt_entry *rule_next;
struct ipa_rt_tbl_set *rset;
u32 apps_start_idx;
struct ipa_hdr_entry *hdr_entry;
struct ipa_hdr_proc_ctx_entry *hdr_proc_entry;
int id;
bool tbl_user = false;

Expand Down Expand Up @@ -1395,6 +1397,27 @@ int ipa2_reset_rt(enum ipa_ip_type ip, bool user_only)
if (!user_only ||
rule->ipacm_installed) {
list_del(&rule->link);
if (rule->hdr) {
hdr_entry = ipa_id_find(
rule->rule.hdr_hdl);
if (!hdr_entry ||
hdr_entry->cookie != IPA_HDR_COOKIE) {
IPAERR_RL(
"Header already deleted\n");
return -EINVAL;
}
} else if (rule->proc_ctx) {
hdr_proc_entry =
ipa_id_find(
rule->rule.hdr_proc_ctx_hdl);
if (!hdr_proc_entry ||
hdr_proc_entry->cookie !=
IPA_PROC_HDR_COOKIE) {
IPAERR_RL(
"Proc entry already deleted\n");
return -EINVAL;
}
}
tbl->rule_cnt--;
if (rule->hdr)
__ipa_release_hdr(rule->hdr->id);
Expand Down
14 changes: 14 additions & 0 deletions drivers/platform/msm/ipa/ipa_v3/ipa_nat.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ enum nat_table_type {
#define NAT_TABLE_ENTRY_SIZE_BYTE 32
#define NAT_INTEX_TABLE_ENTRY_SIZE_BYTE 4

/*
* Max NAT table entries is limited 1000 entries.
* Limit the memory size required by user to prevent kernel memory starvation
*/
#define IPA_TABLE_MAX_ENTRIES 1000
#define MAX_ALLOC_NAT_SIZE (IPA_TABLE_MAX_ENTRIES * NAT_TABLE_ENTRY_SIZE_BYTE)

static int ipa3_nat_vma_fault_remap(
struct vm_area_struct *vma, struct vm_fault *vmf)
{
Expand Down Expand Up @@ -272,6 +279,13 @@ int ipa3_allocate_nat_device(struct ipa_ioc_nat_alloc_mem *mem)
goto bail;
}

if (mem->size > MAX_ALLOC_NAT_SIZE) {
IPAERR("Trying allocate more size = %zu, Max allowed = %d\n",
mem->size, MAX_ALLOC_NAT_SIZE);
result = -EPERM;
goto bail;
}

if (mem->size <= 0 ||
nat_ctx->is_dev_init == true) {
IPAERR_RL("Invalid Parameters or device is already init\n");
Expand Down
27 changes: 26 additions & 1 deletion drivers/platform/msm/ipa/ipa_v3/ipa_rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1486,6 +1486,8 @@ int ipa3_reset_rt(enum ipa_ip_type ip, bool user_only)
struct ipa3_rt_entry *rule;
struct ipa3_rt_entry *rule_next;
struct ipa3_rt_tbl_set *rset;
struct ipa3_hdr_entry *hdr_entry;
struct ipa3_hdr_proc_ctx_entry *hdr_proc_entry;
u32 apps_start_idx;
int id;
bool tbl_user = false;
Expand Down Expand Up @@ -1539,14 +1541,37 @@ int ipa3_reset_rt(enum ipa_ip_type ip, bool user_only)
if (!user_only ||
rule->ipacm_installed) {
list_del(&rule->link);
if (rule->hdr) {
hdr_entry = ipa3_id_find(
rule->rule.hdr_hdl);
if (!hdr_entry ||
hdr_entry->cookie != IPA_HDR_COOKIE) {
IPAERR_RL(
"Header already deleted\n");
return -EINVAL;
}
} else if (rule->proc_ctx) {
hdr_proc_entry =
ipa3_id_find(
rule->rule.hdr_proc_ctx_hdl);
if (!hdr_proc_entry ||
hdr_proc_entry->cookie !=
IPA_PROC_HDR_COOKIE) {
IPAERR_RL(
"Proc entry already deleted\n");
return -EINVAL;
}
}
tbl->rule_cnt--;
if (rule->hdr)
__ipa3_release_hdr(rule->hdr->id);
else if (rule->proc_ctx)
__ipa3_release_hdr_proc_ctx(
rule->proc_ctx->id);
rule->cookie = 0;
idr_remove(&tbl->rule_ids, rule->rule_id);
if (!rule->rule_id_valid)
idr_remove(&tbl->rule_ids,
rule->rule_id);
id = rule->id;
kmem_cache_free(ipa3_ctx->rt_rule_cache, rule);

Expand Down
4 changes: 4 additions & 0 deletions drivers/soc/qcom/icnss.c
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,8 @@ EXPORT_SYMBOL(icnss_disable_irq);

int icnss_get_soc_info(struct device *dev, struct icnss_soc_info *info)
{
char *fw_build_timestamp = NULL;

if (!penv || !dev) {
icnss_pr_err("Platform driver not initialized\n");
return -EINVAL;
Expand All @@ -3047,6 +3049,8 @@ int icnss_get_soc_info(struct device *dev, struct icnss_soc_info *info)
info->board_id = penv->board_info.board_id;
info->soc_id = penv->soc_info.soc_id;
info->fw_version = penv->fw_version_info.fw_version;
fw_build_timestamp = penv->fw_version_info.fw_build_timestamp;
fw_build_timestamp[QMI_WLFW_MAX_TIMESTAMP_LEN_V01] = '\0';
strlcpy(info->fw_build_timestamp,
penv->fw_version_info.fw_build_timestamp,
QMI_WLFW_MAX_TIMESTAMP_LEN_V01 + 1);
Expand Down
3 changes: 3 additions & 0 deletions net/xfrm/xfrm_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1404,6 +1404,9 @@ static int validate_tmpl(int nr, struct xfrm_user_tmpl *ut, u16 family)
(ut[i].family != prev_family))
return -EINVAL;

if (ut[i].mode >= XFRM_MODE_MAX)
return -EINVAL;

prev_family = ut[i].family;

switch (ut[i].family) {
Expand Down

0 comments on commit a9968a6

Please sign in to comment.