mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/1] misc: fastrpc: fixes for 6.11
@ 2024-09-02 14:14 srinivas.kandagatla
  2024-09-02 14:14 ` [PATCH 1/1] misc: fastrpc: Fix double free of 'buf' in error path srinivas.kandagatla
  0 siblings, 1 reply; 4+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:14 UTC (permalink / raw)
  To: gregkh; +Cc: linux-kernel, Srinivas Kandagatla

From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>

Hi Greg,

Here are one fix in fastrpc for 6.11, Could you queue
this for 6.11 if its not too late.


Thanks,
Srini

Sukrut Bellary (1):
  misc: fastrpc: Fix double free of 'buf' in error path

 drivers/misc/fastrpc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/1] misc: fastrpc: Fix double free of 'buf' in error path
  2024-09-02 14:14 [PATCH 0/1] misc: fastrpc: fixes for 6.11 srinivas.kandagatla
@ 2024-09-02 14:14 ` srinivas.kandagatla
  2024-09-03 10:19   ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: srinivas.kandagatla @ 2024-09-02 14:14 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, Sukrut Bellary, Shuah Khan, Dan Carpenter,
	Srinivas Kandagatla

From: Sukrut Bellary <sukrut.bellary@linux.com>

smatch warning:
drivers/misc/fastrpc.c:1926 fastrpc_req_mmap() error: double free of 'buf'

In fastrpc_req_mmap() error path, the fastrpc buffer is freed in
fastrpc_req_munmap_impl() if unmap is successful.

But in the end, there is an unconditional call to fastrpc_buf_free().
So the above case triggers the double free of fastrpc buf.

Fixes: 72fa6f7820c4 ("misc: fastrpc: Rework fastrpc_req_munmap")
Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
Signed-off-by: Sukrut Bellary <sukrut.bellary@linux.com>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
 drivers/misc/fastrpc.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index 5204fda51da3..878a6746f994 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -1910,7 +1910,8 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
 				      &args[0]);
 	if (err) {
 		dev_err(dev, "mmap error (len 0x%08llx)\n", buf->size);
-		goto err_invoke;
+		fastrpc_buf_free(buf);
+		return err;
 	}
 
 	/* update the buffer to be able to deallocate the memory on the DSP */
@@ -1948,8 +1949,6 @@ static int fastrpc_req_mmap(struct fastrpc_user *fl, char __user *argp)
 
 err_assign:
 	fastrpc_req_munmap_impl(fl, buf);
-err_invoke:
-	fastrpc_buf_free(buf);
 
 	return err;
 }
-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] misc: fastrpc: Fix double free of 'buf' in error path
  2024-09-02 14:14 ` [PATCH 1/1] misc: fastrpc: Fix double free of 'buf' in error path srinivas.kandagatla
@ 2024-09-03 10:19   ` Greg KH
  2024-09-03 10:46     ` Srinivas Kandagatla
  0 siblings, 1 reply; 4+ messages in thread
From: Greg KH @ 2024-09-03 10:19 UTC (permalink / raw)
  To: srinivas.kandagatla
  Cc: linux-kernel, Sukrut Bellary, Shuah Khan, Dan Carpenter

On Mon, Sep 02, 2024 at 03:14:09PM +0100, srinivas.kandagatla@linaro.org wrote:
> From: Sukrut Bellary <sukrut.bellary@linux.com>
> 
> smatch warning:
> drivers/misc/fastrpc.c:1926 fastrpc_req_mmap() error: double free of 'buf'
> 
> In fastrpc_req_mmap() error path, the fastrpc buffer is freed in
> fastrpc_req_munmap_impl() if unmap is successful.
> 
> But in the end, there is an unconditional call to fastrpc_buf_free().
> So the above case triggers the double free of fastrpc buf.
> 
> Fixes: 72fa6f7820c4 ("misc: fastrpc: Rework fastrpc_req_munmap")
> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> Signed-off-by: Sukrut Bellary <sukrut.bellary@linux.com>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
>  drivers/misc/fastrpc.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)

Any reason you forgot a cc: stable@ on this?

I'll go add it by hand...


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/1] misc: fastrpc: Fix double free of 'buf' in error path
  2024-09-03 10:19   ` Greg KH
@ 2024-09-03 10:46     ` Srinivas Kandagatla
  0 siblings, 0 replies; 4+ messages in thread
From: Srinivas Kandagatla @ 2024-09-03 10:46 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel, Sukrut Bellary, Shuah Khan, Dan Carpenter



On 03/09/2024 11:19, Greg KH wrote:
> On Mon, Sep 02, 2024 at 03:14:09PM +0100, srinivas.kandagatla@linaro.org wrote:
>> From: Sukrut Bellary <sukrut.bellary@linux.com>
>>
>> smatch warning:
>> drivers/misc/fastrpc.c:1926 fastrpc_req_mmap() error: double free of 'buf'
>>
>> In fastrpc_req_mmap() error path, the fastrpc buffer is freed in
>> fastrpc_req_munmap_impl() if unmap is successful.
>>
>> But in the end, there is an unconditional call to fastrpc_buf_free().
>> So the above case triggers the double free of fastrpc buf.
>>
>> Fixes: 72fa6f7820c4 ("misc: fastrpc: Rework fastrpc_req_munmap")
>> Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>
>> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
>> Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> Signed-off-by: Sukrut Bellary <sukrut.bellary@linux.com>
>> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
>> ---
>>   drivers/misc/fastrpc.c | 5 ++---
>>   1 file changed, 2 insertions(+), 3 deletions(-)
> 
> Any reason you forgot a cc: stable@ on this?
> 
I think it was forgotten.
> I'll go add it by hand...
Thanks for doing this.

--srini
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-09-03 10:46 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-02 14:14 [PATCH 0/1] misc: fastrpc: fixes for 6.11 srinivas.kandagatla
2024-09-02 14:14 ` [PATCH 1/1] misc: fastrpc: Fix double free of 'buf' in error path srinivas.kandagatla
2024-09-03 10:19   ` Greg KH
2024-09-03 10:46     ` Srinivas Kandagatla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®