All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: dan.j.williams@intel.com, mpe@ellerman.id.au
Cc: linux-nvdimm@lists.01.org, linuxppc-dev@lists.ozlabs.org,
	"Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
Subject: [RFC PATCH 4/4] libnvdimm/namespace: Add debug check while initializing namespace resource size.
Date: Mon, 28 Oct 2019 15:18:25 +0530	[thread overview]
Message-ID: <20191028094825.21448-4-aneesh.kumar@linux.ibm.com> (raw)
In-Reply-To: <20191028094825.21448-1-aneesh.kumar@linux.ibm.com>

This should enable us to catch if we are initializing the namespace with a wrong
size.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 drivers/nvdimm/namespace_devs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 83c70631a86f..9f2dc20bcc73 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -956,6 +956,18 @@ static void nd_namespace_pmem_set_resource(struct nd_region *nd_region,
  out:
 	res->start = nd_region->ndr_start + offset;
 	res->end = res->start + size - 1;
+#ifdef CONFIG_DEBUG_VM
+	if (size) {
+		unsigned long map_size;
+
+		map_size = arch_validate_namespace_size(nd_region->ndr_mappings, size);
+		WARN_ON(map_size);
+
+		map_size = arch_validate_namespace_size(1, res->start);
+		WARN_ON(map_size);
+
+	}
+#endif
 }
 
 static bool uuid_not_set(const u8 *uuid, struct device *dev, const char *where)
-- 
2.21.0
_______________________________________________
Linux-nvdimm mailing list -- linux-nvdimm@lists.01.org
To unsubscribe send an email to linux-nvdimm-leave@lists.01.org

WARNING: multiple messages have this Message-ID (diff)
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>
To: dan.j.williams@intel.com, mpe@ellerman.id.au
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, linux-nvdimm@lists.01.org
Subject: [RFC PATCH 4/4] libnvdimm/namespace: Add debug check while initializing namespace resource size.
Date: Mon, 28 Oct 2019 15:18:25 +0530	[thread overview]
Message-ID: <20191028094825.21448-4-aneesh.kumar@linux.ibm.com> (raw)
In-Reply-To: <20191028094825.21448-1-aneesh.kumar@linux.ibm.com>

This should enable us to catch if we are initializing the namespace with a wrong
size.

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
 drivers/nvdimm/namespace_devs.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/nvdimm/namespace_devs.c b/drivers/nvdimm/namespace_devs.c
index 83c70631a86f..9f2dc20bcc73 100644
--- a/drivers/nvdimm/namespace_devs.c
+++ b/drivers/nvdimm/namespace_devs.c
@@ -956,6 +956,18 @@ static void nd_namespace_pmem_set_resource(struct nd_region *nd_region,
  out:
 	res->start = nd_region->ndr_start + offset;
 	res->end = res->start + size - 1;
+#ifdef CONFIG_DEBUG_VM
+	if (size) {
+		unsigned long map_size;
+
+		map_size = arch_validate_namespace_size(nd_region->ndr_mappings, size);
+		WARN_ON(map_size);
+
+		map_size = arch_validate_namespace_size(1, res->start);
+		WARN_ON(map_size);
+
+	}
+#endif
 }
 
 static bool uuid_not_set(const u8 *uuid, struct device *dev, const char *where)
-- 
2.21.0


  parent reply	other threads:[~2019-10-28  9:48 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-28  9:48 [RFC PATCH 1/4] libnvdimm/namespace: Make namespace size validation arch dependent Aneesh Kumar K.V
2019-10-28  9:48 ` Aneesh Kumar K.V
2019-10-28  9:48 ` [RFC PATCH 2/4] libnvdimm/namespace: Disable the region if the namespace size is not aligned correctly Aneesh Kumar K.V
2019-10-28  9:48   ` Aneesh Kumar K.V
2019-10-30  9:12   ` kbuild test robot
2019-10-28  9:48 ` [RFC PATCH 3/4] libnvdimm/namespace: Use direct-mapping page size to validate namespace size Aneesh Kumar K.V
2019-10-28  9:48   ` Aneesh Kumar K.V
2019-10-28  9:48 ` Aneesh Kumar K.V [this message]
2019-10-28  9:48   ` [RFC PATCH 4/4] libnvdimm/namespace: Add debug check while initializing namespace resource size Aneesh Kumar K.V
2019-10-28 21:21 ` [RFC PATCH 1/4] libnvdimm/namespace: Make namespace size validation arch dependent Ira Weiny
2019-10-28 21:21   ` Ira Weiny
2019-10-29  4:34   ` Aneesh Kumar K.V
2019-10-29  4:34     ` Aneesh Kumar K.V
2019-10-28 23:08 ` Dan Williams
2019-10-28 23:08   ` Dan Williams
2019-10-29  4:34   ` Aneesh Kumar K.V
2019-10-29  4:34     ` Aneesh Kumar K.V
2019-10-29  5:30     ` Dan Williams
2019-10-29  5:30       ` Dan Williams
2019-10-31  5:35       ` Aneesh Kumar K.V
2019-10-31  5:35         ` Aneesh Kumar K.V
2019-10-31  6:30         ` Dan Williams
2019-10-31  6:30           ` Dan Williams
2019-10-31  8:37           ` Aneesh Kumar K.V
2019-10-31  8:37             ` Aneesh Kumar K.V
2019-10-31 15:53             ` Dan Williams
2019-10-31 15:53               ` Dan Williams
2019-11-06 10:44           ` Aneesh Kumar K.V
2019-11-06 10:44             ` Aneesh Kumar K.V
2019-11-16 12:15             ` Aneesh Kumar K.V
2019-11-16 12:15               ` Aneesh Kumar K.V
2019-11-16 18:50               ` Dan Williams
2019-11-16 18:50                 ` Dan Williams
2019-11-18  9:51                 ` Aneesh Kumar K.V
2019-11-18  9:51                   ` Aneesh Kumar K.V
2019-11-19 17:58                   ` Dan Williams
2019-11-19 17:58                     ` Dan Williams
2019-11-20  3:19                     ` Aneesh Kumar K.V
2019-11-20  3:19                       ` Aneesh Kumar K.V
2019-11-20  3:46                       ` Dan Williams
2019-11-20  3:46                         ` Dan Williams

Reply instructions:

You may reply publicly 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20191028094825.21448-4-aneesh.kumar@linux.ibm.com \
    --to=aneesh.kumar@linux.ibm.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-nvdimm@lists.01.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=mpe@ellerman.id.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.