mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Possible race in loop.ko
@ 2017-07-28 15:55 Anton Volkov
  2017-08-01 12:39 ` Ming Lei
  0 siblings, 1 reply; 11+ messages in thread
From: Anton Volkov @ 2017-07-28 15:55 UTC (permalink / raw)
  To: axboe; +Cc: tom.leiming, osandov, linux-kernel, ldv-project, khoroshilov

Hello.
While searching for races in Linux kernel I've come across 
drivers/block/loop.ko module. Here is the question that I came up with 
while analyzing results. Lines are given using the info from Linux v4.12.

In loop_init function additional initialization happens after a 
successful call to misc_register() (loop.c: line 1961). Consider the 
following case:

Thread 1:                 Thread 2:
loop_init()
   misc_register()         loop_control_ioctl
   part_shift = 0          -> loop_add
   if (max_part > 0) {          alloc_disk(1 << part_shift)
     part_shift =
          <greater than 0>
     ...
   }

In this case alloc_disk() will be called with 1 as a parameter although 
part_shift should have been greater than 0. Maybe it would be better to 
move the call to a misc_register() function a bit further down (at least 
so it could be after the part_shift initialization)?

Thank you for your time.

-- Anton Volkov
Linux Verification Center, ISPRAS
web: http://linuxtesting.org
e-mail: avolkov@ispras.ru

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-08-15 18:51 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-28 15:55 Possible race in loop.ko Anton Volkov
2017-08-01 12:39 ` Ming Lei
2017-08-03 15:01   ` [PATCH] loop: fix to a race condition due to the early registration of device Anton Volkov
2017-08-07  2:39     ` Ming Lei
2017-08-07 12:37       ` Anton Volkov
2017-08-07 12:54         ` Johannes Thumshirn
2017-08-07 13:09           ` Anton Volkov
2017-08-07 13:24             ` Johannes Thumshirn
2017-08-08 22:00         ` Omar Sandoval
2017-08-10 15:46           ` Anton Volkov
2017-08-15 18:51         ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®