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: <9f2ef1ac-c0a1-eb77-8e68-e9a60bc8efd2@gnuweeb.org>
Date:   Thu, 1 Sep 2022 15:16:44 +0700
From:   Ammar Faizi <ammarfaizi2@...weeb.org>
To:     Oscar Salvador <osalvador@...e.de>
Cc:     Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        Linux MM Mailing List <linux-mm@...ck.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Michal Hocko <mhocko@...e.com>,
        Vlastimil Babka <vbabka@...e.cz>,
        Eric Dumazet <edumazet@...gle.com>,
        Waiman Long <longman@...hat.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        Ammar Faizi <ammarfaizi2@...il.com>
Subject: Re: [PATCH 2/3] mm, page_owner: Add page_owner_stacks file to print
 out only stacks and their counter

On 9/1/22 11:42 AM, Oscar Salvador wrote:
> +static unsigned long last_stack = 0;

This @last_stack can just be a static local variable in the new
function you wrote, read_page_owner_stacks(), since no other
functions use it.

> +static ssize_t read_page_owner_stacks(struct file *file, char __user *buf,
> +				      size_t count, loff_t *pos)
> +{
> +	char *kbuf;
> +	int ret = 0;
> +
> +	count = min_t(size_t, count, PAGE_SIZE);
> +	kbuf = kmalloc(count, GFP_KERNEL);
> +	if (!kbuf)
> +		return ENOMEM;

Missing a negative sign, return -ENOMEM;

> +	ret += stack_depot_print_stacks_threshold(kbuf, count, pos, &last_stack);
> +	if (copy_to_user(buf, kbuf, ret))
> +		ret = -EFAULT;
> +
> +	if (!ret)
> +		last_stack = 0;
> +
> +	kfree(kbuf);
> +	return ret;
> +}

-- 
Ammar Faizi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ