From patchwork Thu Feb 3 00:08:16 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milan Broz X-Patchwork-Id: 528121 X-Patchwork-Delegate: agk@redhat.com Received: from mx3-phx2.redhat.com (mx3-phx2.redhat.com [209.132.183.24]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p130CBVO010570 for ; Thu, 3 Feb 2011 00:12:31 GMT Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx3-phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p130AJh9014464; Wed, 2 Feb 2011 19:10:19 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p1308R9A019339 for ; Wed, 2 Feb 2011 19:08:27 -0500 Received: from tawny.mazyland.cz (vpn1-4-126.ams2.redhat.com [10.36.4.126]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1308I5f031888; Wed, 2 Feb 2011 19:08:21 -0500 From: Milan Broz To: dm-devel@redhat.com Date: Thu, 3 Feb 2011 01:08:16 +0100 Message-Id: <1296691696-23722-3-git-send-email-mbroz@redhat.com> In-Reply-To: <1296691696-23722-1-git-send-email-mbroz@redhat.com> References: <1296691696-23722-1-git-send-email-mbroz@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-loop: dm-devel@redhat.com Cc: Milan Broz Subject: [dm-devel] [PATCH 3/3] dm ioctl: add data secure (bufer wipe) flag X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 03 Feb 2011 00:12:56 +0000 (UTC) diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 189c7ab..9284c38 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c @@ -1518,9 +1518,16 @@ static int copy_params(struct dm_ioctl __user *user, struct dm_ioctl **param) if (copy_from_user(dmi, user, tmp.data_size)) goto fail; + /* Wipe the user buffer so we do not return it to userspace */ + if ((tmp.flags & DM_SECURE_DATA_FLAG) && + clear_user(user, tmp.data_size)) + goto fail; + *param = dmi; return 0; fail: + if (tmp.flags & DM_SECURE_DATA_FLAG) + memset(dmi, 0, tmp.data_size); vfree(dmi); return -EFAULT; } @@ -1621,6 +1628,9 @@ static int ctl_ioctl(uint command, struct dm_ioctl __user *user) if (!r && copy_to_user(user, param, param->data_size)) r = -EFAULT; out: + if (param->flags & DM_SECURE_DATA_FLAG) + memset(param, 0, param_size); + vfree(param); return r; } diff --git a/include/linux/dm-ioctl.h b/include/linux/dm-ioctl.h index 78bbf47..c314198 100644 --- a/include/linux/dm-ioctl.h +++ b/include/linux/dm-ioctl.h @@ -267,9 +267,9 @@ enum { #define DM_DEV_SET_GEOMETRY _IOWR(DM_IOCTL, DM_DEV_SET_GEOMETRY_CMD, struct dm_ioctl) #define DM_VERSION_MAJOR 4 -#define DM_VERSION_MINOR 19 -#define DM_VERSION_PATCHLEVEL 1 -#define DM_VERSION_EXTRA "-ioctl (2011-01-07)" +#define DM_VERSION_MINOR 20 +#define DM_VERSION_PATCHLEVEL 0 +#define DM_VERSION_EXTRA "-ioctl (2011-02-02)" /* Status bits */ #define DM_READONLY_FLAG (1 << 0) /* In/Out */ @@ -328,4 +328,10 @@ enum { */ #define DM_UUID_FLAG (1 << 14) /* In */ +/* + * If set, all buffers are wiped after use. Used when sending + * or requesting sensitive data like crypt key. + */ +#define DM_SECURE_DATA_FLAG (1 << 15) /* In */ + #endif /* _LINUX_DM_IOCTL_H */