DSPBRIDGE: check pointer before calling Proc_Detach
PATCH 1/1 DSPBRIDGE: check pointer before calling Proc_Detach
From: Ernest Ramos Falcon <[email protected]>
This patch adds a check before calling Proc_Detach, otherwise in case a failure occurs on PROC_Attach and hProcessor is invalid when the userspace task closes its handle, unexpected behavior might be seen as this pointer is dereferenced in PROC_Detach.
--- drivers/dsp/bridge/rmgr/drv_interface.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/dsp/bridge/rmgr/drv_interface.c +2 -1
@@ -539,7 +539,8 @@ static int bridge_release(struct inode *ip, struct file *filp) pr_ctxt = filp->private_data;flush_signals (current);DRV_RemoveAllResources (pr_ctxt); -PROC_Detach (pr_ctxt); +if (pr_ctxt->hProcessor) +PROC_Detach (pr_ctxt);MEM_Free (pr_ctxt); filp->private_data =NULL ;
Signature · 1 line
1.6.2.4
Hi,
Quoted 18 lines · ext Omar Ramirez Luna
From: Ernest Ramos Falcon <[email protected]>
This patch adds a check before calling
Proc_Detach, otherwise in case a failure occurs onPROC_Attachand hProcessor is invalid when the userspace task closes its handle, unexpected behavior might be seen as this pointer is dereferenced inPROC_Detach.Signed-off-by Ernest Ramos Falcon <[email protected]>--- drivers/dsp/bridge/rmgr/drv_interface.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)drivers/dsp/bridge/rmgr/drv_interface.c +0
-0
drivers/dsp/bridge/rmgr/drv_interface.c static int bridge_release(struct inode *ip, struct file *filp) · line 546
Quoted 9 lines
drivers/dsp/bridge/rmgr/drv_interface.c +2
-1@@ -539,7 +539,8 @@ static int bridge_release(struct inode *ip, struct file *filp) pr_ctxt = filp->private_data;flush_signals (current);DRV_RemoveAllResources (pr_ctxt); -PROC_Detach (pr_ctxt); +if (pr_ctxt->hProcessor) +PROC_Detach (pr_ctxt);MEM_Free (pr_ctxt); filp->private_data =NULL ;
I guess PROC_Detach already checks for a valid hProcessor handle! Why we need this check here again?
Also if you go ahead with this patch, then how are you going to cover a use case where userspace application calls PROC_Attach() which fails, but without checking the failure userspace application calls PROC_Detach()!
Cheers,
Ameya.
Quoted 41 lines
-----Original Message-----
From: Ameya Palande [mailto:[email protected]]
Sent: Wednesday, February 10, 2010 7:48 AM
To: Ramirez Luna, Omar
Cc: linux-omap; Doyu Hiroshi (Nokia-D/Helsinki); Contreras Felipe (Nokia- D/Helsinki); Menon, Nishanth; Ramos Falcon, Ernesto
Subject: Re: [PATCH] DSPBRIDGE: check pointer before callingProc_DetachHi,
Quoted 8 lines · ext Omar Ramirez Luna
From: Ernest Ramos Falcon <[email protected]>
This patch adds a check before calling
Proc_Detach, otherwise in case a failure occurs onPROC_Attachand hProcessor is invalid when the userspace task closes its handle, unexpected behavior might be seen as this pointer is dereferenced inPROC_Detach.Review
Quoted 6 lines
Signed-off-by Ernest Ramos Falcon <[email protected]>--- drivers/dsp/bridge/rmgr/drv_interface.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)(quoted diff) +0
-0
b/drivers/dsp/bridge/rmgr/drv_interface.cdrivers/dsp/bridge/rmgr/drv_interface.c static int bridge_release(struct inode *ip, struct
Quoted 4 lines
index 32aff66..b0f0d93 100644
drivers/dsp/bridge/rmgr/drv_interface.c +0
-0@@ -539,7 +539,8 @@ static int bridge_release(struct inode *ip, structfile *filp)
Quoted 8 lines
drivers/dsp/bridge/rmgr/drv_interface.c +2
-1pr_ctxt = filp->private_data;flush_signals (current);DRV_RemoveAllResources (pr_ctxt); -PROC_Detach (pr_ctxt); +if (pr_ctxt->hProcessor) +PROC_Detach (pr_ctxt);MEM_Free (pr_ctxt);
Quoted 5 lines
drivers/dsp/bridge/rmgr/drv_interface.c static int bridge_release(struct inode *ip, struct file *filp) · line 546
Quoted 1 line
drivers/dsp/bridge/rmgr/drv_interface.c +0
-0filp->private_data =NULL ;I guess
PROC_Detachalready checks for a valid hProcessor handle! Why we need this check here again?
Sorry, I think this applied for different version of dspbridge.
Quoted 5 lines
Also if you go ahead with this patch, then how are you going to cover a use case where userspace application calls
PROC_Attach()which fails, but without checking the failure userspace application callsPROC_Detach()!
PROC_Detach can not be called directly from user space, is deprecated; the only place where this is function is called is bridge_release, so nothing would happen. Anyway, dismiss this patch.
Quoted 2 lines
Cheers,
Ameya.