Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
When syncing using "--append" and the file on the sender is > 2GB and gets truncated between rsync receiving the checksum and the actual transfer, rsync dies in Segmentation Fault.
This is due to having the "n" computation on line 108 below wrap (it's supposed to be a int32):
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
105 static void matched(int f, struct sum_struct *s, struct map_struct *buf,
106 OFF_T offset, int32 i)
107 {
108 int32 n = (int32)(offset - last_match); /* max value: block_size (int32) */
109 int32 j;
:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
Version-Release number of selected component (if applicable):
rsync-3.1.2 and rsync-3.1.3 (RHEL8)
How reproducible:
ALWAYS
Steps to Reproduce: notes: line numbers in reproducer are from RHEL8's rsync ...
1. Create 2 >2GB big files, sent file /root/file and received file /mnt/file, with /mnt/file < /root/file
# truncate -s 2760M /root/file
# truncate -s 2759M /mnt/file
2. Start rsync to sync /root/file -> /mnt under GDB, with a breakpoint on "receive_sums"
# gdb --args /usr/bin/rsync --append -vvvv /root/file /mnt
[...]
(gdb) break receive_sums
(gdb) run
3. At breakpoint, hit "next" until the checksum is computed (hence the -vvvv mode) but before /root/file gets opened for transfer
Breakpoint 1, receive_sums (f=5) at sender.c:332
332 if (!(s = receive_sums(f_in))) {
(gdb) next
71 if (!(s = new(struct sum_struct)))
(gdb)
74 read_sum_head(f, s);
(gdb)
76 s->sums = NULL;
(gdb)
78 if (DEBUG_GTE(DELTASUM, 3)) {
(gdb)
send_files (f_in=5, f_out=<optimized out>) at sender.c:332
332 if (!(s = receive_sums(f_in))) {
(gdb)
count=53790 n=53784 rem=33608
338 fd = do_open(fname, O_RDONLY, 0);
(gdb) STOP HERE
4. From another terminal, truncate /root/file to 0
# truncate -s 0 /root/file
5. Continue rsync process
(gdb) cont
Actual results:
send_files mapped /root/file of size 0
calling match_sums /root/file
file
Program received signal SIGSEGV, Segmentation fault.
map_ptr (map=map@entry=0x0, offset=offset@entry=2893021184, len=len@entry=32768) at fileio.c:247
247 if (offset >= map->p_offset && offset+len <= map->p_offset+map->p_len)
(gdb)
Expected results:
Not dying
Some more details.
With a big file (> 2GB) which got truncated on sender side, we have "n" wrap the int32:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
105 static void matched(int f, struct sum_struct *s, struct map_struct *buf,
106 OFF_T offset, int32 i)
107 {
108 int32 n = (int32)(offset - last_match); /* max value: block_size (int32) */
:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
"n" becomes positive instead of negative (offset == 0 since file got truncated, last_match (size of the file on receiver, >2GB, not truncated, is positive).
Later this makes the code 245-253 below be executed, because "n" is positive, while it should be negative:
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
241 /* non-compressing send token */
242 static void simple_send_token(int f, int32 token, struct map_struct *buf,
243 OFF_T offset, int32 n)
244 {
245 if (n > 0) {
246 int32 len = 0;
247 while (len < n) {
248 int32 n1 = MIN(CHUNK_SIZE, n-len);
249 write_int(f, n1);
250 write_buf(f, map_ptr(buf, offset+len, n1), n1);
251 len += n1;
252 }
253 }
254 /* a -2 token means to send data only and no token */
255 if (token != -2)
256 write_int(f, -(token+1));
257 }
-------- 8< ---------------- 8< ---------------- 8< ---------------- 8< --------
This makes rsync die on line 250, because map_ptr() computes an offset on NULL buf (because sender file got truncated).
Description of problem: When syncing using "--append" and the file on the sender is > 2GB and gets truncated between rsync receiving the checksum and the actual transfer, rsync dies in Segmentation Fault. This is due to having the "n" computation on line 108 below wrap (it's supposed to be a int32): -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- 105 static void matched(int f, struct sum_struct *s, struct map_struct *buf, 106 OFF_T offset, int32 i) 107 { 108 int32 n = (int32)(offset - last_match); /* max value: block_size (int32) */ 109 int32 j; : -------- 8< ---------------- 8< ---------------- 8< ---------------- 8< -------- Version-Release number of selected component (if applicable): rsync-3.1.2 and rsync-3.1.3 (RHEL8) How reproducible: ALWAYS Steps to Reproduce: notes: line numbers in reproducer are from RHEL8's rsync ... 1. Create 2 >2GB big files, sent file /root/file and received file /mnt/file, with /mnt/file < /root/file # truncate -s 2760M /root/file # truncate -s 2759M /mnt/file 2. Start rsync to sync /root/file -> /mnt under GDB, with a breakpoint on "receive_sums" # gdb --args /usr/bin/rsync --append -vvvv /root/file /mnt [...] (gdb) break receive_sums (gdb) run 3. At breakpoint, hit "next" until the checksum is computed (hence the -vvvv mode) but before /root/file gets opened for transfer Breakpoint 1, receive_sums (f=5) at sender.c:332 332 if (!(s = receive_sums(f_in))) { (gdb) next 71 if (!(s = new(struct sum_struct))) (gdb) 74 read_sum_head(f, s); (gdb) 76 s->sums = NULL; (gdb) 78 if (DEBUG_GTE(DELTASUM, 3)) { (gdb) send_files (f_in=5, f_out=<optimized out>) at sender.c:332 332 if (!(s = receive_sums(f_in))) { (gdb) count=53790 n=53784 rem=33608 338 fd = do_open(fname, O_RDONLY, 0); (gdb) STOP HERE 4. From another terminal, truncate /root/file to 0 # truncate -s 0 /root/file 5. Continue rsync process (gdb) cont Actual results: send_files mapped /root/file of size 0 calling match_sums /root/file file Program received signal SIGSEGV, Segmentation fault. map_ptr (map=map@entry=0x0, offset=offset@entry=2893021184, len=len@entry=32768) at fileio.c:247 247 if (offset >= map->p_offset && offset+len <= map->p_offset+map->p_len) (gdb) Expected results: Not dying