← Commit list

934da8291

Rob Landley
Rob Landley
2006-06-25
SOURCE BUG Duration: 44s

Subject

Fix a possible race condition if two processes try to claim the same loop device at the same time. We should only CLR_FD if the set status fails, not if the SET_FD fails.

SOURCE BUG

This commit was genuinely broken at the time (not related to our build system): scripts/config/mkconfigs.c (2005-08-01 - 2006-10-05 arasi) uretilen bbconfigopts.h icine .config satirlarini kacissiz, ham newline'larla gömüyordu - gecerli C degildi, busybox'un kendi bb_mkdep araci bile parse edemiyordu (7d219aab7 ile duzeltildi, mkconfigs shell scripte cevrildi)

→ Bu hatanin tam hikayesini ve duzeltme diffini gor

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

libbb/loop.c+4 -3
@@ -118,9 +118,10 @@ int set_loop(char **device, const char *file, int offset)
safe_strncpy((char *)loopinfo.lo_file_name, file, LO_NAME_SIZE);
loopinfo.lo_offset = offset;
/* Associate free loop device with file. */
- if(!ioctl(dfd, LOOP_SET_FD, ffd) &&
- !ioctl(dfd, BB_LOOP_SET_STATUS, &loopinfo)) rc=0;
- else ioctl(dfd, LOOP_CLR_FD, 0);
+ if(!ioctl(dfd, LOOP_SET_FD, ffd)) {
+ if (!ioctl(dfd, BB_LOOP_SET_STATUS, &loopinfo)) rc=0;
+ else ioctl(dfd, LOOP_CLR_FD, 0);
+ }
/* If this block device already set up right, re-use it.
(Yes this is racy, but associating two loop devices with the same