yangsong8-a1 opened a new pull request, #21587: URL: https://github.com/apache/nuttx/pull/21587
## Summary loop_read() and loop_write() seek the backing file and then transfer from the current position. The position is shared by all users of the loop device and the two steps were not serialized, so a concurrent reader could make a transfer use the wrong offset. Hold dev->lock over the seek and the transfer. loop_write() now also returns on a failed seek instead of writing at the current position. ## Impact drivers/loop only. No API change. ## Testing Ubuntu 22.04, gcc 13.1, sim:nsh with CONFIG_DEV_LOOP and CONFIG_BCH. A test program sets up /dev/loop0 on a file whose sectors hold their own index, then two threads pread() different sectors 3000 times each and check the data: ``` loop: setup ret=0 loop: 6000 concurrent reads, wrong data: 0 ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
