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  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:   Fri, 4 Dec 2020 09:33:10 +0800
From:   Miles Chen <miles.chen@...iatek.com>
To:     Vincenzo Frascino <vincenzo.frascino@....com>
CC:     Alexey Dobriyan <adobriyan@...il.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        <linux-kernel@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>,
        <linux-mediatek@...ts.infradead.org>, <wsd_upstream@...iatek.com>,
        Andrey Konovalov <andreyknvl@...gle.com>,
        Alexander Potapenko <glider@...gle.com>,
        Andrey Ryabinin <aryabinin@...tuozzo.com>,
        Catalin Marinas <catalin.marinas@....com>,
        Dmitry Vyukov <dvyukov@...gle.com>,
        Marco Elver <elver@...gle.com>,
        "Will Deacon" <will.deacon@....com>,
        "Eric W . Biederman" <ebiederm@...ssion.com>,
        Song Bao Hua <song.bao.hua@...ilicon.com>,
        <stable@...r.kernel.org>
Subject: Re: [PATCH v2] proc: use untagged_addr() for pagemap_read addresses

On Thu, 2020-12-03 at 11:45 +0000, Vincenzo Frascino wrote:
> Hi Miles,
> 
> On 11/27/20 5:07 AM, Miles Chen wrote:
> > When we try to visit the pagemap of a tagged userspace pointer, we find
> > that the start_vaddr is not correct because of the tag.
> > To fix it, we should untag the usespace pointers in pagemap_read().
> > 
> 
> Nit: s/usespace/userspace/ (please search and replace all occurrences :) )
> 
> > I tested with 5.10-rc4 and the issue remains.
> > 
> > Explaination from Catalin in [1]:
> >
> 
> Nit: s/Explaination/Explanation/ (please search and replace all occurrences :) )

thanks, I will fix this and push v3
> 
> > "
> > Arguably, that's a user-space bug since tagged file offsets were never
> > supported. In this case it's not even a tag at bit 56 as per the arm64
> > tagged address ABI but rather down to bit 47. You could say that the
> > problem is caused by the C library (malloc()) or whoever created the
> > tagged vaddr and passed it to this function. It's not a kernel
> > regression as we've never supported it.
> > 
> > Now, pagemap is a special case where the offset is usually not generated
> > as a classic file offset but rather derived by shifting a user virtual
> > address. I guess we can make a concession for pagemap (only) and allow
> > such offset with the tag at bit (56 - PAGE_SHIFT + 3).
> > "
> > 
> > My test code is baed on [2]:
> 
> Nit: s/baed/based/ (please search and replace all occurrences :) )

thanks, I will fix this and push v3



Miles
> 
> [...]
> 
> > ---
> >  fs/proc/task_mmu.c | 8 ++++++--
> >  1 file changed, 6 insertions(+), 2 deletions(-)
> > 
> > diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
> > index 217aa2705d5d..92b277388f05 100644
> > --- a/fs/proc/task_mmu.c
> > +++ b/fs/proc/task_mmu.c
> > @@ -1599,11 +1599,15 @@ static ssize_t pagemap_read(struct file *file, char __user *buf,
> >  
> >  	src = *ppos;
> >  	svpfn = src / PM_ENTRY_BYTES;
> > -	start_vaddr = svpfn << PAGE_SHIFT;
> >  	end_vaddr = mm->task_size;
> >  
> >  	/* watch out for wraparound */
> > -	if (svpfn > mm->task_size >> PAGE_SHIFT)
> > +	start_vaddr = end_vaddr;
> > +	if (svpfn < (ULONG_MAX >> PAGE_SHIFT))
> 
> It seems that 'svpfn' should be less-then-equal (<=) '(ULONG_MAX >>
> PAGE_SHIFT)'. Is there any specific reason why this is not the case?
> 
> > +		start_vaddr = untagged_addr(svpfn << PAGE_SHIFT);
> > +
> > +	/* Ensure the address is inside the task */
> > +	if (start_vaddr > mm->task_size)
> >  		start_vaddr = end_vaddr;
> >  
> >  	/*
> > 
> 
> Otherwise:
> 
> Reviewed-by: Vincenzo Frascino <vincenzo.frascino@....com>
> 

Powered by blists - more mailing lists