All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: <linux-rdma@vger.kernel.org>
Subject: [PATCH 3/4] iwpmd: Always copy the ss_family in copy_iwpm_sockaddr()
Date: Mon, 16 Nov 2020 16:16:15 -0400	[thread overview]
Message-ID: <3-v1-f03f70229014+144-fix_lto_jgg@nvidia.com> (raw)
In-Reply-To: <0-v1-f03f70229014+144-fix_lto_jgg@nvidia.com>

gcc10 with LTO finds a path where process_iwpm_wire_request() calls
copy_iwpm_sockaddr() and then does print_iwpm_sockaddr() against the
dst. If the case statement in copy_iwpm_sockaddr() bails then
print_iwpm_sockaddr() is still called and this triggers a read from
uninitialized memory.

Always copy the ss_family, this will cause the default case to be taken in
print_iwpm_sockaddr() as well.

Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
---
 iwpmd/iwarp_pm_common.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/iwpmd/iwarp_pm_common.c b/iwpmd/iwarp_pm_common.c
index 8160180aee48e8..67309cbee6a057 100644
--- a/iwpmd/iwarp_pm_common.c
+++ b/iwpmd/iwarp_pm_common.c
@@ -570,6 +570,10 @@ void copy_iwpm_sockaddr(__u16 addr_family, struct sockaddr_storage *src_sockaddr
 		*dst = *src;
 		break;
 	}
+	default:
+	assert(false);
+	if (dst_sockaddr)
+		dst_sockaddr->ss_family = addr_family;
 	}
 }
 
-- 
2.29.2


  parent reply	other threads:[~2020-11-16 20:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-16 20:16 [PATCH 0/4] Enable LTO support for rdma-core Jason Gunthorpe
2020-11-16 20:16 ` [PATCH 1/4] libibumad: Check for error returns in get_port() Jason Gunthorpe
2020-11-16 20:16 ` [PATCH 2/4] verbs: Simplify the logic assigning vid in ibv_resolve_eth_l2_from_gid() Jason Gunthorpe
2020-11-16 20:16 ` Jason Gunthorpe [this message]
2020-11-16 20:16 ` [PATCH 4/4] util: Use GCC 10's attribute symver to define compat symbol versions Jason Gunthorpe

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=3-v1-f03f70229014+144-fix_lto_jgg@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=linux-rdma@vger.kernel.org \
    /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.