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]
Date:	Wed, 10 Aug 2016 11:50:56 -0400
From:	Robert Foss <robert.foss@...labora.com>
To:	Mateusz Guzik <mguzik@...hat.com>
Cc:	akpm@...ux-foundation.org, keescook@...omium.org,
	viro@...iv.linux.org.uk, gorcunov@...nvz.org,
	john.stultz@...aro.org, plaguedbypenguins@...il.com,
	sonnyrao@...omium.org, adobriyan@...il.com, jdanis@...gle.com,
	calvinowens@...com, jann@...jh.net, mhocko@...e.com,
	koct9i@...il.com, vbabka@...e.cz, n-horiguchi@...jp.nec.com,
	kirill.shutemov@...ux.intel.com, ldufour@...ux.vnet.ibm.com,
	hannes@...xchg.org, linux-kernel@...r.kernel.org,
	Ben Zhang <benzh@...omium.org>,
	Bryan Freed <bfreed@...omium.org>,
	Filipe Brandenburger <filbranden@...omium.org>
Subject: Re: [PACTH v1] mm, proc: Implement /proc/<pid>/totmaps



On 2016-08-10 11:42 AM, Mateusz Guzik wrote:
> On Wed, Aug 10, 2016 at 11:39:12AM -0400, Robert Foss wrote:
>>
>>
>> On 2016-08-09 04:17 PM, Robert Foss wrote:
>>>>> +static int totmaps_proc_show(struct seq_file *m, void *data)
>>>>> +{
>>>>> +    struct proc_maps_private *priv = m->private;
>>>>> +    struct mm_struct *mm;
>>>>> +    struct vm_area_struct *vma;
>>>>> +    struct mem_size_stats *mss_sum = priv->mss;
>>>>> +
>>>>> +    /* reference to priv->task already taken */
>>>>> +    /* but need to get the mm here because */
>>>>> +    /* task could be in the process of exiting */
>>>>> +    mm = get_task_mm(priv->task);
>>>>> +    if (!mm || IS_ERR(mm))
>>>>> +        return -EINVAL;
>>>>> +
>>>>
>>>> That's not how it's done in smaps.
>>>
>>> Alright, I'll have to look into the difference between this approach and
>>> the smaps one.
>>
>>
>> I had a look at show_smaps(), and it's not entirely clear to me what the
>> advantage of doing it show_smaps() way.
>>
>> mm = get_task_mm(priv->task) is needed to iterate through all of the
>> mappings. Is there a preferable way of doing that?
>
> In the other part of the mail I stated smaps goes to proc_maps_open
> which has:
> priv->mm = proc_mem_open(inode, PTRACE_MODE_READ);
>
> This gives you stable access to mm and all needed permission checks.
>
> Then, in the read routine you can just:
> if (!atomic_inc_not_zero(&mm->mm_users))
> 	goto thats_it;
>
> See smaps routines or e.g. environ_read.
>

Ah! I see what you mean now. Thanks for the clarification!


Rob.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ