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: <78624B4A-EA8B-4D51-B3E6-448132BB839B@oracle.com>
Date:   Mon, 24 Dec 2018 04:35:28 -0700
From:   William Kucharski <william.kucharski@...cle.com>
To:     Michal Hocko <mhocko@...e.com>
Cc:     Paul Oppenheimer <bepvte@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Vlastimil Babka <vbabka@...e.cz>,
        David Rientjes <rientjes@...gle.com>, Jan Kara <jack@...e.cz>,
        Mike Rapoport <rppt@...ux.ibm.com>, linux-mm@...ck.org,
        LKML <linux-kernel@...r.kernel.org>
Subject: Re: Bug with report THP eligibility for each vma



> On Dec 24, 2018, at 12:49 AM, Michal Hocko <mhocko@...e.com> wrote:
> 
> [Cc-ing mailing list and people involved in the original patch]
> 
> On Fri 21-12-18 13:42:24, Paul Oppenheimer wrote:
>> Hello! I've never reported a kernel bug before, and since its on the
>> "next" tree I was told to email the author of the relevant commit.
>> Please redirect me to the correct place if I've made a mistake.
>> 
>> When opening firefox or chrome, and using it for a good 7 seconds, it
>> hangs in "uninterruptible sleep" and I recieve a "BUG" in dmesg. This
>> doesn't occur when reverting this commit:
>> https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=48cf516f8c.
>> Ive attached the output of decode_stacktrace.sh and the relevant dmesg
>> log to this email.
>> 
>> Thanks
> 
>> BUG: unable to handle kernel NULL pointer dereference at 00000000000000e8
> 
> Thanks for the bug report! This is offset 232 and that matches
> file->f_mapping as per pahole
> pahole -C file ./vmlinux | grep f_mapping
>        struct address_space *     f_mapping;            /*   232     8 */
> 
> I thought that each file really has to have a mapping. But the following
> should heal the issue and add an extra care.
> 
> diff --git a/mm/huge_memory.c b/mm/huge_memory.c
> index f64733c23067..fc9d70a9fbd1 100644
> --- a/mm/huge_memory.c
> +++ b/mm/huge_memory.c
> @@ -66,6 +66,8 @@ bool transparent_hugepage_enabled(struct vm_area_struct *vma)
> {
> 	if (vma_is_anonymous(vma))
> 		return __transparent_hugepage_enabled(vma);
> +	if (!vma->vm_file || !vma->vm_file->f_mapping)
> +		return false;
> 	if (shmem_mapping(vma->vm_file->f_mapping) && shmem_huge_enabled(vma))
> 		return __transparent_hugepage_enabled(vma);

From what I see in code in mm/mmap.c, it seems if vma->vm_file is non-zero
vma->vm_file->f_mapping may be assumed to be non-NULL; see unlink_file_vma()
and __vma_link_file() for two examples, which both use the construct:

	file = vma->vm_file;
	if (file) {
		struct address_space *mapping = file->f_mapping;

		[ ... ]

		[ code that dereferences "mapping" without further checks ]
	}

I see nothing wrong with your second check but a few extra instructions
performed, but depending upon how often transparent_hugepage_enabled() is called
there may be at least theoretical performance concerns.

William Kucharski
william.kucharski@...cle.com

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ