lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACOAw_yjyy+58B=RawAaQO98NQB43roZOv4sq5313sFHN1myXQ@mail.gmail.com>
Date:   Fri, 12 Mar 2021 23:37:29 +0900
From:   Daeho Jeong <daeho43@...il.com>
To:     Greg KH <gregkh@...uxfoundation.org>
Cc:     linux-kernel@...r.kernel.org,
        linux-f2fs-devel@...ts.sourceforge.net, kernel-team@...roid.com,
        Daeho Jeong <daehojeong@...gle.com>
Subject: Re: [PATCH v4] f2fs: add sysfs nodes to get runtime compression stat

As you can see, if we're doing like the below.

sbi->compr_written_block += blocks;

Let's assume the initial value as 0.

<thread A>                                             <thread B>
sbi->compr_written_block = 0;

sbi->compr_written_block = 0;
+blocks(3);
                                                               + blocks(2);
sbi->compr_written_block = 3;

sbi->compr_written_block = 2;

Finally, we end up with 2, not 5.

As more threads are participating it, we might miss more counting.

2021년 3월 12일 (금) 오후 11:04, Greg KH <gregkh@...uxfoundation.org>님이 작성:
>
> On Fri, Mar 12, 2021 at 10:56:13PM +0900, Daeho Jeong wrote:
> > Thanks for suggesting me sysfs_emit().
> >
> > For atomic values, actually, those are needed for writer part, not reader.
> >
> > +#define add_compr_block_stat(inode, blocks)                            \
> > +       do {                                                            \
> > +               struct f2fs_sb_info *sbi = F2FS_I_SB(inode);            \
> > +               int diff = F2FS_I(inode)->i_cluster_size - blocks;      \
> > +               atomic64_add(blocks, &sbi->compr_written_block);        \
> > +               atomic64_add(diff, &sbi->compr_saved_block);            \
> > +       } while (0)
> >
> > I needed a protection here, because they might be updated in the race condition.
>
> Why?  What are you trying to protect from "racing" here?
>
> thanks,
>
> greg k-h

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ