🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.debian.bugs.dist
Article #4965

Bug#1154303: backuppc-rsync: double free in bpc_poolWrite_repeatPoolWrite breaks parallel backups (hang / pool write errors)

#4965
From: Arnd Hannemann
Date: Wed, 18 Nov 2026 17:40
143 lines
9419 bytes
This is a multi-part message in MIME format.
--------------HQQCO502nV2utpegU55wpVB0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Source: backuppc-rsync
Version: 3.1.3.0-5
Severity: important
Tags: patch upstream fixed-upstream
Forwarded: https://github.com/backuppc/rsync-bpc/issues/55
Control: found -1 3.1.3.0-3
Control: found -1 3.1.3.0-4

Dear Maintainer,

all backuppc-rsync versions in Debian (3.1.3.0-3 in bookworm, -4 in
trixie, -5 in forky/sid) contain a double free in
bpc_poolWrite_repeatPoolWrite() that breaks parallel backups into the
same pool. I reported it upstream with a patch, and the maintainer merged
it on 2026-11-18:

   https://github.com/backuppc/rsync-bpc/issues/55
   https://github.com/backuppc/rsync-bpc/pull/56  (merge commit 41b5ba3)

There is no upstream release with the fix yet (3.1.3.2 does not contain
it). The attached patch is the upstream commit; it applies to 3.1.3.0
with an offset of -17 lines.

What happens
------------

Since 3.1.3.0, bpc_poolWrite_repeatPoolWrite() calls
bpc_poolWrite_cleanup(), which returns info->tmpFileName to the
bpc_strBuf free list, and then keeps using it; bpc_poolWrite_close()
frees it a second time. The free list then hands the same buffer out
twice, so the temp file name gets overwritten with a pool path or a pool
directory. 3.1.2.2 is not affected (it used a fixed char array).

The retry path runs when two transfers add a file with the same digest 
at the same moment, e.g. parallel first full backups of hosts with the 
same OS. With the Debian default MaxBackups = 4 parallel backups are normal.
This is how I ran into it: the first backups of two new hosts with the
same OS (Ubuntu 26.04), running in parallel into an empty pool, ended
with "can't open/create <pool path> for writing" errors.

Symptoms with 3.1.3.0 (the Debian version): one rsync_bpc receiver loops
forever at 100% CPU in bpc_poolWrite_updateMatches (it reads from a
directory fd and adds -1 per read), so that backup hangs; the other
transfer finishes with missing files and errors. With upstream master
before the fix the hang is gone, but the same race gives "can't
open/create <pool path> for writing" errors and in one run unbounded
memory growth of the receiver (about 42 GB, ended by the OOM killer).

Reproduction
------------

BackupPC 4.4.0 with an empty pool, two hosts backing up the same tree of
about 30,500 files via rsync, BackupPC_dump -f for both at the same time:

   3.1.2.2           clean
   3.1.3.0           one receiver hangs at 100% CPU, the other has errors
   3.1.3.1           code 12 on one host, 27 xferErrs on the other
   3.1.3.1 + patch   clean in 4 of 4 runs (about 3,800 retries per host)

Details are in the upstream issue.

Stable
------

Since the patch is small, self-contained and merged upstream, it would 
be great to have it in trixie (and bookworm, if you consider it worth 
it) via a stable update as well.

Thanks for maintaining BackupPC in Debian!

Best Regards
  Arnd

--------------HQQCO502nV2utpegU55wpVB0
Content-Type: text/x-diff; charset=UTF-8;
 name="rsync-bpc-repeatPoolWrite-double-free.patch"
Content-Disposition: attachment;
 filename="rsync-bpc-repeatPoolWrite-double-free.patch"
Content-Transfer-Encoding: base64

RnJvbSA4NjQ2NzAyODFiOWVjYTYxYjBlZmY1NDM3OTZkYzczYzM0MjQyMjEyIE1vbiBTZXAg
MTcgMDA6MDA6MDAgMjAwMQpGcm9tOiBBcm5kIEhhbm5lbWFubiA8YXJuZEBhcm5kbmV0LmRl
PgpEYXRlOiBXZWQsIDE4IE5vdiAyMDI2IDA4OjQ2OjU1ICswMTAwClN1YmplY3Q6IFtQQVRD
SF0gYnBjX3Bvb2xXcml0ZV9yZXBlYXRQb29sV3JpdGU6IGZpeCBkb3VibGUgZnJlZSBvZiB0
bXBGaWxlTmFtZQoKYnBjX3Bvb2xXcml0ZV9yZXBlYXRQb29sV3JpdGUoKSBjYWxscyBicGNf
cG9vbFdyaXRlX2NsZWFudXAoKSwgd2hpY2gKcmV0dXJucyBpbmZvLT50bXBGaWxlTmFtZSB0
byB0aGUgYnBjX3N0ckJ1ZiBmcmVlIGxpc3QsIGFuZCB0aGVuI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IGNhbid0
IG9wZW4gJXMgZm9yIHJlYWRpbmciLCBmaWxlTmFtZVRtcCk7CiAgICAgICAgIGluZm8tPmVy
cm9yQ250Kys7CisgICAgICAgIGZyZWUoZmlsZU5hbWVUbXApOwogICAgICAgICByZXR1cm47
CiAgICAgfQogICAgIGluZm8tPmVvZiAgICA9IDE7CiAgICAgaW5mby0+c3RhdGUgID0gMjsK
ICAgICBpbmZvLT5mZE9wZW4gPSAxOworICAgIGZyZWUoZmlsZU5hbWVUbXApOwogICAgIGJw
Y19wb29sV3JpdGVfd3JpdGUoaW5mbywgTlVMTCwgMCk7CiB9CiAKLS0gCjIuNTMuMAoK

--------------HQQCO502nV2utpegU55wpVB0--
Technical Details
Message-ID: <O0RNv-cJ5E-3@gated-at.bofh.it>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.corradoroberto.it!diesel.cu.mi.it!bofh.it!news.nic.it!robomod
From: Arnd Hannemann <arnd@arndnet.de>
Newsgroups: linux.debian.bugs.dist
Subject: Bug#1154303: backuppc-rsync: double free in bpc_poolWrite_repeatPoolWrite breaks parallel backups (hang / pool write errors)
Date: Wed, 18 Nov 2026 18:40:01 +0100
Message-ID: <O0RNv-cJ5E-3@gated-at.bofh.it>
X-Original-To: submit@bugs.debian.org
X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org  Wed Nov 18 17:37:08 2026
Old-Return-Path: <debbugs@buxtehude.debian.org>
X-Spam-Flag: NO
X-Spam-Score: -1.451
Reply-To: Arnd Hannemann <arnd@arndnet.de>, 1154303@bugs.debian.org
Resent-To: debian-bugs-dist@lists.debian.org
Resent-Cc: team+pkg-backuppc@tracker.debian.org
X-Debian-Pr-Message: report 1154303
X-Debian-Pr-Package: src:backuppc-rsync
X-Debian-Pr-Keywords: fixed-upstream patch upstream
X-Debian-Pr-Source: backuppc-rsync
Authentication-Results: outgoing_mbo_mout;
	dkim=none;
	spf=pass (outgoing_mbo_mout: domain of arnd@arndnet.de designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=arnd@arndnet.de
Content-Type: multipart/mixed; boundary="------------HQQCO502nV2utpegU55wpVB0"
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
X-Rspamd-Queue-ID: 4jV7zt1lN7z8vfP
X-Debian-Message: from BTS
X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2003310
List-ID: <debian-bugs-dist.lists.debian.org>
List-URL: <https://lists.debian.org/debian-bugs-dist/>
Approved: robomod@news.nic.it
Lines: 143
Organization: linux.* mail to news gateway
Sender: robomod@news.nic.it
X-Original-Date: Wed, 18 Nov 2026 18:35:52 +0100
X-Original-Message-ID: <4e9fbc55-a224-4a58-8dcd-36bddcb15cfa@arndnet.de>