* [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match()
@ 2024-11-23 7:21 Max Kellermann
2024-11-23 7:21 ` [PATCH 2/2] fs/ceph/mds_client: fix cred leak in ceph_mds_check_access() Max Kellermann
2024-11-25 0:52 ` [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match() Xiubo Li
0 siblings, 2 replies; 6+ messages in thread
From: Max Kellermann @ 2024-11-23 7:21 UTC (permalink / raw)
To: xiubli, idryomov, ceph-devel, linux-kernel; +Cc: stable, Max Kellermann
This eliminates a redundant get_current_cred() call, because
ceph_mds_check_access() has already obtained this pointer.
As a side effect, this also fixes a reference leak in
ceph_mds_auth_match(): by omitting the get_current_cred() call, no
additional cred reference is taken.
Fixes: 596afb0b8933 ("ceph: add ceph_mds_check_access() helper")
Cc: stable@vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/ceph/mds_client.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 6baec1387f7d..e8a5994de8b6 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -5615,9 +5615,9 @@ void send_flush_mdlog(struct ceph_mds_session *s)
static int ceph_mds_auth_match(struct ceph_mds_client *mdsc,
struct ceph_mds_cap_auth *auth,
+ const struct cred *cred,
char *tpath)
{
- const struct cred *cred = get_current_cred();
u32 caller_uid = from_kuid(&init_user_ns, cred->fsuid);
u32 caller_gid = from_kgid(&init_user_ns, cred->fsgid);
struct ceph_client *cl = mdsc->fsc->client;
@@ -5740,7 +5740,7 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
for (i = 0; i < mdsc->s_cap_auths_num; i++) {
struct ceph_mds_cap_auth *s = &mdsc->s_cap_auths[i];
- err = ceph_mds_auth_match(mdsc, s, tpath);
+ err = ceph_mds_auth_match(mdsc, s, cred, tpath);
if (err < 0) {
return err;
} else if (err > 0) {
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] fs/ceph/mds_client: fix cred leak in ceph_mds_check_access()
2024-11-23 7:21 [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match() Max Kellermann
@ 2024-11-23 7:21 ` Max Kellermann
2024-11-25 0:53 ` Xiubo Li
2024-11-25 0:52 ` [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match() Xiubo Li
1 sibling, 1 reply; 6+ messages in thread
From: Max Kellermann @ 2024-11-23 7:21 UTC (permalink / raw)
To: xiubli, idryomov, ceph-devel, linux-kernel; +Cc: stable, Max Kellermann
get_current_cred() increments the reference counter, but the
put_cred() call was missing.
Fixes: 596afb0b8933 ("ceph: add ceph_mds_check_access() helper")
Cc: stable@vger.kernel.org
Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
---
fs/ceph/mds_client.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index e8a5994de8b6..35d83c8c2874 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -5742,6 +5742,7 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
err = ceph_mds_auth_match(mdsc, s, cred, tpath);
if (err < 0) {
+ put_cred(cred);
return err;
} else if (err > 0) {
/* always follow the last auth caps' permision */
@@ -5757,6 +5758,8 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
}
}
+ put_cred(cred);
+
doutc(cl, "root_squash_perms %d, rw_perms_s %p\n", root_squash_perms,
rw_perms_s);
if (root_squash_perms && rw_perms_s == NULL) {
--
2.45.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match()
2024-11-23 7:21 [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match() Max Kellermann
2024-11-23 7:21 ` [PATCH 2/2] fs/ceph/mds_client: fix cred leak in ceph_mds_check_access() Max Kellermann
@ 2024-11-25 0:52 ` Xiubo Li
2024-11-25 14:54 ` Ilya Dryomov
1 sibling, 1 reply; 6+ messages in thread
From: Xiubo Li @ 2024-11-25 0:52 UTC (permalink / raw)
To: Max Kellermann, idryomov, ceph-devel, linux-kernel; +Cc: stable
On 11/23/24 15:21, Max Kellermann wrote:
> This eliminates a redundant get_current_cred() call, because
> ceph_mds_check_access() has already obtained this pointer.
>
> As a side effect, this also fixes a reference leak in
> ceph_mds_auth_match(): by omitting the get_current_cred() call, no
> additional cred reference is taken.
>
> Fixes: 596afb0b8933 ("ceph: add ceph_mds_check_access() helper")
> Cc: stable@vger.kernel.org
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
> fs/ceph/mds_client.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index 6baec1387f7d..e8a5994de8b6 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -5615,9 +5615,9 @@ void send_flush_mdlog(struct ceph_mds_session *s)
>
> static int ceph_mds_auth_match(struct ceph_mds_client *mdsc,
> struct ceph_mds_cap_auth *auth,
> + const struct cred *cred,
> char *tpath)
> {
> - const struct cred *cred = get_current_cred();
> u32 caller_uid = from_kuid(&init_user_ns, cred->fsuid);
> u32 caller_gid = from_kgid(&init_user_ns, cred->fsgid);
> struct ceph_client *cl = mdsc->fsc->client;
> @@ -5740,7 +5740,7 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
> for (i = 0; i < mdsc->s_cap_auths_num; i++) {
> struct ceph_mds_cap_auth *s = &mdsc->s_cap_auths[i];
>
> - err = ceph_mds_auth_match(mdsc, s, tpath);
> + err = ceph_mds_auth_match(mdsc, s, cred, tpath);
> if (err < 0) {
> return err;
> } else if (err > 0) {
Good catch.
Reviewed-by: Xiubo Li <xiubli@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] fs/ceph/mds_client: fix cred leak in ceph_mds_check_access()
2024-11-23 7:21 ` [PATCH 2/2] fs/ceph/mds_client: fix cred leak in ceph_mds_check_access() Max Kellermann
@ 2024-11-25 0:53 ` Xiubo Li
2024-11-25 14:55 ` Ilya Dryomov
0 siblings, 1 reply; 6+ messages in thread
From: Xiubo Li @ 2024-11-25 0:53 UTC (permalink / raw)
To: Max Kellermann, idryomov, ceph-devel, linux-kernel; +Cc: stable
On 11/23/24 15:21, Max Kellermann wrote:
> get_current_cred() increments the reference counter, but the
> put_cred() call was missing.
>
> Fixes: 596afb0b8933 ("ceph: add ceph_mds_check_access() helper")
> Cc: stable@vger.kernel.org
> Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> ---
> fs/ceph/mds_client.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index e8a5994de8b6..35d83c8c2874 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -5742,6 +5742,7 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
>
> err = ceph_mds_auth_match(mdsc, s, cred, tpath);
> if (err < 0) {
> + put_cred(cred);
> return err;
> } else if (err > 0) {
> /* always follow the last auth caps' permision */
> @@ -5757,6 +5758,8 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
> }
> }
>
> + put_cred(cred);
> +
> doutc(cl, "root_squash_perms %d, rw_perms_s %p\n", root_squash_perms,
> rw_perms_s);
> if (root_squash_perms && rw_perms_s == NULL) {
Good catch.
Reviewed-by: Xiubo Li <xiubli@redhat.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match()
2024-11-25 0:52 ` [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match() Xiubo Li
@ 2024-11-25 14:54 ` Ilya Dryomov
0 siblings, 0 replies; 6+ messages in thread
From: Ilya Dryomov @ 2024-11-25 14:54 UTC (permalink / raw)
To: Xiubo Li; +Cc: Max Kellermann, ceph-devel, linux-kernel, stable
On Mon, Nov 25, 2024 at 1:53 AM Xiubo Li <xiubli@redhat.com> wrote:
>
>
> On 11/23/24 15:21, Max Kellermann wrote:
> > This eliminates a redundant get_current_cred() call, because
> > ceph_mds_check_access() has already obtained this pointer.
> >
> > As a side effect, this also fixes a reference leak in
> > ceph_mds_auth_match(): by omitting the get_current_cred() call, no
> > additional cred reference is taken.
> >
> > Fixes: 596afb0b8933 ("ceph: add ceph_mds_check_access() helper")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> > ---
> > fs/ceph/mds_client.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> > index 6baec1387f7d..e8a5994de8b6 100644
> > --- a/fs/ceph/mds_client.c
> > +++ b/fs/ceph/mds_client.c
> > @@ -5615,9 +5615,9 @@ void send_flush_mdlog(struct ceph_mds_session *s)
> >
> > static int ceph_mds_auth_match(struct ceph_mds_client *mdsc,
> > struct ceph_mds_cap_auth *auth,
> > + const struct cred *cred,
> > char *tpath)
> > {
> > - const struct cred *cred = get_current_cred();
> > u32 caller_uid = from_kuid(&init_user_ns, cred->fsuid);
> > u32 caller_gid = from_kgid(&init_user_ns, cred->fsgid);
> > struct ceph_client *cl = mdsc->fsc->client;
> > @@ -5740,7 +5740,7 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
> > for (i = 0; i < mdsc->s_cap_auths_num; i++) {
> > struct ceph_mds_cap_auth *s = &mdsc->s_cap_auths[i];
> >
> > - err = ceph_mds_auth_match(mdsc, s, tpath);
> > + err = ceph_mds_auth_match(mdsc, s, cred, tpath);
> > if (err < 0) {
> > return err;
> > } else if (err > 0) {
>
> Good catch.
>
> Reviewed-by: Xiubo Li <xiubli@redhat.com>
Applied.
Thanks,
Ilya
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] fs/ceph/mds_client: fix cred leak in ceph_mds_check_access()
2024-11-25 0:53 ` Xiubo Li
@ 2024-11-25 14:55 ` Ilya Dryomov
0 siblings, 0 replies; 6+ messages in thread
From: Ilya Dryomov @ 2024-11-25 14:55 UTC (permalink / raw)
To: Xiubo Li; +Cc: Max Kellermann, ceph-devel, linux-kernel, stable
On Mon, Nov 25, 2024 at 1:53 AM Xiubo Li <xiubli@redhat.com> wrote:
>
>
> On 11/23/24 15:21, Max Kellermann wrote:
> > get_current_cred() increments the reference counter, but the
> > put_cred() call was missing.
> >
> > Fixes: 596afb0b8933 ("ceph: add ceph_mds_check_access() helper")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Max Kellermann <max.kellermann@ionos.com>
> > ---
> > fs/ceph/mds_client.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> > index e8a5994de8b6..35d83c8c2874 100644
> > --- a/fs/ceph/mds_client.c
> > +++ b/fs/ceph/mds_client.c
> > @@ -5742,6 +5742,7 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
> >
> > err = ceph_mds_auth_match(mdsc, s, cred, tpath);
> > if (err < 0) {
> > + put_cred(cred);
> > return err;
> > } else if (err > 0) {
> > /* always follow the last auth caps' permision */
> > @@ -5757,6 +5758,8 @@ int ceph_mds_check_access(struct ceph_mds_client *mdsc, char *tpath, int mask)
> > }
> > }
> >
> > + put_cred(cred);
> > +
> > doutc(cl, "root_squash_perms %d, rw_perms_s %p\n", root_squash_perms,
> > rw_perms_s);
> > if (root_squash_perms && rw_perms_s == NULL) {
>
> Good catch.
>
> Reviewed-by: Xiubo Li <xiubli@redhat.com>
Applied.
Thanks,
Ilya
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-11-25 14:55 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-23 7:21 [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match() Max Kellermann
2024-11-23 7:21 ` [PATCH 2/2] fs/ceph/mds_client: fix cred leak in ceph_mds_check_access() Max Kellermann
2024-11-25 0:53 ` Xiubo Li
2024-11-25 14:55 ` Ilya Dryomov
2024-11-25 0:52 ` [PATCH 1/2] fs/ceph/mds_client: pass cred pointer to ceph_mds_auth_match() Xiubo Li
2024-11-25 14:54 ` Ilya Dryomov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox