From: Ekansh Gupta <quic_ekangupt@quicinc.com>
Untrusted application with access to only non-secure fastrpc device
node can attach to root_pd or static PDs if it can make the respective
init request. This can cause problems as the untrusted application
can send bad requests to root_pd or static PDs. Add changes to reject
attach to privileged PDs if the request is being made using non-secure
fastrpc device node.
Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
Cc: stable <stable@kernel.org>
Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
drivers/misc/fastrpc.c | 22 +++++++++++++++++++---
include/uapi/misc/fastrpc.h | 3 +++
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 5680856c0fb8..a7a2bcedb37e 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -2087,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
return err;
}
+static int is_attach_rejected(struct fastrpc_user *fl)
+{
+ /* Check if the device node is non-secure */
+ if (!fl->is_secure_dev) {
+ dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
+ return -EACCES;
+ }
+ return 0;
+}
+
static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
unsigned long arg)
{
@@ -2099,13 +2109,19 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd,
err = fastrpc_invoke(fl, argp);
break;
case FASTRPC_IOCTL_INIT_ATTACH:
- err = fastrpc_init_attach(fl, ROOT_PD);
+ err = is_attach_rejected(fl);
+ if (!err)
+ err = fastrpc_init_attach(fl, ROOT_PD);
break;
case FASTRPC_IOCTL_INIT_ATTACH_SNS:
- err = fastrpc_init_attach(fl, SENSORS_PD);
+ err = is_attach_rejected(fl);
+ if (!err)
+ err = fastrpc_init_attach(fl, SENSORS_PD);
break;
case FASTRPC_IOCTL_INIT_CREATE_STATIC:
- err = fastrpc_init_create_static_process(fl, argp);
+ err = is_attach_rejected(fl);
+ if (!err)
+ err = fastrpc_init_create_static_process(fl, argp);
break;
case FASTRPC_IOCTL_INIT_CREATE:
err = fastrpc_init_create_process(fl, argp);
diff --git a/include/uapi/misc/fastrpc.h b/include/uapi/misc/fastrpc.h
index f33d914d8f46..91583690bddc 100644
--- a/include/uapi/misc/fastrpc.h
+++ b/include/uapi/misc/fastrpc.h
@@ -8,11 +8,14 @@
#define FASTRPC_IOCTL_ALLOC_DMA_BUFF _IOWR('R', 1, struct fastrpc_alloc_dma_buf)
#define FASTRPC_IOCTL_FREE_DMA_BUFF _IOWR('R', 2, __u32)
#define FASTRPC_IOCTL_INVOKE _IOWR('R', 3, struct fastrpc_invoke)
+/* This ioctl is only supported with secure device nodes */
#define FASTRPC_IOCTL_INIT_ATTACH _IO('R', 4)
#define FASTRPC_IOCTL_INIT_CREATE _IOWR('R', 5, struct fastrpc_init_create)
#define FASTRPC_IOCTL_MMAP _IOWR('R', 6, struct fastrpc_req_mmap)
#define FASTRPC_IOCTL_MUNMAP _IOWR('R', 7, struct fastrpc_req_munmap)
+/* This ioctl is only supported with secure device nodes */
#define FASTRPC_IOCTL_INIT_ATTACH_SNS _IO('R', 8)
+/* This ioctl is only supported with secure device nodes */
#define FASTRPC_IOCTL_INIT_CREATE_STATIC _IOWR('R', 9, struct fastrpc_init_create_static)
#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_mem_map)
#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_mem_unmap)
--
2.25.1
Hi Srinivas Kandagatla and Ekansh Gupta,
On 6/28/24 06:45, srinivas.kandagatla@linaro.org wrote:
> From: Ekansh Gupta <quic_ekangupt@quicinc.com>
>
> Untrusted application with access to only non-secure fastrpc device
> node can attach to root_pd or static PDs if it can make the respective
> init request. This can cause problems as the untrusted application
> can send bad requests to root_pd or static PDs. Add changes to reject
> attach to privileged PDs if the request is being made using non-secure
> fastrpc device node.
>
> Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
> Cc: stable <stable@kernel.org>
> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> drivers/misc/fastrpc.c | 22 +++++++++++++++++++---
> include/uapi/misc/fastrpc.h | 3 +++
> 2 files changed, 22 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index 5680856c0fb8..a7a2bcedb37e 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -2087,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
> return err;
> }
>
> +static int is_attach_rejected(struct fastrpc_user *fl)
> +{
> + /* Check if the device node is non-secure */
> + if (!fl->is_secure_dev) {
> + dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
> + return -EACCES;
> + }
> + return 0;
> +}
This broke userspace for us. Sensors stopped working in SDM845 and other
qcom SoC devices running postmarketOS. Trying to communicate with the
fastrpc device just ends up with a permission denied error. This was
previously working. I am not sure if this is intended. Here are my two
observations:
1. if change the if condition to
`if (!fl->is_secure_dev && fl->cctx->secure)`
similar to how it's done in fastrpc's `is_session_rejected()` function,
then it works. But I am not sure if this is an valid fix. But currently,
fastrpc will simply deny access to all fastrpc device that contains the
`qcom,non-secure-domain` dt property. Is that the intended change?
Because I see a lot of adsp, cdsp and sdsp fastrpc nodes have that dt
property.
2. In the `fastrpc_rpmsg_probe()` function, it is commented that,
"Unsigned PD offloading is only supported on CDSP"
Does this mean adsp and sdsp shouldn't have the `qcom,non-secure-domain`
dt property? In fact, it was reported that removing this dt property and
using the `/dev/fastrpc-sdsp-secure` node instead works fine too. Is
this the correct way to fix it?
I don't know much about fastrpc, just reporting the issue and guessing
here. It would be really if this can be fixed before the stable release.
Thank you,
Joel Selvaraj
On 15/08/2024 03:34, Selvaraj, Joel (MU-Student) wrote:
> Hi Srinivas Kandagatla and Ekansh Gupta,
>
> On 6/28/24 06:45, srinivas.kandagatla@linaro.org wrote:
>> From: Ekansh Gupta <quic_ekangupt@quicinc.com>
>>
>> Untrusted application with access to only non-secure fastrpc device
>> node can attach to root_pd or static PDs if it can make the respective
>> init request. This can cause problems as the untrusted application
>> can send bad requests to root_pd or static PDs. Add changes to reject
>> attach to privileged PDs if the request is being made using non-secure
>> fastrpc device node.
>>
>> Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
>> Cc: stable <stable@kernel.org>
>> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
>> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>> drivers/misc/fastrpc.c | 22 +++++++++++++++++++---
>> include/uapi/misc/fastrpc.h | 3 +++
>> 2 files changed, 22 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
>> index 5680856c0fb8..a7a2bcedb37e 100644
>> --- a/drivers/misc/fastrpc.c
>> +++ b/drivers/misc/fastrpc.c
>> @@ -2087,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
>> return err;
>> }
>>
>> +static int is_attach_rejected(struct fastrpc_user *fl)
>> +{
>> + /* Check if the device node is non-secure */
>> + if (!fl->is_secure_dev) {
>> + dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
>> + return -EACCES;
>> + }
>> + return 0;
>> +}
>
> This broke userspace for us. Sensors stopped working in SDM845 and other
> qcom SoC devices running postmarketOS. Trying to communicate with the
> fastrpc device just ends up with a permission denied error. This was
> previously working. I am not sure if this is intended. Here are my two
> observations:
>
> 1. if change the if condition to
>
> `if (!fl->is_secure_dev && fl->cctx->secure)`
>
> similar to how it's done in fastrpc's `is_session_rejected()` function,
> then it works. But I am not sure if this is an valid fix. But currently,
> fastrpc will simply deny access to all fastrpc device that contains the
> `qcom,non-secure-domain` dt property. Is that the intended change?
> Because I see a lot of adsp, cdsp and sdsp fastrpc nodes have that dt
> property.
>
> 2. In the `fastrpc_rpmsg_probe()` function, it is commented that,
>
> "Unsigned PD offloading is only supported on CDSP"
>
> Does this mean adsp and sdsp shouldn't have the `qcom,non-secure-domain`
> dt property? In fact, it was reported that removing this dt property and
> using the `/dev/fastrpc-sdsp-secure` node instead works fine too. Is
> this the correct way to fix it?
Yes, this is the ideal way to fix this, Audio DSP and Sensor DSPs are by
default secure DSP's.
usage of "qcom,non-secure-domain" has been abused on all the platforms
as the device tree bindings are not enforcing this checks to any new
device tree entries. This needs fixing properly.
Ideally this patch has to fix the existing dts and update bindings to
reflect that.
Sorry this has been over looked!
On the library side that you are using consider non-secure node as
fallback only when secure node is missing.
given the mess with the current state of patch, reverting sounds good
for me to start with.
--srini
>
> I don't know much about fastrpc, just reporting the issue and guessing
> here. It would be really if this can be fixed before the stable release.
>
> Thank you,
> Joel Selvaraj
>
>
On Thu, Aug 15, 2024 at 02:30:19PM +0100, Srinivas Kandagatla wrote:
>
>
> On 15/08/2024 03:34, Selvaraj, Joel (MU-Student) wrote:
> > Hi Srinivas Kandagatla and Ekansh Gupta,
> >
> > On 6/28/24 06:45, srinivas.kandagatla@linaro.org wrote:
> > > From: Ekansh Gupta <quic_ekangupt@quicinc.com>
> > >
> > > Untrusted application with access to only non-secure fastrpc device
> > > node can attach to root_pd or static PDs if it can make the respective
> > > init request. This can cause problems as the untrusted application
> > > can send bad requests to root_pd or static PDs. Add changes to reject
> > > attach to privileged PDs if the request is being made using non-secure
> > > fastrpc device node.
> > >
> > > Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
> > > Cc: stable <stable@kernel.org>
> > > Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> > > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > > ---
> > > drivers/misc/fastrpc.c | 22 +++++++++++++++++++---
> > > include/uapi/misc/fastrpc.h | 3 +++
> > > 2 files changed, 22 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> > > index 5680856c0fb8..a7a2bcedb37e 100644
> > > --- a/drivers/misc/fastrpc.c
> > > +++ b/drivers/misc/fastrpc.c
> > > @@ -2087,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
> > > return err;
> > > }
> > > +static int is_attach_rejected(struct fastrpc_user *fl)
> > > +{
> > > + /* Check if the device node is non-secure */
> > > + if (!fl->is_secure_dev) {
> > > + dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
> > > + return -EACCES;
> > > + }
> > > + return 0;
> > > +}
> >
> > This broke userspace for us. Sensors stopped working in SDM845 and other
> > qcom SoC devices running postmarketOS. Trying to communicate with the
> > fastrpc device just ends up with a permission denied error. This was
> > previously working. I am not sure if this is intended. Here are my two
> > observations:
> >
> > 1. if change the if condition to
> >
> > `if (!fl->is_secure_dev && fl->cctx->secure)`
> >
> > similar to how it's done in fastrpc's `is_session_rejected()` function,
> > then it works. But I am not sure if this is an valid fix. But currently,
> > fastrpc will simply deny access to all fastrpc device that contains the
> > `qcom,non-secure-domain` dt property. Is that the intended change?
> > Because I see a lot of adsp, cdsp and sdsp fastrpc nodes have that dt
> > property.
> >
> > 2. In the `fastrpc_rpmsg_probe()` function, it is commented that,
> >
> > "Unsigned PD offloading is only supported on CDSP"
> >
> > Does this mean adsp and sdsp shouldn't have the `qcom,non-secure-domain`
> > dt property? In fact, it was reported that removing this dt property and
> > using the `/dev/fastrpc-sdsp-secure` node instead works fine too. Is
> > this the correct way to fix it?
>
> Yes, this is the ideal way to fix this, Audio DSP and Sensor DSPs are by
> default secure DSP's.
>
> usage of "qcom,non-secure-domain" has been abused on all the platforms as
> the device tree bindings are not enforcing this checks to any new device
> tree entries. This needs fixing properly.
>
> Ideally this patch has to fix the existing dts and update bindings to
> reflect that.
>
> Sorry this has been over looked!
>
> On the library side that you are using consider non-secure node as fallback
> only when secure node is missing.
>
> given the mess with the current state of patch, reverting sounds good for me
> to start with.
Great, can you ack the revert then and I'll queue it up to get to Linus
this week?
thanks,
greg k-h
On Thu, Aug 15, 2024 at 02:34:18AM +0000, Selvaraj, Joel (MU-Student) wrote:
> Hi Srinivas Kandagatla and Ekansh Gupta,
>
> On 6/28/24 06:45, srinivas.kandagatla@linaro.org wrote:
> > From: Ekansh Gupta <quic_ekangupt@quicinc.com>
> >
> > Untrusted application with access to only non-secure fastrpc device
> > node can attach to root_pd or static PDs if it can make the respective
> > init request. This can cause problems as the untrusted application
> > can send bad requests to root_pd or static PDs. Add changes to reject
> > attach to privileged PDs if the request is being made using non-secure
> > fastrpc device node.
> >
> > Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
> > Cc: stable <stable@kernel.org>
> > Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > ---
> > drivers/misc/fastrpc.c | 22 +++++++++++++++++++---
> > include/uapi/misc/fastrpc.h | 3 +++
> > 2 files changed, 22 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> > index 5680856c0fb8..a7a2bcedb37e 100644
> > --- a/drivers/misc/fastrpc.c
> > +++ b/drivers/misc/fastrpc.c
> > @@ -2087,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
> > return err;
> > }
> >
> > +static int is_attach_rejected(struct fastrpc_user *fl)
> > +{
> > + /* Check if the device node is non-secure */
> > + if (!fl->is_secure_dev) {
> > + dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
> > + return -EACCES;
> > + }
> > + return 0;
> > +}
>
> This broke userspace for us. Sensors stopped working in SDM845 and other
> qcom SoC devices running postmarketOS. Trying to communicate with the
> fastrpc device just ends up with a permission denied error. This was
> previously working. I am not sure if this is intended. Here are my two
> observations:
>
> 1. if change the if condition to
>
> `if (!fl->is_secure_dev && fl->cctx->secure)`
>
> similar to how it's done in fastrpc's `is_session_rejected()` function,
> then it works. But I am not sure if this is an valid fix. But currently,
> fastrpc will simply deny access to all fastrpc device that contains the
> `qcom,non-secure-domain` dt property. Is that the intended change?
> Because I see a lot of adsp, cdsp and sdsp fastrpc nodes have that dt
> property.
>
> 2. In the `fastrpc_rpmsg_probe()` function, it is commented that,
>
> "Unsigned PD offloading is only supported on CDSP"
>
> Does this mean adsp and sdsp shouldn't have the `qcom,non-secure-domain`
> dt property? In fact, it was reported that removing this dt property and
> using the `/dev/fastrpc-sdsp-secure` node instead works fine too. Is
> this the correct way to fix it?
>
> I don't know much about fastrpc, just reporting the issue and guessing
> here. It would be really if this can be fixed before the stable release.
I will be glad to revert it, what was the git id for this in the tree
now?
thanks,
greg k-h
Hi greg k-h,
The git commit id is: bab2f5e8fd5d2f759db26b78d9db57412888f187
But I am bit hesitant if we should revert it because there is a CVE
attached to it: https://ubuntu.com/security/CVE-2024-41024
Also, I am ok with changing userspace if it's necessary. It would be
nice if the authors can clarify the ideal fix here.
Regards,
Joel Selvaraj
On 8/15/24 00:15, gregkh@linuxfoundation.org wrote:
> On Thu, Aug 15, 2024 at 02:34:18AM +0000, Selvaraj, Joel (MU-Student) wrote:
>> Hi Srinivas Kandagatla and Ekansh Gupta,
>>
>> On 6/28/24 06:45, srinivas.kandagatla@linaro.org wrote:
>>> From: Ekansh Gupta <quic_ekangupt@quicinc.com>
>>>
>>> Untrusted application with access to only non-secure fastrpc device
>>> node can attach to root_pd or static PDs if it can make the respective
>>> init request. This can cause problems as the untrusted application
>>> can send bad requests to root_pd or static PDs. Add changes to reject
>>> attach to privileged PDs if the request is being made using non-secure
>>> fastrpc device node.
>>>
>>> Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
>>> Cc: stable <stable@kernel.org>
>>> Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
>>> Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
>>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>>> ---
>>> drivers/misc/fastrpc.c | 22 +++++++++++++++++++---
>>> include/uapi/misc/fastrpc.h | 3 +++
>>> 2 files changed, 22 insertions(+), 3 deletions(-)
>>>
>>> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
>>> index 5680856c0fb8..a7a2bcedb37e 100644
>>> --- a/drivers/misc/fastrpc.c
>>> +++ b/drivers/misc/fastrpc.c
>>> @@ -2087,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
>>> return err;
>>> }
>>>
>>> +static int is_attach_rejected(struct fastrpc_user *fl)
>>> +{
>>> + /* Check if the device node is non-secure */
>>> + if (!fl->is_secure_dev) {
>>> + dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
>>> + return -EACCES;
>>> + }
>>> + return 0;
>>> +}
>>
>> This broke userspace for us. Sensors stopped working in SDM845 and other
>> qcom SoC devices running postmarketOS. Trying to communicate with the
>> fastrpc device just ends up with a permission denied error. This was
>> previously working. I am not sure if this is intended. Here are my two
>> observations:
>>
>> 1. if change the if condition to
>>
>> `if (!fl->is_secure_dev && fl->cctx->secure)`
>>
>> similar to how it's done in fastrpc's `is_session_rejected()` function,
>> then it works. But I am not sure if this is an valid fix. But currently,
>> fastrpc will simply deny access to all fastrpc device that contains the
>> `qcom,non-secure-domain` dt property. Is that the intended change?
>> Because I see a lot of adsp, cdsp and sdsp fastrpc nodes have that dt
>> property.
>>
>> 2. In the `fastrpc_rpmsg_probe()` function, it is commented that,
>>
>> "Unsigned PD offloading is only supported on CDSP"
>>
>> Does this mean adsp and sdsp shouldn't have the `qcom,non-secure-domain`
>> dt property? In fact, it was reported that removing this dt property and
>> using the `/dev/fastrpc-sdsp-secure` node instead works fine too. Is
>> this the correct way to fix it?
>>
>> I don't know much about fastrpc, just reporting the issue and guessing
>> here. It would be really if this can be fixed before the stable release.
>
> I will be glad to revert it, what was the git id for this in the tree
> now?
>
> thanks,
>
> greg k-h
On Thu, Aug 15, 2024 at 03:35:13AM -0500, Joel Selvaraj wrote: > Hi greg k-h, > > The git commit id is: bab2f5e8fd5d2f759db26b78d9db57412888f187 > > But I am bit hesitant if we should revert it because there is a CVE attached > to it: https://ubuntu.com/security/CVE-2024-41024 Not an issue if it is breaking things, let's get it right. We can trivially reject that CVE if needed. > Also, I am ok with changing userspace if it's necessary. It would be nice if > the authors can clarify the ideal fix here. No, userspace should not break, that's not ok at all. I'll get someone to revert this later today, thanks! greg k-h
On Thu, Aug 15, 2024 at 10:41:15AM +0200, gregkh@linuxfoundation.org wrote: > On Thu, Aug 15, 2024 at 03:35:13AM -0500, Joel Selvaraj wrote: > > Hi greg k-h, > > > > The git commit id is: bab2f5e8fd5d2f759db26b78d9db57412888f187 > > > > But I am bit hesitant if we should revert it because there is a CVE attached > > to it: https://ubuntu.com/security/CVE-2024-41024 > > Not an issue if it is breaking things, let's get it right. We can > trivially reject that CVE if needed. > > > Also, I am ok with changing userspace if it's necessary. It would be nice if > > the authors can clarify the ideal fix here. > > No, userspace should not break, that's not ok at all. I'll get someone > to revert this later today, thanks! Now sent: https://lore.kernel.org/r/20240815094920.8242-1-griffin@kroah.com I'll queue this up later today. thanks, greg k-h
On 8/15/24 05:02, gregkh@linuxfoundation.org wrote: > On Thu, Aug 15, 2024 at 10:41:15AM +0200, gregkh@linuxfoundation.org wrote: >> On Thu, Aug 15, 2024 at 03:35:13AM -0500, Joel Selvaraj wrote: >>> Hi greg k-h, >>> >>> The git commit id is: bab2f5e8fd5d2f759db26b78d9db57412888f187 >>> >>> But I am bit hesitant if we should revert it because there is a CVE attached >>> to it: https://ubuntu.com/security/CVE-2024-41024 >> >> Not an issue if it is breaking things, let's get it right. We can >> trivially reject that CVE if needed. >> >>> Also, I am ok with changing userspace if it's necessary. It would be nice if >>> the authors can clarify the ideal fix here. >> >> No, userspace should not break, that's not ok at all. I'll get someone >> to revert this later today, thanks! > > Now sent: > https://lore.kernel.org/r/20240815094920.8242-1-griffin@kroah.com > > I'll queue this up later today. Thanks! Joel Selvaraj > thanks, > > greg k-h
On Thu, Aug 15, 2024 at 07:15:50AM +0200, gregkh@linuxfoundation.org wrote:
> On Thu, Aug 15, 2024 at 02:34:18AM +0000, Selvaraj, Joel (MU-Student) wrote:
> > Hi Srinivas Kandagatla and Ekansh Gupta,
> >
> > On 6/28/24 06:45, srinivas.kandagatla@linaro.org wrote:
> > > From: Ekansh Gupta <quic_ekangupt@quicinc.com>
> > >
> > > Untrusted application with access to only non-secure fastrpc device
> > > node can attach to root_pd or static PDs if it can make the respective
> > > init request. This can cause problems as the untrusted application
> > > can send bad requests to root_pd or static PDs. Add changes to reject
> > > attach to privileged PDs if the request is being made using non-secure
> > > fastrpc device node.
> > >
> > > Fixes: 0871561055e6 ("misc: fastrpc: Add support for audiopd")
> > > Cc: stable <stable@kernel.org>
> > > Signed-off-by: Ekansh Gupta <quic_ekangupt@quicinc.com>
> > > Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
> > > Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> > > ---
> > > drivers/misc/fastrpc.c | 22 +++++++++++++++++++---
> > > include/uapi/misc/fastrpc.h | 3 +++
> > > 2 files changed, 22 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> > > index 5680856c0fb8..a7a2bcedb37e 100644
> > > --- a/drivers/misc/fastrpc.c
> > > +++ b/drivers/misc/fastrpc.c
> > > @@ -2087,6 +2087,16 @@ static int fastrpc_req_mem_map(struct fastrpc_user *fl, char __user *argp)
> > > return err;
> > > }
> > >
> > > +static int is_attach_rejected(struct fastrpc_user *fl)
> > > +{
> > > + /* Check if the device node is non-secure */
> > > + if (!fl->is_secure_dev) {
> > > + dev_dbg(&fl->cctx->rpdev->dev, "untrusted app trying to attach to privileged DSP PD\n");
> > > + return -EACCES;
> > > + }
> > > + return 0;
> > > +}
> >
> > This broke userspace for us. Sensors stopped working in SDM845 and other
> > qcom SoC devices running postmarketOS. Trying to communicate with the
> > fastrpc device just ends up with a permission denied error. This was
> > previously working. I am not sure if this is intended. Here are my two
> > observations:
> >
> > 1. if change the if condition to
> >
> > `if (!fl->is_secure_dev && fl->cctx->secure)`
> >
> > similar to how it's done in fastrpc's `is_session_rejected()` function,
> > then it works. But I am not sure if this is an valid fix. But currently,
> > fastrpc will simply deny access to all fastrpc device that contains the
> > `qcom,non-secure-domain` dt property. Is that the intended change?
> > Because I see a lot of adsp, cdsp and sdsp fastrpc nodes have that dt
> > property.
> >
> > 2. In the `fastrpc_rpmsg_probe()` function, it is commented that,
> >
> > "Unsigned PD offloading is only supported on CDSP"
> >
> > Does this mean adsp and sdsp shouldn't have the `qcom,non-secure-domain`
> > dt property? In fact, it was reported that removing this dt property and
> > using the `/dev/fastrpc-sdsp-secure` node instead works fine too. Is
> > this the correct way to fix it?
> >
> > I don't know much about fastrpc, just reporting the issue and guessing
> > here. It would be really if this can be fixed before the stable release.
>
> I will be glad to revert it, what was the git id for this in the tree
> now?
Ah, nevermind, I found it, it's bab2f5e8fd5d ("misc: fastrpc: Restrict
untrusted app to attach to privileged PD") and is already in the stable
kernel trees. Do you want to submit a revert or do you need/want me to
do it?
thanks,
greg k-h
© 2016 - 2025 Red Hat, Inc.