From: David Miller <davem@davemloft.net>
To: chris.packham@alliedtelesis.co.nz
Cc: jon.maloy@ericsson.com, ying.xue@windriver.com,
netdev@vger.kernel.org, tipc-discussion@lists.sourceforge.net,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] tipc: Avoid copying bytes beyond the supplied data
Date: Sat, 04 May 2019 00:44:49 -0400 (EDT) [thread overview]
Message-ID: <20190504.004449.945185836330139212.davem@davemloft.net> (raw)
In-Reply-To: <20190502031004.7125-1-chris.packham@alliedtelesis.co.nz>
From: Chris Packham <chris.packham@alliedtelesis.co.nz>
Date: Thu, 2 May 2019 15:10:04 +1200
> TLV_SET is called with a data pointer and a len parameter that tells us
> how many bytes are pointed to by data. When invoking memcpy() we need
> to careful to only copy len bytes.
>
> Previously we would copy TLV_LENGTH(len) bytes which would copy an extra
> 4 bytes past the end of the data pointer which newer GCC versions
> complain about.
>
> In file included from test.c:17:
> In function 'TLV_SET',
> inlined from 'test' at test.c:186:5:
> /usr/include/linux/tipc_config.h:317:3:
> warning: 'memcpy' forming offset [33, 36] is out of the bounds [0, 32]
> of object 'bearer_name' with type 'char[32]' [-Warray-bounds]
> memcpy(TLV_DATA(tlv_ptr), data, tlv_len);
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> test.c: In function 'test':
> test.c::161:10: note:
> 'bearer_name' declared here
> char bearer_name[TIPC_MAX_BEARER_NAME];
> ^~~~~~~~~~~
>
> Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
But now the pad bytes at the end are uninitialized.
The whole idea is that the encapsulating TLV object has to be rounded
up in size based upon the given 'len' for the data.
next prev parent reply other threads:[~2019-05-04 4:45 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-02 3:10 Chris Packham
2019-05-04 4:44 ` David Miller [this message]
2019-05-05 20:20 ` Chris Packham
2019-05-05 20:56 ` Arvind Sankar
2019-05-05 21:17 ` Chris Packham
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=20190504.004449.945185836330139212.davem@davemloft.net \
--to=davem@davemloft.net \
--cc=chris.packham@alliedtelesis.co.nz \
--cc=jon.maloy@ericsson.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=tipc-discussion@lists.sourceforge.net \
--cc=ying.xue@windriver.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®