[1/1] powerpc/pseries/dlpar: Fix a missing check in dlpar_parse_cc_property()
diff mbox series

Message ID 1563220419-25080-2-git-send-email-tyhicks@canonical.com
State New
Headers show
Series
  • CVE-2019-12614: POWER DoS
Related show

Commit Message

Tyler Hicks July 15, 2019, 7:53 p.m. UTC
From: Gen Zhang <blackgod016574@gmail.com>

In dlpar_parse_cc_property(), 'prop->name' is allocated by kstrdup().
kstrdup() may return NULL, so it should be checked and handle error.
And prop should be freed if 'prop->name' is NULL.

Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

CVE-2019-12614

(cherry picked from commit efa9ace68e487ddd29c2b4d6dd23242158f1f607)
Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
---
 arch/powerpc/platforms/pseries/dlpar.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Kleber Souza July 16, 2019, 10:59 a.m. UTC | #1
On 15.07.19 21:53, Tyler Hicks wrote:
> From: Gen Zhang <blackgod016574@gmail.com>
> 
> In dlpar_parse_cc_property(), 'prop->name' is allocated by kstrdup().
> kstrdup() may return NULL, so it should be checked and handle error.
> And prop should be freed if 'prop->name' is NULL.
> 
> Signed-off-by: Gen Zhang <blackgod016574@gmail.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> 
> CVE-2019-12614
> 
> (cherry picked from commit efa9ace68e487ddd29c2b4d6dd23242158f1f607)
> Signed-off-by: Tyler Hicks <tyhicks@canonical.com>

Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>


> ---
>  arch/powerpc/platforms/pseries/dlpar.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
> index 437a74173db2..ee4aa1dd34c9 100644
> --- a/arch/powerpc/platforms/pseries/dlpar.c
> +++ b/arch/powerpc/platforms/pseries/dlpar.c
> @@ -58,6 +58,10 @@ static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
>  
>  	name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
>  	prop->name = kstrdup(name, GFP_KERNEL);
> +	if (!prop->name) {
> +		dlpar_free_cc_property(prop);
> +		return NULL;
> +	}
>  
>  	prop->length = be32_to_cpu(ccwa->prop_length);
>  	value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);
>

Patch
diff mbox series

diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c
index 437a74173db2..ee4aa1dd34c9 100644
--- a/arch/powerpc/platforms/pseries/dlpar.c
+++ b/arch/powerpc/platforms/pseries/dlpar.c
@@ -58,6 +58,10 @@  static struct property *dlpar_parse_cc_property(struct cc_workarea *ccwa)
 
 	name = (char *)ccwa + be32_to_cpu(ccwa->name_offset);
 	prop->name = kstrdup(name, GFP_KERNEL);
+	if (!prop->name) {
+		dlpar_free_cc_property(prop);
+		return NULL;
+	}
 
 	prop->length = be32_to_cpu(ccwa->prop_length);
 	value = (char *)ccwa + be32_to_cpu(ccwa->prop_offset);