All of lore.kernel.org
 help / color / mirror / Atom feed
From: mwilck@suse.com
To: Christophe Varoqui <christophe.varoqui@opensvc.com>,
	Benjamin Marzinski <bmarzins@redhat.com>
Cc: dm-devel@redhat.com, Martin Wilck <mwilck@suse.com>,
	David Bond <dbond@suse.com>
Subject: [PATCH 3/4] libmpathpersist: mpath_format_readfullstatus(): use real buffer size
Date: Sat,  7 Mar 2020 00:06:04 +0100	[thread overview]
Message-ID: <20200306230605.3473-4-mwilck@suse.com> (raw)
In-Reply-To: <20200306230605.3473-1-mwilck@suse.com>

From: Martin Wilck <mwilck@suse.com>

This changes no semantics, but it will allow changing the size of
prin_readfd.private_buffer in a follow-up patch.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmpathpersist/mpath_pr_ioctl.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libmpathpersist/mpath_pr_ioctl.c b/libmpathpersist/mpath_pr_ioctl.c
index 8bf16c0d..8d8ca76f 100644
--- a/libmpathpersist/mpath_pr_ioctl.c
+++ b/libmpathpersist/mpath_pr_ioctl.c
@@ -233,6 +233,8 @@ static void mpath_format_readfullstatus(struct prin_resp *pr_buff)
 	uint32_t additional_length, k, tid_len_len = 0;
 	char tempbuff[MPATH_MAX_PARAM_LEN];
 	struct prin_fulldescr fdesc;
+	static const int pbuf_size =
+		sizeof(pr_buff->prin_descriptor.prin_readfd.private_buffer);
 
 	convert_be32_to_cpu(&pr_buff->prin_descriptor.prin_readfd.prgeneration);
 	convert_be32_to_cpu(&pr_buff->prin_descriptor.prin_readfd.number_of_descriptor);
@@ -244,16 +246,18 @@ static void mpath_format_readfullstatus(struct prin_resp *pr_buff)
 	}
 
 	additional_length = pr_buff->prin_descriptor.prin_readfd.number_of_descriptor;
-	if (additional_length > MPATH_MAX_PARAM_LEN) {
+	if (additional_length > pbuf_size) {
 		condlog(3, "PRIN length %u exceeds max length %d", additional_length,
-			MPATH_MAX_PARAM_LEN);
+			pbuf_size);
 		return;
 	}
 
 	memset(&fdesc, 0, sizeof(struct prin_fulldescr));
 
-	memcpy( tempbuff, pr_buff->prin_descriptor.prin_readfd.private_buffer,MPATH_MAX_PARAM_LEN );
-	memset(&pr_buff->prin_descriptor.prin_readfd.private_buffer, 0, MPATH_MAX_PARAM_LEN);
+	memcpy( tempbuff, pr_buff->prin_descriptor.prin_readfd.private_buffer,
+		pbuf_size);
+	memset(&pr_buff->prin_descriptor.prin_readfd.private_buffer, 0,
+	       pbuf_size);
 
 	p =(unsigned char *)tempbuff;
 	ppbuff = (char *)pr_buff->prin_descriptor.prin_readfd.private_buffer;
-- 
2.25.1

  parent reply	other threads:[~2020-03-06 23:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-06 23:06 [PATCH 0/4] libmpathpersist allocation size fixes mwilck
2020-03-06 23:06 ` [PATCH 1/4] libmpathpersist: limit PRIN allocation length to 8192 bytes mwilck
2020-03-14 23:14   ` Benjamin Marzinski
2020-03-06 23:06 ` [PATCH 2/4] libmpathpersist: format_transportids(): avoid PROUT overflow mwilck
2020-03-14 23:15   ` Benjamin Marzinski
2020-03-15  0:14     ` Martin Wilck
2020-03-06 23:06 ` mwilck [this message]
2020-03-14 23:16   ` [PATCH 3/4] libmpathpersist: mpath_format_readfullstatus(): use real buffer size Benjamin Marzinski
2020-03-06 23:06 ` [PATCH 4/4] libmpathpersist: ABI change: limit data-in/out size to 8192 bytes mwilck
2020-03-15  0:19   ` Benjamin Marzinski
2020-03-15  0:27     ` Martin Wilck
2020-03-15 20:45       ` Martin Wilck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200306230605.3473-4-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=bmarzins@redhat.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dbond@suse.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.