Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ed1bd95 authored by Abdulla Anam's avatar Abdulla Anam Committed by Gerrit - the friendly Code Review server
Browse files

msm: vidc: use %pK instead of %p which respects kptr_restrict sysctl



Hide kernel pointers from unprivileged ussers by using %pK format-
specifier instead of %p. This respects the kptr_restrict sysctl
setting which is by default on. So by default %pK will print zeroes
as address. echo 1 to kptr_restrict to print proper kernel addresses.

CRs-Fixed: 987018
Change-Id: I4772257a557c6730ecc0624cbc8e5614e893e9fd
Signed-off-by: default avatarAbdulla Anam <abdullahanam@codeaurora.org>
parent ff605d64
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -90,7 +90,7 @@ static int msm_vidc_table_get_target_freq(struct devfreq *dev,
	int i = 0;

	if (!dev || !frequency || !flag) {
		dprintk(VIDC_ERR, "%s: Invalid params %p, %p, %p\n",
		dprintk(VIDC_ERR, "%s: Invalid params %pK, %pK, %pK\n",
			__func__, dev, frequency, flag);
		return -EINVAL;
	}
@@ -173,7 +173,7 @@ static int msm_vidc_free_bus_table(struct platform_device *pdev,
	int rc = 0, i = 0;

	if (!pdev || !data) {
		dprintk(VIDC_ERR, "%s: invalid args %p %p\n",
		dprintk(VIDC_ERR, "%s: invalid args %pK %pK\n",
			__func__, pdev, data);
		return -EINVAL;
	}
@@ -197,7 +197,7 @@ static int msm_vidc_load_bus_table(struct platform_device *pdev,
	struct device_node *child_node = NULL;

	if (!pdev || !data) {
		dprintk(VIDC_ERR, "%s: invalid args %p %p\n",
		dprintk(VIDC_ERR, "%s: invalid args %pK %pK\n",
			__func__, pdev, data);
		return -EINVAL;
	}
+3 −3
Original line number Diff line number Diff line
@@ -1462,7 +1462,7 @@ int create_pkt_cmd_session_set_property(
			break;
		default:
			dprintk(VIDC_ERR,
					"Invalid Rate control setting: %p\n",
					"Invalid Rate control setting: %pK\n",
					pdata);
			break;
		}
@@ -2200,7 +2200,7 @@ int create_pkt_ssr_cmd(enum hal_ssr_trigger_type type,
		struct hfi_cmd_sys_test_ssr_packet *pkt)
{
	if (!pkt) {
		dprintk(VIDC_ERR, "Invalid params, device: %p\n", pkt);
		dprintk(VIDC_ERR, "Invalid params, device: %pK\n", pkt);
		return -EINVAL;
	}
	pkt->size = sizeof(struct hfi_cmd_sys_test_ssr_packet);
@@ -2213,7 +2213,7 @@ int create_pkt_cmd_sys_image_version(
		struct hfi_cmd_sys_get_property_packet *pkt)
{
	if (!pkt) {
		dprintk(VIDC_ERR, "%s invalid param :%p\n", __func__, pkt);
		dprintk(VIDC_ERR, "%s invalid param :%pK\n", __func__, pkt);
		return -EINVAL;
	}
	pkt->size = sizeof(struct hfi_cmd_sys_get_property_packet);
+3 −3
Original line number Diff line number Diff line
@@ -955,7 +955,7 @@ static enum vidc_status hfi_parse_init_done_properties(
		}
		default:
			dprintk(VIDC_DBG,
				"%s: default case - data_ptr %p, prop_id 0x%x\n",
				"%s: default case - data_ptr %pK, prop_id 0x%x\n",
				__func__, data_ptr, prop_id);
			break;
		}
@@ -1055,7 +1055,7 @@ static void hfi_process_sess_get_prop_profile_level(
	dprintk(VIDC_DBG, "Entered %s\n", __func__);
	if (!prop) {
		dprintk(VIDC_ERR,
			"hal_process_sess_get_profile_level: bad_prop: %p\n",
			"hal_process_sess_get_profile_level: bad_prop: %pK\n",
			prop);
		return;
	}
@@ -1086,7 +1086,7 @@ static void hfi_process_sess_get_prop_buf_req(

	if (!prop) {
		dprintk(VIDC_ERR,
			"hal_process_sess_get_prop_buf_req: bad_prop: %p\n",
			"hal_process_sess_get_prop_buf_req: bad_prop: %pK\n",
			prop);
		return;
	}
+16 −16
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ static int get_device_address(struct smem_client *smem_client,
	struct context_bank_info *cb = NULL;

	if (!iova || !buffer_size || !hndl || !smem_client || !mapping_info) {
		dprintk(VIDC_ERR, "Invalid params: %p, %p, %p, %p\n",
		dprintk(VIDC_ERR, "Invalid params: %pK, %pK, %pK, %pK\n",
				smem_client, hndl, iova, buffer_size);
		return -EINVAL;
	}
@@ -107,7 +107,7 @@ static int get_device_address(struct smem_client *smem_client,
		}
		if (table->sgl) {
			dprintk(VIDC_DBG,
				"%s: CB : %s, DMA buf: %p, device: %p, attach: %p, table: %p, table sgl: %p, rc: %d, dma_address: %pa\n",
				"%s: CB : %s, DMA buf: %pK, device: %pK, attach: %pK, table: %pK, table sgl: %pK, rc: %d, dma_address: %pa\n",
				__func__, cb->name, buf, cb->dev, attach,
				table, table->sgl, rc,
				&table->sgl->dma_address);
@@ -137,7 +137,7 @@ static int get_device_address(struct smem_client *smem_client,
		}
	}

	dprintk(VIDC_DBG, "mapped ion handle %p to %pa\n", hndl, iova);
	dprintk(VIDC_DBG, "mapped ion handle %pK to %pa\n", hndl, iova);
	return 0;
mem_map_sg_failed:
	dma_buf_unmap_attachment(attach, table, DMA_BIDIRECTIONAL);
@@ -157,7 +157,7 @@ static void put_device_address(struct smem_client *smem_client,
	struct ion_client *clnt = NULL;

	if (!hndl || !smem_client || !mapping_info) {
		dprintk(VIDC_WARN, "Invalid params: %p, %p\n",
		dprintk(VIDC_WARN, "Invalid params: %pK, %pK\n",
				smem_client, hndl);
		return;
	}
@@ -175,7 +175,7 @@ static void put_device_address(struct smem_client *smem_client,
	}
	if (is_iommu_present(smem_client->res)) {
		dprintk(VIDC_DBG,
			"Calling dma_unmap_sg - device: %p, address: %pa, buf: %p, table: %p, attach: %p\n",
			"Calling dma_unmap_sg - device: %pK, address: %pa, buf: %pK, table: %pK, attach: %pK\n",
			mapping_info->dev,
			&mapping_info->table->sgl->dma_address,
			mapping_info->buf, mapping_info->table,
@@ -204,9 +204,9 @@ static int ion_user_to_kernel(struct smem_client *client, int fd, u32 offset,
	unsigned long ion_flags = 0;

	hndl = ion_import_dma_buf(client->clnt, fd);
	dprintk(VIDC_DBG, "%s ion handle: %p\n", __func__, hndl);
	dprintk(VIDC_DBG, "%s ion handle: %pK\n", __func__, hndl);
	if (IS_ERR_OR_NULL(hndl)) {
		dprintk(VIDC_ERR, "Failed to get handle: %p, %d, %d, %p\n",
		dprintk(VIDC_ERR, "Failed to get handle: %pK, %d, %d, %pK\n",
				client, fd, offset, hndl);
		rc = -ENOMEM;
		goto fail_import_fd;
@@ -242,7 +242,7 @@ static int ion_user_to_kernel(struct smem_client *client, int fd, u32 offset,
		goto fail_device_address;
	}
	dprintk(VIDC_DBG,
		"%s: ion_handle = %p, fd = %d, device_addr = %pa, size = %zx, kvaddr = %p, buffer_type = %d, flags = %#lx\n",
		"%s: ion_handle = %pK, fd = %d, device_addr = %pa, size = %zx, kvaddr = %pK, buffer_type = %d, flags = %#lx\n",
		__func__, mem->smem_priv, fd, &mem->device_addr, mem->size,
		mem->kvaddr, mem->buffer_type, mem->flags);
	return rc;
@@ -339,7 +339,7 @@ static int alloc_ion_mem(struct smem_client *client, size_t size, u32 align,
	hndl = ion_alloc(client->clnt, size, align, heap_mask, ion_flags);
	if (IS_ERR_OR_NULL(hndl)) {
		dprintk(VIDC_ERR,
		"Failed to allocate shared memory = %p, %zx, %d, %#x\n",
		"Failed to allocate shared memory = %pK, %zx, %d, %#x\n",
		client, size, align, flags);
		rc = -ENOMEM;
		goto fail_shared_mem_alloc;
@@ -377,7 +377,7 @@ static int alloc_ion_mem(struct smem_client *client, size_t size, u32 align,
	}
	mem->size = size;
	dprintk(VIDC_DBG,
		"%s: ion_handle = %p, device_addr = %pa, size = %#zx, kvaddr = %p, buffer_type = %#x, flags = %#lx\n",
		"%s: ion_handle = %pK, device_addr = %pa, size = %#zx, kvaddr = %pK, buffer_type = %#x, flags = %#lx\n",
		__func__, mem->smem_priv, &mem->device_addr,
		mem->size, mem->kvaddr, mem->buffer_type, mem->flags);
	return rc;
@@ -393,7 +393,7 @@ fail_shared_mem_alloc:
static void free_ion_mem(struct smem_client *client, struct msm_smem *mem)
{
	dprintk(VIDC_DBG,
		"%s: ion_handle = %p, device_addr = %pa, size = %#zx, kvaddr = %p, buffer_type = %#x\n",
		"%s: ion_handle = %pK, device_addr = %pa, size = %#zx, kvaddr = %pK, buffer_type = %#x\n",
		__func__, mem->smem_priv, &mem->device_addr,
		mem->size, mem->kvaddr, mem->buffer_type);

@@ -408,7 +408,7 @@ static void free_ion_mem(struct smem_client *client, struct msm_smem *mem)
				(u32)mem->buffer_type, -1, mem->size, -1,
				mem->flags, -1);
		dprintk(VIDC_DBG,
			"%s: Freeing handle %p, client: %p\n",
			"%s: Freeing handle %pK, client: %pK\n",
			__func__, mem->smem_priv, client->clnt);
		ion_free(client->clnt, mem->smem_priv);
		trace_msm_smem_buffer_ion_op_end("FREE", (u32)mem->buffer_type,
@@ -469,7 +469,7 @@ bool msm_smem_compare_buffers(void *clt, int fd, void *priv)
	bool ret = false;

	if (!clt || !priv) {
		dprintk(VIDC_ERR, "Invalid params: %p, %p\n",
		dprintk(VIDC_ERR, "Invalid params: %pK, %pK\n",
			clt, priv);
		return false;
	}
@@ -486,7 +486,7 @@ static int ion_cache_operations(struct smem_client *client,
	int rc = 0;
	int msm_cache_ops = 0;
	if (!mem || !client) {
		dprintk(VIDC_ERR, "Invalid params: %p, %p\n",
		dprintk(VIDC_ERR, "Invalid params: %pK, %pK\n",
			mem, client);
		return -EINVAL;
	}
@@ -533,7 +533,7 @@ int msm_smem_cache_operations(void *clt, struct msm_smem *mem,
	struct smem_client *client = clt;
	int rc = 0;
	if (!client) {
		dprintk(VIDC_ERR, "Invalid params: %p\n",
		dprintk(VIDC_ERR, "Invalid params: %pK\n",
			client);
		return -EINVAL;
	}
@@ -684,7 +684,7 @@ struct context_bank_info *msm_smem_get_context_bank(void *clt,
				cb->buffer_type & buffer_type) {
			match = cb;
			dprintk(VIDC_DBG,
				"context bank found for CB : %s, device: %p mapping: %p\n",
				"context bank found for CB : %s, device: %pK mapping: %pK\n",
				match->name, match->dev, match->mapping);
			break;
		}
+2 −2
Original line number Diff line number Diff line
@@ -280,7 +280,7 @@ static int read_platform_resources(struct msm_vidc_core *core,
		struct platform_device *pdev)
{
	if (!core || !pdev) {
		dprintk(VIDC_ERR, "%s: Invalid params %p %p\n",
		dprintk(VIDC_ERR, "%s: Invalid params %pK %pK\n",
			__func__, core, pdev);
		return -EINVAL;
	}
@@ -657,7 +657,7 @@ static int msm_vidc_remove(struct platform_device *pdev)
	struct msm_vidc_core *core;

	if (!pdev) {
		dprintk(VIDC_ERR, "%s invalid input %p", __func__, pdev);
		dprintk(VIDC_ERR, "%s invalid input %pK", __func__, pdev);
		return -EINVAL;
	}

Loading