All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>, Christoph Hellwig <hch@lst.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	gmpy.liaowx@gmail.com, Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-doc@vger.kernel.org, linux-mtd@lists.infradead.org,
	linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 1/5] pstore/blk: Improve failure reporting
Date: Wed, 16 Jun 2021 09:40:39 -0700	[thread overview]
Message-ID: <20210616164043.1221861-2-keescook@chromium.org> (raw)
In-Reply-To: <20210616164043.1221861-1-keescook@chromium.org>

There was no feedback on bad registration attempts. Add details on the
failure cause.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 fs/pstore/blk.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c
index 4bb8a344957a..eca83820fb5d 100644
--- a/fs/pstore/blk.c
+++ b/fs/pstore/blk.c
@@ -114,8 +114,22 @@ static int __register_pstore_device(struct pstore_device_info *dev)
 
 	lockdep_assert_held(&pstore_blk_lock);
 
-	if (!dev || !dev->total_size || !dev->read || !dev->write)
+	if (!dev) {
+		pr_err("NULL device info\n");
 		return -EINVAL;
+	}
+	if (!dev->total_size) {
+		pr_err("zero sized device\n");
+		return -EINVAL;
+	}
+	if (!dev->read) {
+		pr_err("no read handler for device\n");
+		return -EINVAL;
+	}
+	if (!dev->write) {
+		pr_err("no write handler for device\n");
+		return -EINVAL;
+	}
 
 	/* someone already registered before */
 	if (pstore_zone_info)
-- 
2.25.1


WARNING: multiple messages have this Message-ID
From: Kees Cook <keescook@chromium.org>
To: linux-kernel@vger.kernel.org
Cc: Kees Cook <keescook@chromium.org>, Christoph Hellwig <hch@lst.de>,
	Al Viro <viro@zeniv.linux.org.uk>,
	gmpy.liaowx@gmail.com, Anton Vorontsov <anton@enomsg.org>,
	Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
	Jonathan Corbet <corbet@lwn.net>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Richard Weinberger <richard@nod.at>,
	Vignesh Raghavendra <vigneshr@ti.com>,
	linux-doc@vger.kernel.org, linux-mtd@lists.infradead.org,
	linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH v3 1/5] pstore/blk: Improve failure reporting
Date: Wed, 16 Jun 2021 09:40:39 -0700	[thread overview]
Message-ID: <20210616164043.1221861-2-keescook@chromium.org> (raw)
In-Reply-To: <20210616164043.1221861-1-keescook@chromium.org>

There was no feedback on bad registration attempts. Add details on the
failure cause.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 fs/pstore/blk.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/fs/pstore/blk.c b/fs/pstore/blk.c
index 4bb8a344957a..eca83820fb5d 100644
--- a/fs/pstore/blk.c
+++ b/fs/pstore/blk.c
@@ -114,8 +114,22 @@ static int __register_pstore_device(struct pstore_device_info *dev)
 
 	lockdep_assert_held(&pstore_blk_lock);
 
-	if (!dev || !dev->total_size || !dev->read || !dev->write)
+	if (!dev) {
+		pr_err("NULL device info\n");
 		return -EINVAL;
+	}
+	if (!dev->total_size) {
+		pr_err("zero sized device\n");
+		return -EINVAL;
+	}
+	if (!dev->read) {
+		pr_err("no read handler for device\n");
+		return -EINVAL;
+	}
+	if (!dev->write) {
+		pr_err("no write handler for device\n");
+		return -EINVAL;
+	}
 
 	/* someone already registered before */
 	if (pstore_zone_info)
-- 
2.25.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  reply	other threads:[~2021-06-16 16:40 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 16:40 [PATCH v3 0/5] Use the normal block device I/O path Kees Cook
2021-06-16 16:40 ` Kees Cook
2021-06-16 16:40 ` Kees Cook [this message]
2021-06-16 16:40   ` [PATCH v3 1/5] pstore/blk: Improve failure reporting Kees Cook
2021-06-17  7:55   ` Christoph Hellwig
2021-06-17  7:55     ` Christoph Hellwig
2021-06-16 16:40 ` [PATCH v3 2/5] pstore/blk: Move verify_size() macro out of function Kees Cook
2021-06-16 16:40   ` Kees Cook
2021-06-17  7:56   ` Christoph Hellwig
2021-06-17  7:56     ` Christoph Hellwig
2021-06-16 16:40 ` [PATCH v3 3/5] pstore/blk: Use the normal block device I/O path Kees Cook
2021-06-16 16:40   ` Kees Cook
2021-06-16 16:40 ` [PATCH v3 4/5] pstore/blk: Fix kerndoc and redundancy on blkdev param Kees Cook
2021-06-16 16:40   ` Kees Cook
2021-06-16 16:40 ` [PATCH v3 5/5] pstore/blk: Include zone in pstore_device_info Kees Cook
2021-06-16 16:40   ` Kees Cook
2021-06-17  7:57   ` Christoph Hellwig
2021-06-17  7:57     ` Christoph Hellwig

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=20210616164043.1221861-2-keescook@chromium.org \
    --to=keescook@chromium.org \
    --cc=anton@enomsg.org \
    --cc=ccross@android.com \
    --cc=corbet@lwn.net \
    --cc=gmpy.liaowx@gmail.com \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=miquel.raynal@bootlin.com \
    --cc=richard@nod.at \
    --cc=tony.luck@intel.com \
    --cc=vigneshr@ti.com \
    --cc=viro@zeniv.linux.org.uk \
    --subject='Re: [PATCH v3 1/5] pstore/blk: Improve failure reporting' \
    /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

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.