Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp2069536ybm; Thu, 23 May 2019 10:54:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwQWXv9FtCUoTpwrvIYFuTiBz6Q9rJV/YuoDWNKBKYT3hzgS/4AGCN40AOdy23WGKo0IU/0 X-Received: by 2002:a63:6a41:: with SMTP id f62mr98148123pgc.392.1558634054391; Thu, 23 May 2019 10:54:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558634054; cv=none; d=google.com; s=arc-20160816; b=CklTm9dF63H+MxS36CeX8mXwm2CTkjgVvlt2Fv2Ux99wXJTq1P1wPWR1N131Mo95aS EinO9NT8jvncigtxvL09GpoJ7KGs2t3fz69wOKAenVy07MCD3SqorKgZ/kRSgeDsDsgb N7M6HfPU1YT6QC0UBV5taYvVR8eSDpn6N4M2Id90oiapCffU6tk4aiVA0k15ktvtQRXc 9PIuUcVuwL7BN6Ifejcn4kdHx7TJF+DKVm+0KCuzmkFkOeK2aHnzTD+exs3tAxdH+ndD 7A8dxyloB7rzcfzYa2MrasO6f5SGkblSN4Uq8PvJ2QMqr2ZjCpbzbXlwI8UirA9YSP/1 mjkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=uPTPiHhjzx6WVJ249EhCncEIwxchgNIv0VHBQeFbd1o=; b=draGKhtqjvanSc3LOAKInrYL/BZIc81IjUsbWftjFLz9QHHdZ8IxRPAGWBuGqHCMWK iZstkU8qn2jmugXclTq/AatYVcrIIVvBvsxM5GJnCM4rEBPk4bPgxLsGoWqbTqSBciA+ pkeK3Zli953XohEYKxAZF6VMXnE88Fre3AEZpW683F1viuhkKXOVltzE1a4DkBMbyP2a 95CUMSpKMl7+KawDwSdDL0JyCFbm3TWf64+8zk23GFVkN0GDqKd8p318qleOGnkduDeJ 8wqC6t6SRl9kZKen8FBDFf8IifKEeMclgdRbH3+kbfUaLd2ZPLNW6G2R7bykBuJyfyZb gNNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o4si243251pgg.49.2019.05.23.10.53.43; Thu, 23 May 2019 10:54:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731116AbfEWRx3 (ORCPT + 99 others); Thu, 23 May 2019 13:53:29 -0400 Received: from mga02.intel.com ([134.134.136.20]:17242 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730899AbfEWRx3 (ORCPT ); Thu, 23 May 2019 13:53:29 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 May 2019 10:53:29 -0700 X-ExtLoop1: 1 Received: from bgix-dell-lap.sea.intel.com ([10.255.78.4]) by orsmga004.jf.intel.com with ESMTP; 23 May 2019 10:53:28 -0700 From: Brian Gix 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 Message-Id: <20190523175321.13094-1-brian.gix@intel.com> X-Mailer: git-send-email 2.14.5 Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org From: Jakub Witowski 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