lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ac5b9485-c9cb-9458-1101-6a219ee1faa5@marvell.com>
Date:   Fri, 30 Sep 2022 12:20:01 +0300
From:   Taras Chornyi <tchornyi@...vell.com>
To:     Jiasheng Jiang <jiasheng@...as.ac.cn>, vmytnyk@...vell.com,
        davem@...emloft.net, edumazet@...gle.com, kuba@...nel.org,
        pabeni@...hat.com
Cc:     netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: prestera: acl: Add check for kmemdup


> ----------------------------------------------------------------------
> As the kemdup could return NULL, it should be better to check the return
> value and return error if fails.
> Moreover, the return value of prestera_acl_ruleset_keymask_set() should
> be checked by cascade.
>
> Fixes: 604ba230902d ("net: prestera: flower template support")
> Signed-off-by: Jiasheng Jiang <jiasheng@...as.ac.cn>
> ---
>   drivers/net/ethernet/marvell/prestera/prestera_acl.c    | 8 ++++++--
>   drivers/net/ethernet/marvell/prestera/prestera_acl.h    | 4 ++--
>   drivers/net/ethernet/marvell/prestera/prestera_flower.c | 6 +++++-
>   3 files changed, 13 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_acl.c b/drivers/net/ethernet/marvell/prestera/prestera_acl.c
> index 3d4b85f2d541..f6b2933859d0 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_acl.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_acl.c
> @@ -178,10 +178,14 @@ prestera_acl_ruleset_create(struct prestera_acl *acl,
>   	return ERR_PTR(err);
>   }
>   
> -void prestera_acl_ruleset_keymask_set(struct prestera_acl_ruleset *ruleset,
> -				      void *keymask)
> +int prestera_acl_ruleset_keymask_set(struct prestera_acl_ruleset *ruleset,
> +				     void *keymask)
>   {
>   	ruleset->keymask = kmemdup(keymask, ACL_KEYMASK_SIZE, GFP_KERNEL);
> +	if (!ruleset->keymask)
> +		return -ENOMEM;
> +
> +	return 0;
>   }
>   
>   int prestera_acl_ruleset_offload(struct prestera_acl_ruleset *ruleset)
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_acl.h b/drivers/net/ethernet/marvell/prestera/prestera_acl.h
> index 03fc5b9dc925..131bfbc87cd7 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_acl.h
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_acl.h
> @@ -185,8 +185,8 @@ struct prestera_acl_ruleset *
>   prestera_acl_ruleset_lookup(struct prestera_acl *acl,
>   			    struct prestera_flow_block *block,
>   			    u32 chain_index);
> -void prestera_acl_ruleset_keymask_set(struct prestera_acl_ruleset *ruleset,
> -				      void *keymask);
> +int prestera_acl_ruleset_keymask_set(struct prestera_acl_ruleset *ruleset,
> +				     void *keymask);
>   bool prestera_acl_ruleset_is_offload(struct prestera_acl_ruleset *ruleset);
>   int prestera_acl_ruleset_offload(struct prestera_acl_ruleset *ruleset);
>   void prestera_acl_ruleset_put(struct prestera_acl_ruleset *ruleset);
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_flower.c b/drivers/net/ethernet/marvell/prestera/prestera_flower.c
> index 19d3b55c578e..cf551a8379ac 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_flower.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_flower.c
> @@ -452,7 +452,9 @@ int prestera_flower_tmplt_create(struct prestera_flow_block *block,
>   	}
>   
>   	/* preserve keymask/template to this ruleset */
> -	prestera_acl_ruleset_keymask_set(ruleset, rule.re_key.match.mask);
> +	err = prestera_acl_ruleset_keymask_set(ruleset, rule.re_key.match.mask);
> +	if (err)
> +		goto err_ruleset_keymask_set;
>   
>   	/* skip error, as it is not possible to reject template operation,
>   	 * so, keep the reference to the ruleset for rules to be added
> @@ -468,6 +470,8 @@ int prestera_flower_tmplt_create(struct prestera_flow_block *block,
>   	list_add_rcu(&template->list, &block->template_list);
>   	return 0;
>   
> +err_ruleset_keymask_set:
> +	prestera_acl_ruleset_put(ruleset);
>   err_ruleset_get:
>   	kfree(template);
>   err_malloc:

Reviewed-by: Taras Chornyi<tchornyi@...vell.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ