Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1683024 > unrolled thread

[PATCH 1/3] lib/test_kmod: tidy up bounds checking

Started byDan Carpenter <dan.carpenter@oracle.com>
First post2017-07-07 10:40 +0200
Last post2017-07-07 10:50 +0200
Articles 3 — 1 participant

Back to article view | Back to linux.kernel


Contents

  [PATCH 1/3] lib/test_kmod: tidy up bounds checking Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-07 10:40 +0200
    [PATCH 3/3] lib/test_kmod: fix fs module tests Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-07 10:50 +0200
    [PATCH 2/3] lib/test_kmod: take the lock in register_test_dev_kmod() Dan Carpenter <dan.carpenter@oracle.com> - 2017-07-07 10:50 +0200

#1683024 — [PATCH 1/3] lib/test_kmod: tidy up bounds checking

FromDan Carpenter <dan.carpenter@oracle.com>
Date2017-07-07 10:40 +0200
Subject[PATCH 1/3] lib/test_kmod: tidy up bounds checking
Message-ID<u0wXT-1kR-9@gated-at.bofh.it>
There is technically a bug where we don't test for negatives in
test_dev_config_update_uint_sync().  "new" is long and UINT_MAX is
unsigned int so on 64 bit systems negatives are allowed.

In the next test I removed the UINT_MAX comparison because "max" is
already an unsigned int so we already know that "new" can't be larger
than UINT_MAX.

On the third test, I just flipped the tests around so we consistently
test the lower bound before the upper bound.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index 6c1d678bcf8b..8797400b8bda 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -887,7 +887,7 @@ static int test_dev_config_update_uint_sync(struct kmod_test_device *test_dev,
 	if (ret)
 		return ret;
 
-	if (new > UINT_MAX)
+	if (new < 0 || new > UINT_MAX)
 		return -EINVAL;
 
 	mutex_lock(&test_dev->config_mutex);
@@ -924,7 +924,7 @@ static int test_dev_config_update_uint_range(struct kmod_test_device *test_dev,
 	if (ret)
 		return ret;
 
-	if (new < min || new >  max || new > UINT_MAX)
+	if (new < min || new > max)
 		return -EINVAL;
 
 	mutex_lock(&test_dev->config_mutex);
@@ -946,7 +946,7 @@ static int test_dev_config_update_int(struct kmod_test_device *test_dev,
 	if (ret)
 		return ret;
 
-	if (new > INT_MAX || new < INT_MIN)
+	if (new < INT_MIN || new > INT_MAX)
 		return -EINVAL;
 
 	mutex_lock(&test_dev->config_mutex);

[toc] | [next] | [standalone]


#1683027 — [PATCH 3/3] lib/test_kmod: fix fs module tests

FromDan Carpenter <dan.carpenter@oracle.com>
Date2017-07-07 10:50 +0200
Subject[PATCH 3/3] lib/test_kmod: fix fs module tests
Message-ID<u0x7z-1qN-1@gated-at.bofh.it>
In reply to#1683024
The break was in the wrong place so file system tests don't work as
intended.

Fixes: 39258f448d71 ("kmod: add test driver to stress test the module loader")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index 093b44771197..5a402e610237 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -746,11 +746,11 @@ static int trigger_config_run_type(struct kmod_test_device *test_dev,
 						      strlen(test_str));
 		break;
 	case TEST_KMOD_FS_TYPE:
-		break;
 		kfree_const(config->test_fs);
 		config->test_driver = NULL;
 		copied = config_copy_test_fs(config, test_str,
 					     strlen(test_str));
+		break;
 	default:
 		mutex_unlock(&test_dev->config_mutex);
 		return -EINVAL;

[toc] | [prev] | [next] | [standalone]


#1683028 — [PATCH 2/3] lib/test_kmod: take the lock in register_test_dev_kmod()

FromDan Carpenter <dan.carpenter@oracle.com>
Date2017-07-07 10:50 +0200
Subject[PATCH 2/3] lib/test_kmod: take the lock in register_test_dev_kmod()
Message-ID<u0x7z-1qN-3@gated-at.bofh.it>
In reply to#1683024
We accidentally just drop the lock twice instead of taking it and then
releasing it.

Fixes: 39258f448d71 ("kmod: add test driver to stress test the module loader")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index 8797400b8bda..093b44771197 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -1146,7 +1146,7 @@ static struct kmod_test_device *register_test_dev_kmod(void)
 	struct kmod_test_device *test_dev = NULL;
 	int ret;
 
-	mutex_unlock(&reg_dev_mutex);
+	mutex_lock(&reg_dev_mutex);
 
 	/* int should suffice for number of devices, test for wrap */
 	if (unlikely(num_test_devs + 1) < 0) {

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web