Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
* ACPI / LPIT: Correct LPIT end address for lpit_process()
@ 2019-05-02 20:00 Lenny Szubowicz
  2019-05-02 20:00 ` Lenny Szubowicz
  2019-05-06 23:46 ` Srinivas Pandruvada
  0 siblings, 2 replies; 5+ messages in thread
From: Lenny Szubowicz @ 2019-05-02 20:00 UTC (permalink / raw)
  To: rjw, lenb, srinivas.pandruvada, linux-acpi, linux-kernel

Correct the LPIT end address which is passed into lpit_process()
and the end address limit test in lpit_process().

The LPI state descriptor subtables follow the fixed sized
acpi_lpit_header up to the end of the LPIT. The last LPI state
descriptor can end at exactly the end of the LPIT.

Note that this is a fix to a latent problem. Although incorrect,
the unpatched version works because the passed in end address
is just slightly beyond the actual end of the LPIT and the size
of the ACPI LPIT header is smaller than the size of the only
currently defined LPI state descriptor, acpi_lpit_native.

Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
---
 drivers/acpi/acpi_lpit.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
index e43cb71b6972..8b170a07908a 100644
--- a/drivers/acpi/acpi_lpit.c
+++ b/drivers/acpi/acpi_lpit.c
@@ -137,7 +137,7 @@ static void lpit_update_residency(struct lpit_residency_info *info,
 
 static void lpit_process(u64 begin, u64 end)
 {
-	while (begin + sizeof(struct acpi_lpit_native) < end) {
+	while (begin + sizeof(struct acpi_lpit_native) <= end) {
 		struct acpi_lpit_native *lpit_native = (struct acpi_lpit_native *)begin;
 
 		if (!lpit_native->header.type && !lpit_native->header.flags) {
@@ -156,7 +156,6 @@ static void lpit_process(u64 begin, u64 end)
 void acpi_init_lpit(void)
 {
 	acpi_status status;
-	u64 lpit_begin;
 	struct acpi_table_lpit *lpit;
 
 	status = acpi_get_table(ACPI_SIG_LPIT, 0, (struct acpi_table_header **)&lpit);
@@ -164,6 +163,6 @@ void acpi_init_lpit(void)
 	if (ACPI_FAILURE(status))
 		return;
 
-	lpit_begin = (u64)lpit + sizeof(*lpit);
-	lpit_process(lpit_begin, lpit_begin + lpit->header.length);
+	lpit_process((u64)lpit + sizeof(*lpit),
+		     (u64)lpit + lpit->header.length);
 }
-- 
2.18.1

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

* ACPI / LPIT: Correct LPIT end address for lpit_process()
  2019-05-02 20:00 ACPI / LPIT: Correct LPIT end address for lpit_process() Lenny Szubowicz
@ 2019-05-02 20:00 ` Lenny Szubowicz
  2019-05-06 23:46 ` Srinivas Pandruvada
  1 sibling, 0 replies; 5+ messages in thread
From: Lenny Szubowicz @ 2019-05-02 20:00 UTC (permalink / raw)
  To: rjw, lenb, srinivas.pandruvada, linux-acpi, linux-kernel

Correct the LPIT end address which is passed into lpit_process()
and the end address limit test in lpit_process().

The LPI state descriptor subtables follow the fixed sized
acpi_lpit_header up to the end of the LPIT. The last LPI state
descriptor can end at exactly the end of the LPIT.

Note that this is a fix to a latent problem. Although incorrect,
the unpatched version works because the passed in end address
is just slightly beyond the actual end of the LPIT and the size
of the ACPI LPIT header is smaller than the size of the only
currently defined LPI state descriptor, acpi_lpit_native.

Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
---
 drivers/acpi/acpi_lpit.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
index e43cb71b6972..8b170a07908a 100644
--- a/drivers/acpi/acpi_lpit.c
+++ b/drivers/acpi/acpi_lpit.c
@@ -137,7 +137,7 @@ static void lpit_update_residency(struct lpit_residency_info *info,
 
 static void lpit_process(u64 begin, u64 end)
 {
-	while (begin + sizeof(struct acpi_lpit_native) < end) {
+	while (begin + sizeof(struct acpi_lpit_native) <= end) {
 		struct acpi_lpit_native *lpit_native = (struct acpi_lpit_native *)begin;
 
 		if (!lpit_native->header.type && !lpit_native->header.flags) {
@@ -156,7 +156,6 @@ static void lpit_process(u64 begin, u64 end)
 void acpi_init_lpit(void)
 {
 	acpi_status status;
-	u64 lpit_begin;
 	struct acpi_table_lpit *lpit;
 
 	status = acpi_get_table(ACPI_SIG_LPIT, 0, (struct acpi_table_header **)&lpit);
@@ -164,6 +163,6 @@ void acpi_init_lpit(void)
 	if (ACPI_FAILURE(status))
 		return;
 
-	lpit_begin = (u64)lpit + sizeof(*lpit);
-	lpit_process(lpit_begin, lpit_begin + lpit->header.length);
+	lpit_process((u64)lpit + sizeof(*lpit),
+		     (u64)lpit + lpit->header.length);
 }
-- 
2.18.1


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

* Re: ACPI / LPIT: Correct LPIT end address for lpit_process()
  2019-05-02 20:00 ACPI / LPIT: Correct LPIT end address for lpit_process() Lenny Szubowicz
  2019-05-02 20:00 ` Lenny Szubowicz
@ 2019-05-06 23:46 ` Srinivas Pandruvada
  2019-05-06 23:46   ` Srinivas Pandruvada
  2019-05-31  9:25   ` Rafael J. Wysocki
  1 sibling, 2 replies; 5+ messages in thread
From: Srinivas Pandruvada @ 2019-05-06 23:46 UTC (permalink / raw)
  To: Lenny Szubowicz, rjw, lenb, linux-acpi, linux-kernel

On Thu, 2019-05-02 at 16:00 -0400, Lenny Szubowicz wrote:
> Correct the LPIT end address which is passed into lpit_process()
> and the end address limit test in lpit_process().
> 
> The LPI state descriptor subtables follow the fixed sized
> acpi_lpit_header up to the end of the LPIT. The last LPI state
> descriptor can end at exactly the end of the LPIT.
> 
> Note that this is a fix to a latent problem. Although incorrect,
> the unpatched version works because the passed in end address
> is just slightly beyond the actual end of the LPIT and the size
> of the ACPI LPIT header is smaller than the size of the only
> currently defined LPI state descriptor, acpi_lpit_native.
> 
> Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
>  drivers/acpi/acpi_lpit.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> index e43cb71b6972..8b170a07908a 100644
> --- a/drivers/acpi/acpi_lpit.c
> +++ b/drivers/acpi/acpi_lpit.c
> @@ -137,7 +137,7 @@ static void lpit_update_residency(struct
> lpit_residency_info *info,
>  
>  static void lpit_process(u64 begin, u64 end)
>  {
> -	while (begin + sizeof(struct acpi_lpit_native) < end) {
> +	while (begin + sizeof(struct acpi_lpit_native) <= end) {
>  		struct acpi_lpit_native *lpit_native = (struct
> acpi_lpit_native *)begin;
>  
>  		if (!lpit_native->header.type && !lpit_native-
> >header.flags) {
> @@ -156,7 +156,6 @@ static void lpit_process(u64 begin, u64 end)
>  void acpi_init_lpit(void)
>  {
>  	acpi_status status;
> -	u64 lpit_begin;
>  	struct acpi_table_lpit *lpit;
>  
>  	status = acpi_get_table(ACPI_SIG_LPIT, 0, (struct
> acpi_table_header **)&lpit);
> @@ -164,6 +163,6 @@ void acpi_init_lpit(void)
>  	if (ACPI_FAILURE(status))
>  		return;
>  
> -	lpit_begin = (u64)lpit + sizeof(*lpit);
> -	lpit_process(lpit_begin, lpit_begin + lpit->header.length);
> +	lpit_process((u64)lpit + sizeof(*lpit),
> +		     (u64)lpit + lpit->header.length);
>  }

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

* Re: ACPI / LPIT: Correct LPIT end address for lpit_process()
  2019-05-06 23:46 ` Srinivas Pandruvada
@ 2019-05-06 23:46   ` Srinivas Pandruvada
  2019-05-31  9:25   ` Rafael J. Wysocki
  1 sibling, 0 replies; 5+ messages in thread
From: Srinivas Pandruvada @ 2019-05-06 23:46 UTC (permalink / raw)
  To: Lenny Szubowicz, rjw, lenb, linux-acpi, linux-kernel

On Thu, 2019-05-02 at 16:00 -0400, Lenny Szubowicz wrote:
> Correct the LPIT end address which is passed into lpit_process()
> and the end address limit test in lpit_process().
> 
> The LPI state descriptor subtables follow the fixed sized
> acpi_lpit_header up to the end of the LPIT. The last LPI state
> descriptor can end at exactly the end of the LPIT.
> 
> Note that this is a fix to a latent problem. Although incorrect,
> the unpatched version works because the passed in end address
> is just slightly beyond the actual end of the LPIT and the size
> of the ACPI LPIT header is smaller than the size of the only
> currently defined LPI state descriptor, acpi_lpit_native.
> 
> Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

> ---
>  drivers/acpi/acpi_lpit.c | 7 +++----
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> index e43cb71b6972..8b170a07908a 100644
> --- a/drivers/acpi/acpi_lpit.c
> +++ b/drivers/acpi/acpi_lpit.c
> @@ -137,7 +137,7 @@ static void lpit_update_residency(struct
> lpit_residency_info *info,
>  
>  static void lpit_process(u64 begin, u64 end)
>  {
> -	while (begin + sizeof(struct acpi_lpit_native) < end) {
> +	while (begin + sizeof(struct acpi_lpit_native) <= end) {
>  		struct acpi_lpit_native *lpit_native = (struct
> acpi_lpit_native *)begin;
>  
>  		if (!lpit_native->header.type && !lpit_native-
> >header.flags) {
> @@ -156,7 +156,6 @@ static void lpit_process(u64 begin, u64 end)
>  void acpi_init_lpit(void)
>  {
>  	acpi_status status;
> -	u64 lpit_begin;
>  	struct acpi_table_lpit *lpit;
>  
>  	status = acpi_get_table(ACPI_SIG_LPIT, 0, (struct
> acpi_table_header **)&lpit);
> @@ -164,6 +163,6 @@ void acpi_init_lpit(void)
>  	if (ACPI_FAILURE(status))
>  		return;
>  
> -	lpit_begin = (u64)lpit + sizeof(*lpit);
> -	lpit_process(lpit_begin, lpit_begin + lpit->header.length);
> +	lpit_process((u64)lpit + sizeof(*lpit),
> +		     (u64)lpit + lpit->header.length);
>  }


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

* Re: ACPI / LPIT: Correct LPIT end address for lpit_process()
  2019-05-06 23:46 ` Srinivas Pandruvada
  2019-05-06 23:46   ` Srinivas Pandruvada
@ 2019-05-31  9:25   ` Rafael J. Wysocki
  1 sibling, 0 replies; 5+ messages in thread
From: Rafael J. Wysocki @ 2019-05-31  9:25 UTC (permalink / raw)
  To: Srinivas Pandruvada, Lenny Szubowicz; +Cc: lenb, linux-acpi, linux-kernel

On Tuesday, May 7, 2019 1:46:15 AM CEST Srinivas Pandruvada wrote:
> On Thu, 2019-05-02 at 16:00 -0400, Lenny Szubowicz wrote:
> > Correct the LPIT end address which is passed into lpit_process()
> > and the end address limit test in lpit_process().
> > 
> > The LPI state descriptor subtables follow the fixed sized
> > acpi_lpit_header up to the end of the LPIT. The last LPI state
> > descriptor can end at exactly the end of the LPIT.
> > 
> > Note that this is a fix to a latent problem. Although incorrect,
> > the unpatched version works because the passed in end address
> > is just slightly beyond the actual end of the LPIT and the size
> > of the ACPI LPIT header is smaller than the size of the only
> > currently defined LPI state descriptor, acpi_lpit_native.
> > 
> > Signed-off-by: Lenny Szubowicz <lszubowi@redhat.com>
> Reviewed-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
> 
> > ---
> >  drivers/acpi/acpi_lpit.c | 7 +++----
> >  1 file changed, 3 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/acpi/acpi_lpit.c b/drivers/acpi/acpi_lpit.c
> > index e43cb71b6972..8b170a07908a 100644
> > --- a/drivers/acpi/acpi_lpit.c
> > +++ b/drivers/acpi/acpi_lpit.c
> > @@ -137,7 +137,7 @@ static void lpit_update_residency(struct
> > lpit_residency_info *info,
> >  
> >  static void lpit_process(u64 begin, u64 end)
> >  {
> > -	while (begin + sizeof(struct acpi_lpit_native) < end) {
> > +	while (begin + sizeof(struct acpi_lpit_native) <= end) {
> >  		struct acpi_lpit_native *lpit_native = (struct
> > acpi_lpit_native *)begin;
> >  
> >  		if (!lpit_native->header.type && !lpit_native-
> > >header.flags) {
> > @@ -156,7 +156,6 @@ static void lpit_process(u64 begin, u64 end)
> >  void acpi_init_lpit(void)
> >  {
> >  	acpi_status status;
> > -	u64 lpit_begin;
> >  	struct acpi_table_lpit *lpit;
> >  
> >  	status = acpi_get_table(ACPI_SIG_LPIT, 0, (struct
> > acpi_table_header **)&lpit);
> > @@ -164,6 +163,6 @@ void acpi_init_lpit(void)
> >  	if (ACPI_FAILURE(status))
> >  		return;
> >  
> > -	lpit_begin = (u64)lpit + sizeof(*lpit);
> > -	lpit_process(lpit_begin, lpit_begin + lpit->header.length);
> > +	lpit_process((u64)lpit + sizeof(*lpit),
> > +		     (u64)lpit + lpit->header.length);
> >  }
> 
> 

Patch applied, thanks!




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

end of thread, back to index

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-02 20:00 ACPI / LPIT: Correct LPIT end address for lpit_process() Lenny Szubowicz
2019-05-02 20:00 ` Lenny Szubowicz
2019-05-06 23:46 ` Srinivas Pandruvada
2019-05-06 23:46   ` Srinivas Pandruvada
2019-05-31  9:25   ` Rafael J. Wysocki

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org linux-acpi@archiver.kernel.org
	public-inbox-index linux-acpi


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/ public-inbox