dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Ondrej Kozina <okozina@redhat.com>
To: dm-devel@redhat.com
Cc: Ondrej Kozina <okozina@redhat.com>,
	mgrac@redhat.com, kas@fi.muni.cz, mbroz@redhat.com
Subject: [RFC PATCH v2 2/3] Adds support for security checks in the linear target
Date: Fri, 25 May 2012 15:22:27 +0200	[thread overview]
Message-ID: <1337952148-20888-3-git-send-email-okozina@redhat.com> (raw)
In-Reply-To: <1337952148-20888-1-git-send-email-okozina@redhat.com>

Just a security check implementation for linear target

---
 drivers/md/dm-linear.c |   19 ++++++++++++++++++-
 1 files changed, 18 insertions(+), 1 deletions(-)

diff --git a/drivers/md/dm-linear.c b/drivers/md/dm-linear.c
index 3639eea..b04aa00 100644
--- a/drivers/md/dm-linear.c
+++ b/drivers/md/dm-linear.c
@@ -153,9 +153,25 @@ static int linear_iterate_devices(struct dm_target *ti,
 	return fn(ti, lc->dev, lc->start, ti->len, data);
 }
 
+static int linear_security(struct dm_target *ti, unsigned int argc, char **argv)
+{
+	int r;
+
+	if (argc < 1) {
+		ti->error = "dm-linear: Security check: invalid number of parameters";
+		return -EINVAL;
+	}
+
+	r = dm_check_backing_dev_permission(ti, argv[0]);
+	if (r)
+		ti->error = "dm-linear: Security check failed";
+
+	return r;
+}
+
 static struct target_type linear_target = {
 	.name   = "linear",
-	.version = {1, 1, 0},
+	.version = {1, 2, 0},
 	.module = THIS_MODULE,
 	.ctr    = linear_ctr,
 	.dtr    = linear_dtr,
@@ -164,6 +180,7 @@ static struct target_type linear_target = {
 	.ioctl  = linear_ioctl,
 	.merge  = linear_merge,
 	.iterate_devices = linear_iterate_devices,
+	.security = linear_security
 };
 
 int __init dm_linear_init(void)
-- 
1.7.8.6

  parent reply	other threads:[~2012-05-25 13:22 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-02 19:13 [RFC PATCH 0/4] Allow user w/o CAP_SYS_ADMIN to submit ioctl commands into DM okozina
2012-05-02 19:13 ` [RFC PATCH 1/4] Adds support for user-submitted ioctl commands okozina
2012-05-02 19:13 ` [RFC PATCH 2/4] Adds support for the dentry lookup from path or major:minor couple during target security check okozina
2012-05-02 19:13 ` [RFC PATCH 3/4] Adds support for security checks in the linear target okozina
2012-05-02 19:13 ` [RFC PATCH 4/4] Adds support for security checks in the crypt target okozina
2012-05-25 13:22 ` [RFC PATCH v2 0/3] Allow user w/o CAP_SYS_ADMIN to submit ioctl commands into DM Ondrej Kozina
2012-05-25 13:22   ` [RFC PATCH v2 1/3] Adds support for user-submitted ioctl commands Ondrej Kozina
2012-05-25 13:22   ` Ondrej Kozina [this message]
2012-05-25 13:22   ` [RFC PATCH v2 3/3] Adds support for security checks in the crypt target Ondrej Kozina

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=1337952148-20888-3-git-send-email-okozina@redhat.com \
    --to=okozina@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=kas@fi.muni.cz \
    --cc=mbroz@redhat.com \
    --cc=mgrac@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).