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] [day] [month] [year] [list]
Date:   Thu, 9 Sep 2021 21:48:54 +0200
From:   Daniel Borkmann <daniel@...earbox.net>
To:     sdf@...gle.com
Cc:     bpf@...r.kernel.org, netdev@...r.kernel.org, tj@...nel.org,
        davem@...emloft.net, m@...bda.lt, alexei.starovoitov@...il.com,
        andrii@...nel.org
Subject: Re: [PATCH bpf 1/3] bpf, cgroups: Fix cgroup v2 fallback on v1/v2
 mixed mode

On 9/9/21 6:47 PM, sdf@...gle.com wrote:
> On 09/09, Daniel Borkmann wrote:
[...]
>>   static inline struct cgroup *sock_cgroup_ptr(struct sock_cgroup_data *skcd)
>>   {
>> -#if defined(CONFIG_CGROUP_NET_PRIO) || defined(CONFIG_CGROUP_NET_CLASSID)
>> -    unsigned long v;
>> -
>> -    /*
>> -     * @skcd->val is 64bit but the following is safe on 32bit too as we
>> -     * just need the lower ulong to be written and read atomically.
>> -     */
>> -    v = READ_ONCE(skcd->val);
>> -
>> -    if (v & 3)
>> -        return &cgrp_dfl_root.cgrp;
>> -
>> -    return (struct cgroup *)(unsigned long)v ?: &cgrp_dfl_root.cgrp;
>> -#else
>> -    return (struct cgroup *)(unsigned long)skcd->val;
>> -#endif
>> +    return READ_ONCE(skcd->cgroup);
> 
> Do we really need READ_ONCE here? I was always assuming it was there
> because we were flipping that lower bit. Now that it's a simple
> pointer, why not 'return skcd->cgroup' instead?

Hm, good point, from cgroup_sk_alloc() side we don't need it as struct sock is not
public yet at that point, I'll send a v2 and remove the READ_ONCE()/WRITE_ONCE()
pair for the cgroup pointer.

Thanks for spotting!
Daniel

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ