mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] arch:arm:mm:Correction in the boundary check for module end address.
@ 2015-11-09  7:57 Shailendra Verma
  2015-11-09 15:35 ` Jungseung Lee
  0 siblings, 1 reply; 4+ messages in thread
From: Shailendra Verma @ 2015-11-09  7:57 UTC (permalink / raw)
  To: Russell King, Greg Kroah-Hartman, Arve Hjønnevåg,
	Riley Andrews, Laura Abbott, Jungseung Lee, Shailendra Verma,
	Dan Carpenter, Mitchel Humpherys, Sumit Semwal,
	Kirill A. Shutemov, Gioh Kim, Rasmus Villemoes, Shawn Lin,
	Markus Elfring, linux-arm-kernel, devel
  Cc: Ravikant Bijendra Sharma, Shailendra Verma, linux-kernel, vidushi.koul

From: Shailendra Verma <Shailendra.v@samsung.com>

The module end boundary check is not proper.The out of bound value
of module end can produce undesired results.

Signed-off-by: Shailendra Verma <Shailendra.v@samsung.com>
Reviewed-by: Ravikant Bijendra Sharma <ravikant.s2@samsung.com>
---
 linux-4.3-rc6/arch/arm/mm/pageattr.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-4.3-rc6/arch/arm/mm/pageattr.c b/linux-4.3-rc6/arch/arm/mm/pageattr.c
index cf30daf..be7fe4b 100644
--- a/linux-4.3-rc6/arch/arm/mm/pageattr.c
+++ b/linux-4.3-rc6/arch/arm/mm/pageattr.c
@@ -52,7 +52,7 @@ static int change_memory_common(unsigned long addr, int numpages,
 	if (start < MODULES_VADDR || start >= MODULES_END)
 		return -EINVAL;
 
-	if (end < MODULES_VADDR || start >= MODULES_END)
+	if (end < MODULES_VADDR || end >= MODULES_END)
 		return -EINVAL;
 
 	data.set_mask = set_mask;
-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arch:arm:mm:Correction in the boundary check for module end address.
  2015-11-09  7:57 [PATCH] arch:arm:mm:Correction in the boundary check for module end address Shailendra Verma
@ 2015-11-09 15:35 ` Jungseung Lee
  2015-11-09 16:01   ` Russell King - ARM Linux
  0 siblings, 1 reply; 4+ messages in thread
From: Jungseung Lee @ 2015-11-09 15:35 UTC (permalink / raw)
  To: Shailendra Verma
  Cc: Russell King, Greg Kroah-Hartman, Arve Hjønnevåg,
	Riley Andrews, Laura Abbott, Shailendra Verma, Dan Carpenter,
	Mitchel Humpherys, Sumit Semwal, Kirill A. Shutemov, Gioh Kim,
	Rasmus Villemoes, Shawn Lin, Markus Elfring, linux-arm-kernel,
	devel, Ravikant Bijendra Sharma, Shailendra Verma, linux-kernel,
	vidushi.koul, hillf.zj

Hi,

2015-11-09 16:57 GMT+09:00 Shailendra Verma <shailendra.v@samung.com>:
> From: Shailendra Verma <Shailendra.v@samsung.com>
>
> The module end boundary check is not proper.The out of bound value
> of module end can produce undesired results.
>
> Signed-off-by: Shailendra Verma <Shailendra.v@samsung.com>
> Reviewed-by: Ravikant Bijendra Sharma <ravikant.s2@samsung.com>
> ---
>  linux-4.3-rc6/arch/arm/mm/pageattr.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/linux-4.3-rc6/arch/arm/mm/pageattr.c b/linux-4.3-rc6/arch/arm/mm/pageattr.c
> index cf30daf..be7fe4b 100644
> --- a/linux-4.3-rc6/arch/arm/mm/pageattr.c
> +++ b/linux-4.3-rc6/arch/arm/mm/pageattr.c
> @@ -52,7 +52,7 @@ static int change_memory_common(unsigned long addr, int numpages,
>         if (start < MODULES_VADDR || start >= MODULES_END)
>                 return -EINVAL;
>
> -       if (end < MODULES_VADDR || start >= MODULES_END)
> +       if (end < MODULES_VADDR || end >= MODULES_END)
>                 return -EINVAL;
>
>         data.set_mask = set_mask;
> --
> 1.7.9.5
>
Same patch with proper format is already submitted by Hillf.
https://lkml.org/lkml/2015/5/3/202

Best Regards,
Jungseung Lee

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arch:arm:mm:Correction in the boundary check for module end address.
  2015-11-09 15:35 ` Jungseung Lee
@ 2015-11-09 16:01   ` Russell King - ARM Linux
  2015-11-10  2:50     ` Hillf Danton
  0 siblings, 1 reply; 4+ messages in thread
From: Russell King - ARM Linux @ 2015-11-09 16:01 UTC (permalink / raw)
  To: Jungseung Lee
  Cc: Shailendra Verma, Greg Kroah-Hartman, Arve Hjønnevåg,
	Riley Andrews, Laura Abbott, Shailendra Verma, Dan Carpenter,
	Mitchel Humpherys, Sumit Semwal, Kirill A. Shutemov, Gioh Kim,
	Rasmus Villemoes, Shawn Lin, Markus Elfring, linux-arm-kernel,
	devel, Ravikant Bijendra Sharma, Shailendra Verma, linux-kernel,
	vidushi.koul, hillf.zj

On Tue, Nov 10, 2015 at 12:35:50AM +0900, Jungseung Lee wrote:
> Hi,
> 
> 2015-11-09 16:57 GMT+09:00 Shailendra Verma <shailendra.v@samung.com>:
> > From: Shailendra Verma <Shailendra.v@samsung.com>
> >
> > The module end boundary check is not proper.The out of bound value
> > of module end can produce undesired results.
> >
> > Signed-off-by: Shailendra Verma <Shailendra.v@samsung.com>
> > Reviewed-by: Ravikant Bijendra Sharma <ravikant.s2@samsung.com>
> > ---
> >  linux-4.3-rc6/arch/arm/mm/pageattr.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/linux-4.3-rc6/arch/arm/mm/pageattr.c b/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > index cf30daf..be7fe4b 100644
> > --- a/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > +++ b/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > @@ -52,7 +52,7 @@ static int change_memory_common(unsigned long addr, int numpages,
> >         if (start < MODULES_VADDR || start >= MODULES_END)
> >                 return -EINVAL;
> >
> > -       if (end < MODULES_VADDR || start >= MODULES_END)
> > +       if (end < MODULES_VADDR || end >= MODULES_END)
> >                 return -EINVAL;
> >
> >         data.set_mask = set_mask;
> > --
> > 1.7.9.5
> >
> Same patch with proper format is already submitted by Hillf.
> https://lkml.org/lkml/2015/5/3/202

What happened to that patch?  It should at least have had a:

Fixes: f2ca09f381a5 ("ARM: 8311/1: Don't use is_module_addr in setting page attributes")

tag on it, and it needs to find its way into the patch system.  As
no one has reported a crash (I don't think it's crash-causing, but is
merely a correctness issue) I don't see any reason to backport it to
stable trees.

Other changes are needed here as well - the original commit creating
this contains:

+       if (!IS_ALIGNED(addr, PAGE_SIZE)) {
+               start &= PAGE_MASK;
+               end = start + size;
+               WARN_ON_ONCE(1);
+       }

which is truely amazing.  Fine, it may not be intended to work with
non-aligned addresses, but if we're going to round the start down,
then rounding the end down as well like that is also buggy.

	unsigned long start = addr;
	unsigned long size = PAGE_SIZE * numpages;
	unsigned long end = start + size;

	if (WARN_ON_ONCE(!IS_ALIGNED(addr, PAGE_SIZE)) {
		start &= PAGE_MASK;
		end = PAGE_ALIGN(end);
	}

would be much better - this will round 'end' up, so we encompass the
entire requested region.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] arch:arm:mm:Correction in the boundary check for module end address.
  2015-11-09 16:01   ` Russell King - ARM Linux
@ 2015-11-10  2:50     ` Hillf Danton
  0 siblings, 0 replies; 4+ messages in thread
From: Hillf Danton @ 2015-11-10  2:50 UTC (permalink / raw)
  To: 'Russell King - ARM Linux', 'Jungseung Lee'
  Cc: 'Shailendra Verma', 'Greg Kroah-Hartman',
	'Arve Hjønnevåg', 'Riley Andrews',
	'Laura Abbott', 'Shailendra Verma',
	'Dan Carpenter', 'Mitchel Humpherys',
	'Sumit Semwal', 'Kirill A. Shutemov',
	'Gioh Kim', 'Rasmus Villemoes',
	'Shawn Lin', 'Markus Elfring',
	linux-arm-kernel, devel, 'Ravikant Bijendra Sharma',
	'Shailendra Verma',
	linux-kernel, vidushi.koul

> On Tue, Nov 10, 2015 at 12:35:50AM +0900, Jungseung Lee wrote:
> > Hi,
> >
> > 2015-11-09 16:57 GMT+09:00 Shailendra Verma <shailendra.v@samung.com>:
> > > From: Shailendra Verma <Shailendra.v@samsung.com>
> > >
> > > The module end boundary check is not proper.The out of bound value
> > > of module end can produce undesired results.
> > >
> > > Signed-off-by: Shailendra Verma <Shailendra.v@samsung.com>
> > > Reviewed-by: Ravikant Bijendra Sharma <ravikant.s2@samsung.com>
> > > ---
> > >  linux-4.3-rc6/arch/arm/mm/pageattr.c |    2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/linux-4.3-rc6/arch/arm/mm/pageattr.c b/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > > index cf30daf..be7fe4b 100644
> > > --- a/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > > +++ b/linux-4.3-rc6/arch/arm/mm/pageattr.c
> > > @@ -52,7 +52,7 @@ static int change_memory_common(unsigned long addr, int numpages,
> > >         if (start < MODULES_VADDR || start >= MODULES_END)
> > >                 return -EINVAL;
> > >
> > > -       if (end < MODULES_VADDR || start >= MODULES_END)
> > > +       if (end < MODULES_VADDR || end >= MODULES_END)
> > >                 return -EINVAL;
> > >
> > >         data.set_mask = set_mask;
> > > --
> > > 1.7.9.5
> > >
> > Same patch with proper format is already submitted by Hillf.
> > https://lkml.org/lkml/2015/5/3/202
> 
> What happened to that patch?  It should at least have had a:
> 
> Fixes: f2ca09f381a5 ("ARM: 8311/1: Don't use is_module_addr in setting page attributes")
> 
> tag on it, and it needs to find its way into the patch system.  As
> no one has reported a crash (I don't think it's crash-causing, but is
> merely a correctness issue) I don't see any reason to backport it to
> stable trees.
> 
> Other changes are needed here as well - the original commit creating
> this contains:
> 
> +       if (!IS_ALIGNED(addr, PAGE_SIZE)) {
> +               start &= PAGE_MASK;
> +               end = start + size;
> +               WARN_ON_ONCE(1);
> +       }
> 
> which is truely amazing.  Fine, it may not be intended to work with
> non-aligned addresses, but if we're going to round the start down,
> then rounding the end down as well like that is also buggy.
> 
> 	unsigned long start = addr;
> 	unsigned long size = PAGE_SIZE * numpages;
> 	unsigned long end = start + size;
> 
> 	if (WARN_ON_ONCE(!IS_ALIGNED(addr, PAGE_SIZE)) {
> 		start &= PAGE_MASK;
> 		end = PAGE_ALIGN(end);
> 	}
> 
> would be much better - this will round 'end' up, so we encompass the
> entire requested region.
> 
Would you please respin, Shailendra, with Russell's comments
addressed, and with
Reported-by: Hillf Danton <hillf.zj@alibaba-inc.com> ?

thanks
Hillf



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-11-10  2:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-09  7:57 [PATCH] arch:arm:mm:Correction in the boundary check for module end address Shailendra Verma
2015-11-09 15:35 ` Jungseung Lee
2015-11-09 16:01   ` Russell King - ARM Linux
2015-11-10  2:50     ` Hillf Danton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®