Recent changes (master)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The following changes since commit fbf954c96bb4089b3097adde723216a4668f854b:

  engines/io_uring: eliminate FDP memory corruption risk (2024-06-07 09:45:02 -0400)

are available in the Git repository at:

  git://git.kernel.dk/fio.git master

for you to fetch changes up to a15118757dad19c7f17700903d169676f244e318:

  helper_thread: check for null scalloc return value (2024-06-11 16:19:38 -0400)

----------------------------------------------------------------
Vincent Fu (5):
      Reapply "smalloc: smalloc() already clears memory, scalloc() need not do it again"
      t/stest: confirm that scalloc clears the buffer
      iolog: check scalloc return value
      t/stest: remove useless error assignment
      helper_thread: check for null scalloc return value

 helper_thread.c |  2 ++
 iolog.c         |  1 +
 smalloc.c       |  8 +-------
 t/stest.c       | 37 +++++++++++++++++++++++++++++++------
 4 files changed, 35 insertions(+), 13 deletions(-)

---

Diff of recent changes:

diff --git a/helper_thread.c b/helper_thread.c
index 332ccb53..fed21d1d 100644
--- a/helper_thread.c
+++ b/helper_thread.c
@@ -418,6 +418,8 @@ int helper_thread_create(struct fio_sem *startup_sem, struct sk_out *sk_out)
 	int ret;
 
 	hd = scalloc(1, sizeof(*hd));
+	if (!hd)
+		return 1;
 
 	setup_disk_util();
 	steadystate_setup();
diff --git a/iolog.c b/iolog.c
index b57f845e..f727c97f 100644
--- a/iolog.c
+++ b/iolog.c
@@ -840,6 +840,7 @@ void setup_log(struct io_log **log, struct log_params *p,
 	struct flist_head *list;
 
 	l = scalloc(1, sizeof(*l));
+	assert(l);
 	INIT_FLIST_HEAD(&l->io_logs);
 	l->log_type = p->log_type;
 	l->log_offset = p->log_offset;
diff --git a/smalloc.c b/smalloc.c
index 134f3d77..23243054 100644
--- a/smalloc.c
+++ b/smalloc.c
@@ -566,13 +566,7 @@ void *smalloc(size_t size)
 
 void *scalloc(size_t nmemb, size_t size)
 {
-	void *ret;
-
-	ret = smalloc(nmemb * size);
-	if (ret)
-		memset(ret, 0, nmemb * size);
-
-	return ret;
+	return smalloc(nmemb * size);
 }
 
 char *smalloc_strdup(const char *str)
diff --git a/t/stest.c b/t/stest.c
index c6bf2d1e..16ce6923 100644
--- a/t/stest.c
+++ b/t/stest.c
@@ -25,10 +25,11 @@ static FLIST_HEAD(list);
 
 static int do_rand_allocs(void)
 {
-	unsigned int size, nr, rounds = 0, ret = 0;
+	unsigned int i, size, nr, rounds = 0, ret = 0;
 	unsigned long total;
 	struct elem *e;
 	bool error;
+	char *c;
 
 	while (rounds++ < LOOPS) {
 #ifdef STEST_SEED
@@ -38,12 +39,26 @@ static int do_rand_allocs(void)
 		nr = total = 0;
 		while (total < MAXSMALLOC) {
 			size = 8 * sizeof(struct elem) + (int) (999.0 * (rand() / (RAND_MAX + 1.0)));
-			e = smalloc(size);
+			e = scalloc(1, size);
 			if (!e) {
 				printf("fail at %lu, size %u\n", total, size);
 				ret++;
 				break;
 			}
+
+			c = (char *)e;
+			for (i = 0; i < size; i++) {
+				if (*(c+i) != 0) {
+					printf("buffer not cleared at %lu, size %u\n", total, size);
+					ret++;
+					break;
+				}
+			}
+
+			/* stop the while loop if buffer was not cleared */
+			if (i < size)
+				break;
+
 			e->magic1 = MAGIC1;
 			e->magic2 = MAGIC2;
 			e->size = size;
@@ -63,15 +78,25 @@ static int do_rand_allocs(void)
 			sfree(e);
 
 			if (!error) {
-				e = smalloc(LARGESMALLOC);
+				e = scalloc(1, LARGESMALLOC);
 				if (!e) {
-					error = true;
 					ret++;
 					printf("failure allocating %u bytes at %lu allocated during sfree phase\n",
 						LARGESMALLOC, total);
+					break;
 				}
-				else
-					sfree(e);
+
+				c = (char *)e;
+				for (i = 0; i < LARGESMALLOC; i++) {
+					if (*(c+i) != 0) {
+						error = true;
+						ret++;
+						printf("large buffer not cleared at %lu, size %u\n", total, size);
+						break;
+					}
+				}
+
+				sfree(e);
 			}
 		}
 	}




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux