All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cifsd: Fix a use after free on error path
@ 2021-03-18 13:12 Dan Carpenter
  2021-03-19  4:42 ` Sergey Senozhatsky
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-03-18 13:12 UTC (permalink / raw)
  To: Namjae Jeon
  Cc: Hyunchul Lee, Steve French, Sergey Senozhatsky, Ronnie Sahlberg,
	linux-kernel, linux-cifs, kernel-janitors

The ksmbd_free_work_struct() frees "work" so we need to swap the order
of these two function calls to avoid a use after free.

Fixes: cabcebc31de4 ("cifsd: introduce SMB3 kernel server")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 fs/cifsd/oplock.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/cifsd/oplock.c b/fs/cifsd/oplock.c
index 6c3dbc71134e..f694c14be0df 100644
--- a/fs/cifsd/oplock.c
+++ b/fs/cifsd/oplock.c
@@ -638,8 +638,8 @@ static void __smb2_oplock_break_noti(struct work_struct *wk)
 	if (allocate_oplock_break_buf(work)) {
 		ksmbd_err("smb2_allocate_rsp_buf failed! ");
 		atomic_dec(&conn->r_count);
-		ksmbd_free_work_struct(work);
 		ksmbd_fd_put(work, fp);
+		ksmbd_free_work_struct(work);
 		return;
 	}
 
-- 
2.30.2


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

* Re: [PATCH] cifsd: Fix a use after free on error path
  2021-03-18 13:12 [PATCH] cifsd: Fix a use after free on error path Dan Carpenter
@ 2021-03-19  4:42 ` Sergey Senozhatsky
  0 siblings, 0 replies; 2+ messages in thread
From: Sergey Senozhatsky @ 2021-03-19  4:42 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Namjae Jeon, Hyunchul Lee, Steve French, Sergey Senozhatsky,
	Ronnie Sahlberg, linux-kernel, linux-cifs, kernel-janitors

On (21/03/18 16:12), Dan Carpenter wrote:
> The ksmbd_free_work_struct() frees "work" so we need to swap the order
> of these two function calls to avoid a use after free.
> 
> Fixes: cabcebc31de4 ("cifsd: introduce SMB3 kernel server")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks.

Reviewed-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>

	-ss

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

end of thread, other threads:[~2021-03-19  4:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-18 13:12 [PATCH] cifsd: Fix a use after free on error path Dan Carpenter
2021-03-19  4:42 ` Sergey Senozhatsky

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.