]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
mgr: fix PyObject leak in the remote() pickle calls 69755/head
authorKefu Chai <k.chai@proxmox.com>
Fri, 26 Jun 2026 00:44:35 +0000 (08:44 +0800)
committerKefu Chai <k.chai@proxmox.com>
Fri, 26 Jun 2026 04:29:21 +0000 (12:29 +0800)
commit8ae44f6a3753bf5a1681887bb41705f313c47ff9
treea713ffd1b0998a958f660ee962ad612064cab88c
parent96e268b198fba42d00a4baa6eab2f75537086d96
mgr: fix PyObject leak in the remote() pickle calls

dispatch_remote() and ceph_dispatch_remote() invoke pickle.loads/dumps via
PyObject_CallMethodObjArgs(pmodule, PyUnicode_FromString("loads"), ...). The
method-name string created by PyUnicode_FromString is a new reference that
CallMethodObjArgs does not steal, and it was never released, so every cross
-module remote() call leaked three PyUnicode objects on the active mgr.

Use PyObject_CallMethod(pmodule, "loads", "(O)", arg), which takes the method
name as a C string and manages it internally, so there is nothing to leak.
The "(O)" format wraps the argument in a one-tuple so it reaches the callee as
a single object. A bare "O" passes the argument through directly, and when it
is a tuple (as remote()'s *args always is, including the empty tuple from a
no-argument call) PyObject_CallMethod unpacks it and calls dumps() with the
wrong arguments, e.g. dumps() with none.

Fixes: https://tracker.ceph.com/issues/77724
Signed-off-by: Kefu Chai <k.chai@proxmox.com>
src/mgr/ActivePyModule.cc
src/mgr/BaseMgrModule.cc