firmware: qcom: pas_tee: handle a NULL resource table
PATCH 1/1 firmware: qcom: pas_tee: handle a NULL resource table
Stopping a remote processor clears its cached resource table pointer but leaves the size set. On restart, qcom_pas_tee_get_rsc_table() copies from NULL when the firmware has no resource table:
pc : __pi_memcpy_generic+0x110/0x22c lr : qcom_pas_tee_get_rsc_table+0xf0/0x244
Zero the input size when the table is NULL so the copy is skipped.
--- drivers/firmware/qcom/qcom_pas_tee.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/firmware/qcom/qcom_pas_tee.c +4 -1
@@ -230,12 +230,15 @@ static void *qcom_pas_tee_get_rsc_table(struct device *dev, }, [1 ] = { .attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT , - .u.memref.size = input_rt_size, } };void *rt_buf =NULL ;int ret; +if (!input_rt) + input_rt_size =0 ; + param[1 ].u.memref.size = input_rt_size; + ret =tee_client_invoke_func (data->ctx, &inv_arg, param);if (ret <0 || inv_arg.ret !=0 ) { dev_err(dev, "PAS get RT failed, pas_id: %d, ret: %d, err: 0x%x\n",
Signature · 1 line
2.54.0
Quoted 39 lines · Jorge Ramirez-Ortiz
Stopping a remote processor clears its cached resource table pointer but leaves the size set. On restart,
qcom_pas_tee_get_rsc_table()copies from NULL when the firmware has no resource table:pc : __pi_memcpy_generic+0x110/0x22c lr : qcom_pas_tee_get_rsc_table+0xf0/0x244Zero the input size when the table is NULL so the copy is skipped.
Fixes b6f7978da0c4 ("firmware: qcom: Add a PAS TEE service")Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- drivers/firmware/qcom/qcom_pas_tee.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/firmware/qcom/qcom_pas_tee.c +4
-1@@ -230,12 +230,15 @@ static void *qcom_pas_tee_get_rsc_table(struct device *dev, }, [1 ] = { .attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT , - .u.memref.size = input_rt_size, } };void *rt_buf =NULL ;int ret; +if (!input_rt) + input_rt_size =0 ; + param[1 ].u.memref.size = input_rt_size; + ret =tee_client_invoke_func (data->ctx, &inv_arg, param);if (ret <0 || inv_arg.ret !=0 ) { dev_err(dev, "PAS get RT failed, pas_id: %d, ret: %d, err: 0x%x\n",Signature · 1 line
2.54.0
could we merge this? as mentioned, it protects against blindly dereferencin a pointer that might be null. I submitted another patch that should address the issue in a higher level interface but regardless I see nothing wrong with catching it here as well.
TIA
Sumit Garg
maintainerHey Jorge,
Quoted 31 lines · Jorge Ramirez
Quoted 29 lines · Jorge Ramirez-Ortiz
Stopping a remote processor clears its cached resource table pointer but leaves the size set. On restart,
qcom_pas_tee_get_rsc_table()copies from NULL when the firmware has no resource table:pc : __pi_memcpy_generic+0x110/0x22c lr : qcom_pas_tee_get_rsc_table+0xf0/0x244Zero the input size when the table is NULL so the copy is skipped.
Fixes b6f7978da0c4 ("firmware: qcom: Add a PAS TEE service")Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- drivers/firmware/qcom/qcom_pas_tee.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/firmware/qcom/qcom_pas_tee.c +0
-1@@ -230,12 +230,15 @@ static void *qcom_pas_tee_get_rsc_table(struct device *dev, }, [1 ] = { .attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT , - .u.memref.size = input_rt_size, } };void *rt_buf =NULL ;int ret;
Quoted 16 lines
Quoted 10 lines
drivers/firmware/qcom/qcom_pas_tee.c +4
-1+if (!input_rt) + input_rt_size =0 ; + param[1 ].u.memref.size = input_rt_size; + ret =tee_client_invoke_func (data->ctx, &inv_arg, param);if (ret <0 || inv_arg.ret !=0 ) { dev_err(dev, "PAS get RT failed, pas_id: %d, ret: %d, err: 0x%x\n", --2.54.0
could we merge this? as mentioned, it protects against blindly dereferencin a pointer that might be null. I submitted another patch that should address the issue in a higher level interface but regardless I see nothing wrong with catching it here as well.
I would rather prefer to error out to the caller rather than fixing it here. Doesn't tee_client_invoke_func() already error out or it causes a kernel panic instead?
-Sumit
Quoted 52 lines · Sumit Garg
Hey Jorge,
Quoted 31 lines · Jorge Ramirez
Quoted 29 lines · Jorge Ramirez-Ortiz
Stopping a remote processor clears its cached resource table pointer but leaves the size set. On restart,
qcom_pas_tee_get_rsc_table()copies from NULL when the firmware has no resource table:pc : __pi_memcpy_generic+0x110/0x22c lr : qcom_pas_tee_get_rsc_table+0xf0/0x244Zero the input size when the table is NULL so the copy is skipped.
Fixes b6f7978da0c4 ("firmware: qcom: Add a PAS TEE service")Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- drivers/firmware/qcom/qcom_pas_tee.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/firmware/qcom/qcom_pas_tee.c +0
-1@@ -230,12 +230,15 @@ static void *qcom_pas_tee_get_rsc_table(struct device *dev, }, [1 ] = { .attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT , - .u.memref.size = input_rt_size, } };void *rt_buf =NULL ;int ret;Quoted 16 lines
Quoted 10 lines
drivers/firmware/qcom/qcom_pas_tee.c +4
-1+if (!input_rt) + input_rt_size =0 ; + param[1 ].u.memref.size = input_rt_size; + ret =tee_client_invoke_func (data->ctx, &inv_arg, param);if (ret <0 || inv_arg.ret !=0 ) { dev_err(dev, "PAS get RT failed, pas_id: %d, ret: %d, err: 0x%x\n", --2.54.0
could we merge this? as mentioned, it protects against blindly dereferencin a pointer that might be null. I submitted another patch that should address the issue in a higher level interface but regardless I see nothing wrong with catching it here as well.
Quoted 3 lines
I would rather prefer to error out to the caller rather than fixing it here. Doesn't
tee_client_invoke_func()already error out or it causes a kernel panic instead?
it panics
the advantage of having it here as well is that other backend(s) are not restricted in case they chose to take different actions.
Quoted 2 lines
-Sumit
Quoted 54 lines · Jorge Ramirez
Quoted 52 lines · Sumit Garg
Hey Jorge,
Quoted 47 lines · Jorge Ramirez
Quoted 37 lines · Jorge Ramirez-Ortiz
Stopping a remote processor clears its cached resource table pointer but leaves the size set. On restart,
qcom_pas_tee_get_rsc_table()copies from NULL when the firmware has no resource table:pc : __pi_memcpy_generic+0x110/0x22c lr : qcom_pas_tee_get_rsc_table+0xf0/0x244Zero the input size when the table is NULL so the copy is skipped.
Fixes b6f7978da0c4 ("firmware: qcom: Add a PAS TEE service")Signed-off-by Jorge Ramirez-Ortiz <[email protected]>--- drivers/firmware/qcom/qcom_pas_tee.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)drivers/firmware/qcom/qcom_pas_tee.c +4
-2@@ -230,12 +230,15 @@ static void *qcom_pas_tee_get_rsc_table(struct device *dev, }, [1 ] = { .attr =TEE_IOCTL_PARAM_ATTR_TYPE_MEMREF_INOUT , - .u.memref.size = input_rt_size, } };void *rt_buf =NULL ;int ret; +if (!input_rt) + input_rt_size =0 ; + param[1 ].u.memref.size = input_rt_size; + ret =tee_client_invoke_func (data->ctx, &inv_arg, param);if (ret <0 || inv_arg.ret !=0 ) { dev_err(dev, "PAS get RT failed, pas_id: %d, ret: %d, err: 0x%x\n", --Quoted 2 lines
2.54.0
could we merge this? as mentioned, it protects against blindly dereferencin a pointer that might be null. I submitted another patch that should address the issue in a higher level interface but regardless I see nothing wrong with catching it here as well.
Quoted 9 lines
Quoted 3 lines
I would rather prefer to error out to the caller rather than fixing it here. Doesn't
tee_client_invoke_func()already error out or it causes a kernel panic instead?it panics
the advantage of having it here as well is that other backend(s) are not restricted in case they chose to take different actions.
Ah I see, feel free to add:
Bjorn,
Since this is fixing a kernel panic, is there any chance you can get this fix in for the v7.3 release?
-Sumit
Quoted 4 lines · Jorge Ramirez-Ortiz
Stopping a remote processor clears its cached resource table pointer but leaves the size set. On restart,
qcom_pas_tee_get_rsc_table()copies from NULL when the firmware has no resource table:
Quoted 8 lines
pc : __pi_memcpy_generic+0x110/0x22c lr : qcom_pas_tee_get_rsc_table+0xf0/0x244Zero the input size when the table is NULL so the copy is skipped.
Fixes b6f7978da0c4 ("firmware: qcom: Add a PAS TEE service")Signed-off-by Jorge Ramirez-Ortiz <[email protected]>---
Regards,
Harshal
Quoted 8 lines · Jorge Ramirez-Ortiz
Stopping a remote processor clears its cached resource table pointer but leaves the size set. On restart,
qcom_pas_tee_get_rsc_table()copies from NULL when the firmware has no resource table:pc : __pi_memcpy_generic+0x110/0x22c lr : qcom_pas_tee_get_rsc_table+0xf0/0x244[...]
Applied, thanks!
[1/1] firmware: qcom: pas_tee: handle a NULL resource table
commit: c44eef6401b625f292f51e854e5a829e2e6748e1
Best regards,
Signature · 1 line
Bjorn Andersson <[email protected]>