Linux-RDMA Archive on
 help / color / Atom feed
From: Kamal Heib <>
Cc: Jason Gunthorpe <>,
	Doug Ledford <>,
	Kamal Heib <>
Subject: [PATCH for-next V2] RDMA/core: Fix storing node description
Date: Tue, 14 Jan 2020 10:14:55 +0200
Message-ID: <> (raw)

Make sure to return -EINVAL when the supplied string is bigger then
the node_desc array.

Fixes: c5bcbbb9fe00 ("IB: Allow userspace to set node description")
Signed-off-by: Kamal Heib <>
 drivers/infiniband/core/sysfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/infiniband/core/sysfs.c b/drivers/infiniband/core/sysfs.c
index 087682e6969e..aa90a42d6565 100644
--- a/drivers/infiniband/core/sysfs.c
+++ b/drivers/infiniband/core/sysfs.c
@@ -1268,7 +1268,9 @@ static ssize_t node_desc_store(struct device *device,
 	if (!dev->ops.modify_device)
 		return -EOPNOTSUPP;
-	memcpy(desc.node_desc, buf, min_t(int, count, IB_DEVICE_NODE_DESC_MAX));
+	if (strscpy(desc.node_desc, buf, sizeof(desc.node_desc)) == -E2BIG)
+		return -EINVAL;
 	ret = ib_modify_device(dev, IB_DEVICE_MODIFY_NODE_DESC, &desc);
 	if (ret)
 		return ret;

             reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-14  8:14 Kamal Heib [this message]
2020-01-15 18:54 ` Jason Gunthorpe

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Linux-RDMA Archive on

Archives are clonable:
	git clone --mirror linux-rdma/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-rdma linux-rdma/ \
	public-inbox-index linux-rdma

Example config snippet for mirrors

Newsgroup available over NNTP:

AGPL code for this site: git clone