[DRBD-cvs] r1756 - in trunk: drbd drbd/linux user

svn at svn.drbd.org svn at svn.drbd.org
Sun Feb 6 09:52:25 CET 2005


Author: phil
Date: 2005-02-06 09:52:22 +0100 (Sun, 06 Feb 2005)
New Revision: 1756

Modified:
   trunk/drbd/drbd_fs.c
   trunk/drbd/linux/drbd.h
   trunk/user/drbdsetup.c
Log:
We need to make sure that the crypto transformation named by the user
is really a DIGEST transformation...


Modified: trunk/drbd/drbd_fs.c
===================================================================
--- trunk/drbd/drbd_fs.c	2005-02-02 21:19:44 UTC (rev 1755)
+++ trunk/drbd/drbd_fs.c	2005-02-06 08:52:22 UTC (rev 1756)
@@ -560,15 +560,14 @@
 			retcode=CRAMAlgNotAvail;
 			goto fail_ioctl;
 		}
-	}
 
-	if ( mdev->cram_hmac_tfm ) {
-		crypto_free_tfm(mdev->cram_hmac_tfm);
+		if (crypto_tfm_alg_type(tfm) != CRYPTO_ALG_TYPE_DIGEST) {
+			retcode=CRAMAlgNotDigest;
+			goto fail_ioctl;
+		}
 	}
 
-	mdev->cram_hmac_tfm = tfm;
 
-
 	if (mdev->tl_hash_s != new_conf.max_epoch_size/8 ) {
 		new_tl_hash = kmalloc(mdev->tl_hash_s * sizeof(void*),
 				      GFP_KERNEL);
@@ -642,6 +641,12 @@
 		memset(mdev->ee_hash, 0, mdev->ee_hash_s * sizeof(void*));
 	}
 
+	if ( mdev->cram_hmac_tfm ) {
+		crypto_free_tfm(mdev->cram_hmac_tfm);
+	}
+
+	mdev->cram_hmac_tfm = tfm;
+
 	drbd_thread_start(&mdev->worker);
 	if( drbd_request_state(mdev,NS(conn,Unconnected)) > 0) {
 		drbd_thread_start(&mdev->receiver);
@@ -650,6 +655,7 @@
 	return 0;
 
   fail_ioctl:
+	if (tfm) crypto_free_tfm(tfm);
 	if (new_tl_hash) kfree(new_tl_hash);
 	if (new_ee_hash) kfree(new_ee_hash);
 	if (put_user(retcode, &arg->ret_code)) return -EFAULT;

Modified: trunk/drbd/linux/drbd.h
===================================================================
--- trunk/drbd/linux/drbd.h	2005-02-02 21:19:44 UTC (rev 1755)
+++ trunk/drbd/linux/drbd.h	2005-02-06 08:52:22 UTC (rev 1756)
@@ -136,6 +136,7 @@
 	MDIOError,
 	MDInvalid,
 	CRAMAlgNotAvail,
+	CRAMAlgNotDigest,
 	KMallocFailed,
 };
 

Modified: trunk/user/drbdsetup.c
===================================================================
--- trunk/user/drbdsetup.c	2005-02-02 21:19:44 UTC (rev 1755)
+++ trunk/user/drbdsetup.c	2005-02-06 08:52:22 UTC (rev 1756)
@@ -566,7 +566,9 @@
     [MDInvalid]="No valid meta-data signature found.\n"
                 "Use 'drbdadm create-md res' to initialize meta-data area.\n",
     [CRAMAlgNotAvail]="The 'cram-hmac-alg' you specified is not known in "
-                      "the kernel.\n"
+                      "the kernel.\n",
+    [CRAMAlgNotDigest]="The 'cram-hmac-alg' you specified is not a digest.",
+    [KMallocFailed]="kmalloc() failed. Out of memory?"
   };
 
   if (err_no>ARRY_SIZE(etext) || err_no<0) err_no=0;



More information about the drbd-cvs mailing list