Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1635213

Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write mem

From Rik van Riel <riel@redhat.com>
Newsgroups linux.kernel
Subject Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write mem
Date 2017-05-03 20:50 +0200
Message-ID <tD7vA-Hg-29@gated-at.bofh.it> (permalink)
References <tAQfw-8w0-21@gated-at.bofh.it> <tCN3Q-3du-23@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, 2017-05-02 at 13:54 -0700, David Rientjes wrote:

> > diff --git a/drivers/char/mem.c b/drivers/char/mem.c
> > index 7e4a9d1..3a765e02 100644
> > --- a/drivers/char/mem.c
> > +++ b/drivers/char/mem.c
> > @@ -55,7 +55,7 @@ static inline int
> valid_phys_addr_range(phys_addr_t addr, size_t count)
> >  
> >  static inline int valid_mmap_phys_addr_range(unsigned long pfn,
> size_t size)
> >  {
> > -     return 1;
> > +     return (pfn << PAGE_SHIFT) + size <= __pa(high_memory);
> >  }
> >  #endif
> >  
> 
> I suppose you are correct that there should be some sanity checking
> on the 
> size used for the mmap().

My apologies for not responding earlier. It may
indeed make sense to have a sanity check here.

However, it is not as easy as simply checking the
end against __pa(high_memory). Some systems have
non-contiguous physical memory ranges, with gaps
of invalid addresses in-between.

You would have to make sure that both the beginning
and the end are valid, and that there are no gaps of
invalid pfns in the middle...

At that point, is the complexity so much that it no
longer makes sense to try to protect against root
crashing the system?

-- 
All rights reversed

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RESENT PATCH] x86/mem: fix the offset overflow when read/write mem zhongjiang <zhongjiang@huawei.com> - 2017-04-27 14:00 +0200
  Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write  mem zhong jiang <zhongjiang@huawei.com> - 2017-05-02 04:00 +0200
  Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write  mem David Rientjes <rientjes@google.com> - 2017-05-02 23:00 +0200
    Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write  mem zhong jiang <zhongjiang@huawei.com> - 2017-05-03 08:50 +0200
    Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write  mem Rik van Riel <riel@redhat.com> - 2017-05-03 20:50 +0200
      Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write  mem zhong jiang <zhongjiang@huawei.com> - 2017-05-04 04:30 +0200
        Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write  mem Rik van Riel <riel@redhat.com> - 2017-05-09 17:50 +0200
          Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write  mem zhong jiang <zhongjiang@huawei.com> - 2017-05-10 04:20 +0200
          Re: [RESENT PATCH] x86/mem: fix the offset overflow when read/write  mem Xishi Qiu <qiuxishi@huawei.com> - 2017-05-10 04:20 +0200

csiph-web