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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 26 Dec 2018 21:49:44 +0200
From:   Leon Romanovsky <leon@...nel.org>
To:     Kangjie Lu <kjlu@....edu>
Cc:     pakki001@....edu, Doug Ledford <dledford@...hat.com>,
        Jason Gunthorpe <jgg@...pe.ca>,
        Parav Pandit <parav@...lanox.com>,
        Dennis Dalessandro <dennis.dalessandro@...el.com>,
        Artemy Kovalyov <artemyko@...lanox.com>,
        Alex Estrin <alex.estrin@...el.com>,
        linux-rdma@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] infiniband: add checks for the status of nla_put

On Tue, Dec 25, 2018 at 08:11:39PM -0600, Kangjie Lu wrote:
> The fix inserts multiple checks for nla_put, and issues warnings if it
> fails.
>
> Signed-off-by: Kangjie Lu <kjlu@....edu>
> ---

I didn't look very close, but it strange that failure in nla_put()
doesn't follow by canceling of netlink message.

Plus extensive usage of pr_warn() is not needed here.

Thanks



>  drivers/infiniband/core/sa_query.c | 39 ++++++++++++++++++------------
>  1 file changed, 24 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/infiniband/core/sa_query.c b/drivers/infiniband/core/sa_query.c
> index be5ba5e15496..0e5d7a6dde36 100644
> --- a/drivers/infiniband/core/sa_query.c
> +++ b/drivers/infiniband/core/sa_query.c
> @@ -775,28 +775,37 @@ static void ib_nl_set_path_rec_attrs(struct sk_buff *skb,
>  	/* Now build the attributes */
>  	if (comp_mask & IB_SA_PATH_REC_SERVICE_ID) {
>  		val64 = be64_to_cpu(sa_rec->service_id);
> -		nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SERVICE_ID,
> -			sizeof(val64), &val64);
> +		if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SERVICE_ID,
> +			sizeof(val64), &val64))
> +			pr_warn("nla_put failed\n");
> +	}
> +	if (comp_mask & IB_SA_PATH_REC_DGID) {
> +		if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_DGID,
> +			sizeof(sa_rec->dgid), &sa_rec->dgid))
> +			pr_warn("nla_put failed\n");
> +	}
> +	if (comp_mask & IB_SA_PATH_REC_SGID) {
> +		if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SGID,
> +			sizeof(sa_rec->sgid), &sa_rec->sgid))
> +			pr_warn("nla_put failed\n");
> +	}
> +	if (comp_mask & IB_SA_PATH_REC_TRAFFIC_CLASS) {
> +		if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_TCLASS,
> +			sizeof(sa_rec->traffic_class), &sa_rec->traffic_class))
> +			pr_warn("nla_put failed\n");
>  	}
> -	if (comp_mask & IB_SA_PATH_REC_DGID)
> -		nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_DGID,
> -			sizeof(sa_rec->dgid), &sa_rec->dgid);
> -	if (comp_mask & IB_SA_PATH_REC_SGID)
> -		nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_SGID,
> -			sizeof(sa_rec->sgid), &sa_rec->sgid);
> -	if (comp_mask & IB_SA_PATH_REC_TRAFFIC_CLASS)
> -		nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_TCLASS,
> -			sizeof(sa_rec->traffic_class), &sa_rec->traffic_class);
>
>  	if (comp_mask & IB_SA_PATH_REC_PKEY) {
>  		val16 = be16_to_cpu(sa_rec->pkey);
> -		nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_PKEY,
> -			sizeof(val16), &val16);
> +		if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_PKEY,
> +			sizeof(val16), &val16))
> +			pr_warn("nla_put failed\n");
>  	}
>  	if (comp_mask & IB_SA_PATH_REC_QOS_CLASS) {
>  		val16 = be16_to_cpu(sa_rec->qos_class);
> -		nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_QOS_CLASS,
> -			sizeof(val16), &val16);
> +		if (nla_put(skb, RDMA_NLA_F_MANDATORY | LS_NLA_TYPE_QOS_CLASS,
> +			sizeof(val16), &val16))
> +			pr_warn("nla_put failed\n");
>  	}
>  }
>
> --
> 2.17.2 (Apple Git-113)
>

Download attachment "signature.asc" of type "application/pgp-signature" (802 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ