Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1533101
| From | Michal Hocko <mhocko@kernel.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM |
| Date | 2016-11-30 10:20 +0100 |
| Message-ID | <sJ9dv-4cm-17@gated-at.bofh.it> (permalink) |
| References | <sISw2-1KH-43@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue 29-11-16 18:29:06, Yuriy Kolerov wrote: > Despite the fact that subtraction of unsigned integers is a defined > behaviour however such operations can lead to unexpected results. Thus > it is better to check both left and right boundaries to avoid potential > bugs as it done in the generic page.h. Why and which code would use an out of range pfn? Why other arches do not need to care? > > Signed-off-by: Yuriy Kolerov <yuriy.kolerov@synopsys.com> > --- > arch/arc/include/asm/page.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/arc/include/asm/page.h b/arch/arc/include/asm/page.h > index 296c342..81cfc6c7 100644 > --- a/arch/arc/include/asm/page.h > +++ b/arch/arc/include/asm/page.h > @@ -88,7 +88,7 @@ typedef pte_t * pgtable_t; > #define ARCH_PFN_OFFSET virt_to_pfn(CONFIG_LINUX_LINK_BASE) > > #ifdef CONFIG_FLATMEM > -#define pfn_valid(pfn) (((pfn) - ARCH_PFN_OFFSET) < max_mapnr) > +#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr) > #endif > > /* > -- > 2.7.4 > -- Michal Hocko SUSE Labs
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM Yuriy Kolerov <yuriy.kolerov@synopsys.com> - 2016-11-29 16:30 +0100
Re: [RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM Michal Hocko <mhocko@kernel.org> - 2016-11-30 10:20 +0100
RE: [RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM Yuriy Kolerov <Yuriy.Kolerov@synopsys.com> - 2016-11-30 15:30 +0100
Re: [RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2016-11-30 18:00 +0100
RE: [RFC] ARC: mm: Restrict definition of pfn_valid() macro for CONFIG_FLATMEM Yuriy Kolerov <Yuriy.Kolerov@synopsys.com> - 2016-12-02 15:20 +0100
csiph-web