All of lore.kernel.org
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr" failed to apply to 4.14-stable tree
@ 2019-04-15 16:37 gregkh
  2019-04-16  8:44 ` [PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr Mikulas Patocka
  0 siblings, 1 reply; 3+ messages in thread
From: gregkh @ 2019-04-15 16:37 UTC (permalink / raw)
  To: mpatocka, snitzer; +Cc: stable


The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 0d74e6a3b6421d98eeafbed26f29156d469bc0b5 Mon Sep 17 00:00:00 2001
From: Mikulas Patocka <mpatocka@redhat.com>
Date: Wed, 13 Mar 2019 07:56:02 -0400
Subject: [PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr

If the string opt_string is small, the function memcmp can access bytes
that are beyond the terminating nul character. In theory, it could cause
segfault, if opt_string were located just below some unmapped memory.

Change from memcmp to strncmp so that we don't read bytes beyond the end
of the string.

Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c
index d57d997a52c8..33fac437569f 100644
--- a/drivers/md/dm-integrity.c
+++ b/drivers/md/dm-integrity.c
@@ -3185,7 +3185,7 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
 			journal_watermark = val;
 		else if (sscanf(opt_string, "commit_time:%u%c", &val, &dummy) == 1)
 			sync_msec = val;
-		else if (!memcmp(opt_string, "meta_device:", strlen("meta_device:"))) {
+		else if (!strncmp(opt_string, "meta_device:", strlen("meta_device:"))) {
 			if (ic->meta_dev) {
 				dm_put_device(ti, ic->meta_dev);
 				ic->meta_dev = NULL;
@@ -3204,17 +3204,17 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
 				goto bad;
 			}
 			ic->sectors_per_block = val >> SECTOR_SHIFT;
-		} else if (!memcmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
+		} else if (!strncmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
 			r = get_alg_and_key(opt_string, &ic->internal_hash_alg, &ti->error,
 					    "Invalid internal_hash argument");
 			if (r)
 				goto bad;
-		} else if (!memcmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) {
+		} else if (!strncmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) {
 			r = get_alg_and_key(opt_string, &ic->journal_crypt_alg, &ti->error,
 					    "Invalid journal_crypt argument");
 			if (r)
 				goto bad;
-		} else if (!memcmp(opt_string, "journal_mac:", strlen("journal_mac:"))) {
+		} else if (!strncmp(opt_string, "journal_mac:", strlen("journal_mac:"))) {
 			r = get_alg_and_key(opt_string, &ic->journal_mac_alg,  &ti->error,
 					    "Invalid journal_mac argument");
 			if (r)


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr
  2019-04-15 16:37 FAILED: patch "[PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr" failed to apply to 4.14-stable tree gregkh
@ 2019-04-16  8:44 ` Mikulas Patocka
  2019-04-29 12:42   ` Greg KH
  0 siblings, 1 reply; 3+ messages in thread
From: Mikulas Patocka @ 2019-04-16  8:44 UTC (permalink / raw)
  To: gregkh; +Cc: snitzer, stable

Hi.

Here I'm sending the patch backported for the kernel 4.14.

Mikulas


From gregkh@linuxfoundation.org Mon Apr 15 12:38:03 2019
Date: Mon, 15 Apr 2019 18:37:16 +0200
From: gregkh@linuxfoundation.org
To: mpatocka@redhat.com, snitzer@redhat.com
Cc: stable@vger.kernel.org
Subject: FAILED: patch "[PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr" failed to apply to 4.14-stable tree


The patch below does not apply to the 4.14-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

>From 0d74e6a3b6421d98eeafbed26f29156d469bc0b5 Mon Sep 17 00:00:00 2001
From: Mikulas Patocka <mpatocka@redhat.com>
Date: Wed, 13 Mar 2019 07:56:02 -0400
Subject: [PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr

If the string opt_string is small, the function memcmp can access bytes
that are beyond the terminating nul character. In theory, it could cause
segfault, if opt_string were located just below some unmapped memory.

Change from memcmp to strncmp so that we don't read bytes beyond the end
of the string.

Cc: stable@vger.kernel.org # v4.12+
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>

---
 drivers/md/dm-integrity.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Index: linux-stable/drivers/md/dm-integrity.c
===================================================================
--- linux-stable.orig/drivers/md/dm-integrity.c	2019-04-16 10:41:05.000000000 +0200
+++ linux-stable/drivers/md/dm-integrity.c	2019-04-16 10:41:05.000000000 +0200
@@ -2889,17 +2889,17 @@ static int dm_integrity_ctr(struct dm_ta
 				goto bad;
 			}
 			ic->sectors_per_block = val >> SECTOR_SHIFT;
-		} else if (!memcmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
+		} else if (!strncmp(opt_string, "internal_hash:", strlen("internal_hash:"))) {
 			r = get_alg_and_key(opt_string, &ic->internal_hash_alg, &ti->error,
 					    "Invalid internal_hash argument");
 			if (r)
 				goto bad;
-		} else if (!memcmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) {
+		} else if (!strncmp(opt_string, "journal_crypt:", strlen("journal_crypt:"))) {
 			r = get_alg_and_key(opt_string, &ic->journal_crypt_alg, &ti->error,
 					    "Invalid journal_crypt argument");
 			if (r)
 				goto bad;
-		} else if (!memcmp(opt_string, "journal_mac:", strlen("journal_mac:"))) {
+		} else if (!strncmp(opt_string, "journal_mac:", strlen("journal_mac:"))) {
 			r = get_alg_and_key(opt_string, &ic->journal_mac_alg,  &ti->error,
 					    "Invalid journal_mac argument");
 			if (r)


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr
  2019-04-16  8:44 ` [PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr Mikulas Patocka
@ 2019-04-29 12:42   ` Greg KH
  0 siblings, 0 replies; 3+ messages in thread
From: Greg KH @ 2019-04-29 12:42 UTC (permalink / raw)
  To: Mikulas Patocka; +Cc: snitzer, stable

On Tue, Apr 16, 2019 at 04:44:23AM -0400, Mikulas Patocka wrote:
> Hi.
> 
> Here I'm sending the patch backported for the kernel 4.14.

Thanks, now queued up.

greg k-h

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-04-29 12:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-15 16:37 FAILED: patch "[PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr" failed to apply to 4.14-stable tree gregkh
2019-04-16  8:44 ` [PATCH] dm integrity: change memcmp to strncmp in dm_integrity_ctr Mikulas Patocka
2019-04-29 12:42   ` Greg KH

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.