From: Brian Gix <brian.gix@intel.com>
To: linux-bluetooth@vger.kernel.org
Cc: inga.stotland@intel.com, brian.gix@intel.com,
jakub.witowski@silvair.com, michal.lowas-rzechonek@silvair.com
Subject: [PATCH BlueZ] mesh: Fix long MIC usage in segmented messages
Date: Thu, 23 May 2019 10:53:21 -0700 [thread overview]
Message-ID: <20190523175321.13094-1-brian.gix@intel.com> (raw)
From: Jakub Witowski <jakub.witowski@silvair.com>
Contrary to the comment, implementation used a 8-byte MIC even if this
generated an additional segment.
---
mesh/model.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/mesh/model.c b/mesh/model.c
index 034d54496..90bb62db8 100644
--- a/mesh/model.c
+++ b/mesh/model.c
@@ -40,6 +40,9 @@
#include "mesh/util.h"
#include "mesh/model.h"
+/* Divide and round to ceiling (up) to calculate segment count */
+#define CEILDIV(val, div) (((val) + (div) - 1) / (div))
+
struct mesh_model {
const struct mesh_model_ops *cbs;
void *user_data;
@@ -451,7 +454,7 @@ static bool msg_send(struct mesh_node *node, bool credential, uint16_t src,
/* Use large MIC if it doesn't affect segmentation */
if (msg_len > 11 && msg_len <= 376) {
- if ((out_len / 12) == ((out_len + 4) / 12)) {
+ if (CEILDIV(out_len, 12) == CEILDIV(out_len + 4, 12)) {
szmic = true;
out_len = msg_len + sizeof(uint64_t);
}
--
2.14.5
next reply other threads:[~2019-05-23 17:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-05-23 17:53 Brian Gix [this message]
2019-05-23 17:58 ` [PATCH BlueZ] mesh: Fix long MIC usage in segmented messages Gix, Brian
2019-05-24 15:06 ` Gix, Brian
2019-05-27 6:54 ` michal.lowas-rzechonek
2019-05-27 18:14 ` Gix, Brian
2019-05-28 7:28 ` Michał Lowas-Rzechonek
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=20190523175321.13094-1-brian.gix@intel.com \
--to=brian.gix@intel.com \
--cc=inga.stotland@intel.com \
--cc=jakub.witowski@silvair.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=michal.lowas-rzechonek@silvair.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;
as well as URLs for NNTP newsgroup(s).