From: Qi Zheng <qi.zheng@linux.dev>
To: linkinjeon@kernel.org, sfrench@samba.org,
senozhatsky@chromium.org, tom@talpey.com, hyc.lee@gmail.com,
lsahlber@redhat.com, paulmck@kernel.org
Cc: linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
Qi Zheng <zhengqi.arch@bytedance.com>
Subject: [PATCH] cifsd: fix potential UAF
Date: Thu, 27 Jul 2023 09:59:11 +0000 [thread overview]
Message-ID: <20230727095911.3657425-1-qi.zheng@linux.dev> (raw)
From: Qi Zheng <zhengqi.arch@bytedance.com>
After calling opinfo_put(), the opinfo may be freed, then using this
opinfo in the next traversal will cause UAF bug.
To fix it, swap the call order of opinfo_put() and rcu_read_lock(), so
that the opinfo_free_rcu() will not be called, and the opinfo will not be
freed, then we can safely perform the next traversal.
Fixes: e2f34481b24d ("cifsd: add server-side procedures for SMB3")
Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com>
---
fs/smb/server/oplock.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
index 844b303baf29..a0e47eb2df83 100644
--- a/fs/smb/server/oplock.c
+++ b/fs/smb/server/oplock.c
@@ -1021,8 +1021,8 @@ int find_same_lease_key(struct ksmbd_session *sess, struct ksmbd_inode *ci,
goto out;
}
op_next:
- opinfo_put(opinfo);
rcu_read_lock();
+ opinfo_put(opinfo);
}
rcu_read_unlock();
@@ -1314,8 +1314,8 @@ void smb_break_all_levII_oplock(struct ksmbd_work *work, struct ksmbd_file *fp,
brk_op->open_trunc = is_trunc;
oplock_break(brk_op, SMB2_OPLOCK_LEVEL_NONE);
next:
- opinfo_conn_put(brk_op);
rcu_read_lock();
+ opinfo_conn_put(brk_op);
}
rcu_read_unlock();
@@ -1711,8 +1711,8 @@ struct oplock_info *lookup_lease_in_table(struct ksmbd_conn *conn,
goto out;
}
op_next:
- opinfo_put(opinfo);
rcu_read_lock();
+ opinfo_put(opinfo);
}
rcu_read_unlock();
--
2.30.2
reply other threads:[~2023-07-27 9:59 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230727095911.3657425-1-qi.zheng@linux.dev \
--to=qi.zheng@linux.dev \
--cc=hyc.lee@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lsahlber@redhat.com \
--cc=paulmck@kernel.org \
--cc=senozhatsky@chromium.org \
--cc=sfrench@samba.org \
--cc=tom@talpey.com \
--cc=zhengqi.arch@bytedance.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®