* [PATCH] CIFS: fix use-after-free of the lease keys
@ 2019-01-31 12:46 Aurelien Aptel
2019-01-31 12:52 ` Paulo Alcantara
0 siblings, 1 reply; 3+ messages in thread
From: Aurelien Aptel @ 2019-01-31 12:46 UTC (permalink / raw)
To: linux-cifs; +Cc: smfrench, Aurelien Aptel, stable
The request buffers are freed right before copying the pointers.
Use the func args instead which are identical and still valid.
Simple reproducer (requires KASAN enabled) on a cifs mount:
echo foo > foo ; tail -f foo & rm foo
Cc: <stable@vger.kernel.org> # 4.20
Fixes: 179e44d49c2f ("smb3: add tracepoint for sending lease break responses to server")
Signed-off-by: Aurelien Aptel <aaptel@suse.com>
---
fs/cifs/smb2pdu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
index 846e605175bf..54181387a770 100644
--- a/fs/cifs/smb2pdu.c
+++ b/fs/cifs/smb2pdu.c
@@ -4435,8 +4435,8 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
rc = cifs_send_recv(xid, ses, &rqst, &resp_buf_type, flags, &rsp_iov);
cifs_small_buf_release(req);
- please_key_low = (__u64 *)req->LeaseKey;
- please_key_high = (__u64 *)(req->LeaseKey+8);
+ please_key_low = (__u64 *)lease_key;
+ please_key_high = (__u64 *)(lease_key+8);
if (rc) {
cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE);
trace_smb3_lease_err(le32_to_cpu(lease_state), tcon->tid,
--
2.16.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] CIFS: fix use-after-free of the lease keys
2019-01-31 12:46 [PATCH] CIFS: fix use-after-free of the lease keys Aurelien Aptel
@ 2019-01-31 12:52 ` Paulo Alcantara
2019-01-31 15:53 ` Steve French
0 siblings, 1 reply; 3+ messages in thread
From: Paulo Alcantara @ 2019-01-31 12:52 UTC (permalink / raw)
To: Aurelien Aptel, linux-cifs; +Cc: smfrench, Aurelien Aptel, stable
Aurelien Aptel <aaptel@suse.com> writes:
> The request buffers are freed right before copying the pointers.
> Use the func args instead which are identical and still valid.
>
> Simple reproducer (requires KASAN enabled) on a cifs mount:
>
> echo foo > foo ; tail -f foo & rm foo
>
> Cc: <stable@vger.kernel.org> # 4.20
> Fixes: 179e44d49c2f ("smb3: add tracepoint for sending lease break responses to server")
> Signed-off-by: Aurelien Aptel <aaptel@suse.com>
> ---
> fs/cifs/smb2pdu.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> index 846e605175bf..54181387a770 100644
> --- a/fs/cifs/smb2pdu.c
> +++ b/fs/cifs/smb2pdu.c
> @@ -4435,8 +4435,8 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
> rc = cifs_send_recv(xid, ses, &rqst, &resp_buf_type, flags, &rsp_iov);
> cifs_small_buf_release(req);
>
> - please_key_low = (__u64 *)req->LeaseKey;
> - please_key_high = (__u64 *)(req->LeaseKey+8);
> + please_key_low = (__u64 *)lease_key;
> + please_key_high = (__u64 *)(lease_key+8);
> if (rc) {
> cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE);
> trace_smb3_lease_err(le32_to_cpu(lease_state), tcon->tid,
> --
> 2.16.4
Reviewed-by: Paulo Alcantara <palcantara@suse.de>
Thanks!
Paulo
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] CIFS: fix use-after-free of the lease keys
2019-01-31 12:52 ` Paulo Alcantara
@ 2019-01-31 15:53 ` Steve French
0 siblings, 0 replies; 3+ messages in thread
From: Steve French @ 2019-01-31 15:53 UTC (permalink / raw)
To: Paulo Alcantara; +Cc: Aurelien Aptel, CIFS, Stable
Moved into cifs-2.6.git for-next
On Thu, Jan 31, 2019 at 6:53 AM Paulo Alcantara <paulo@paulo.ac> wrote:
>
> Aurelien Aptel <aaptel@suse.com> writes:
>
> > The request buffers are freed right before copying the pointers.
> > Use the func args instead which are identical and still valid.
> >
> > Simple reproducer (requires KASAN enabled) on a cifs mount:
> >
> > echo foo > foo ; tail -f foo & rm foo
> >
> > Cc: <stable@vger.kernel.org> # 4.20
> > Fixes: 179e44d49c2f ("smb3: add tracepoint for sending lease break responses to server")
> > Signed-off-by: Aurelien Aptel <aaptel@suse.com>
> > ---
> > fs/cifs/smb2pdu.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
> > index 846e605175bf..54181387a770 100644
> > --- a/fs/cifs/smb2pdu.c
> > +++ b/fs/cifs/smb2pdu.c
> > @@ -4435,8 +4435,8 @@ SMB2_lease_break(const unsigned int xid, struct cifs_tcon *tcon,
> > rc = cifs_send_recv(xid, ses, &rqst, &resp_buf_type, flags, &rsp_iov);
> > cifs_small_buf_release(req);
> >
> > - please_key_low = (__u64 *)req->LeaseKey;
> > - please_key_high = (__u64 *)(req->LeaseKey+8);
> > + please_key_low = (__u64 *)lease_key;
> > + please_key_high = (__u64 *)(lease_key+8);
> > if (rc) {
> > cifs_stats_fail_inc(tcon, SMB2_OPLOCK_BREAK_HE);
> > trace_smb3_lease_err(le32_to_cpu(lease_state), tcon->tid,
> > --
> > 2.16.4
>
> Reviewed-by: Paulo Alcantara <palcantara@suse.de>
>
> Thanks!
> Paulo
--
Thanks,
Steve
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-01-31 15:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-31 12:46 [PATCH] CIFS: fix use-after-free of the lease keys Aurelien Aptel
2019-01-31 12:52 ` Paulo Alcantara
2019-01-31 15:53 ` Steve French
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox