Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700987

Re: Possible race in loop.ko

From Ming Lei <tom.leiming@gmail.com>
Newsgroups linux.kernel
Subject Re: Possible race in loop.ko
Date 2017-08-01 14:40 +0200
Message-ID <u9ECS-40W-27@gated-at.bofh.it> (permalink)
References <u8fQe-5FT-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Fri, Jul 28, 2017 at 11:55 PM, Anton Volkov <avolkov@ispras.ru> wrote:
> 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)?

That looks a good idea, could you cook a patch to do it?


-- 
Ming Lei

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Possible race in loop.ko Ming Lei <tom.leiming@gmail.com> - 2017-08-01 14:40 +0200
  [PATCH] loop: fix to a race condition due to the early registration of device Anton Volkov <avolkov@ispras.ru> - 2017-08-03 17:10 +0200
    Re: [PATCH] loop: fix to a race condition due to the early  registration of device Ming Lei <tom.leiming@gmail.com> - 2017-08-07 04:40 +0200
      [PATCH] loop: fix to a race condition due to the early registration of device Anton Volkov <avolkov@ispras.ru> - 2017-08-07 14:40 +0200
        Re: [PATCH] loop: fix to a race condition due to the early  registration of device Johannes Thumshirn <jthumshirn@suse.de> - 2017-08-07 15:00 +0200
          Re: [PATCH] loop: fix to a race condition due to the early  registration of device Anton Volkov <avolkov@ispras.ru> - 2017-08-07 15:10 +0200
            Re: [PATCH] loop: fix to a race condition due to the early  registration of device Johannes Thumshirn <jthumshirn@suse.de> - 2017-08-07 15:30 +0200
        Re: [PATCH] loop: fix to a race condition due to the early  registration of device Omar Sandoval <osandov@osandov.com> - 2017-08-09 00:10 +0200
          Re: [PATCH] loop: fix to a race condition due to the early  registration of device Anton Volkov <avolkov@ispras.ru> - 2017-08-10 17:50 +0200

csiph-web