Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp281663ybg; Thu, 17 Oct 2019 23:01:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVxGdsa59+LfeLRYdyy5R1pZbwj9Du0UsHEr1H75e6HEQ7aASy9Li6tXiieNB+GOslhUjw X-Received: by 2002:a05:6402:8cf:: with SMTP id d15mr7590582edz.225.1571378491102; Thu, 17 Oct 2019 23:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571378491; cv=none; d=google.com; s=arc-20160816; b=Z3wKcP20804AxKTyYIlsQFHRv6ES3ZkLelWVL3nXxxow2+0pR6GNvLTABgMbCsDE5c CSG53lUnMJWsnRsAeq50/KWAnyr/pI4L5kQg1jl7mEFOMWD8rrOFvWd6Y7ePT1KSU6qc IqkBkuRhyVnYCcU38MGrJbJaNJy+b3rSxfbtrKN8zK8ytzoMRtEJhIF3hEizk53cwZaF 4zpdDYCnK1CCvFkn+q2vEmop09Pax+iGIQUowjmxwpd8Rm5oPf5JKYt7afuI/Hscg9AK wrrPQBqG1kv2lsorHUVBUYzM+gMd7GNFIN9RZU8LubEVAoIywYuPpS/pXjLvAE9eUEeP Xs9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=kHyaC2v0F9zwzhHSvgQHVu4Gn/OTyEG4YGCFiV+9zhs=; b=RN3oDo/gUiWkttquART0ezT+CuRzLQ6mcri0CJ0BDx7pNRSNGM8k1irgqYMO0f60lf pXQvl8F118kzng5XyrSfJ+WGm4VmK9Ox27mRBsYAvoqCkYc+5Dmi9Tg8U+mll0t+jImd TufxuXS9F3eG0y0LEFT/qxEz+zXIx5RT9qZ3T6zpTsoH1+kOyJlTIORxlBXIRnxs8lfc zwxnRx1e5fvIm5aJiPCtyEutPNiqYRmRG9JrJN2C8noYWlN6vOElYY0ifDlen9xt1Xn8 twXuBmhxkeq62FofBx5knsVlf+JCGeLzOUoetVVwZCCkOuSfXSydgowgL2e0HRNew12+ 22ow== 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 m1si3380844edb.433.2019.10.17.23.00.44; Thu, 17 Oct 2019 23:01:31 -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 S2393765AbfJQDGK (ORCPT + 99 others); Wed, 16 Oct 2019 23:06:10 -0400 Received: from mga09.intel.com ([134.134.136.24]:37056 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392976AbfJQDGK (ORCPT ); Wed, 16 Oct 2019 23:06:10 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Oct 2019 20:06:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.67,306,1566889200"; d="scan'208";a="200256249" Received: from ingas-nuc1.sea.intel.com ([10.255.229.89]) by orsmga006.jf.intel.com with ESMTP; 16 Oct 2019 20:06:08 -0700 From: Inga Stotland To: linux-bluetooth@vger.kernel.org Cc: brian.gix@intel.com, Inga Stotland Subject: [PATCH BlueZ] mesh: Fix unpacking NetKey/AppKey 3-octet index combo Date: Wed, 16 Oct 2019 20:06:07 -0700 Message-Id: <20191017030607.11112-1-inga.stotland@intel.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org This fixes how we unpack 3-octet combination of NetKey and AppKey indices received in the payload of AppKeyAdd/Update/Delete messages. For example, if the config client sends a message to add AppKey with index 0x456 bound to NetKey with index 0x123, the received packed 3-octet will be: 0x56 0x34 0x12 The fix takes into account the correct byte ordering when unpacking indices. --- mesh/cfgmod-server.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/mesh/cfgmod-server.c b/mesh/cfgmod-server.c index 55cc8e9eb..79538037c 100644 --- a/mesh/cfgmod-server.c +++ b/mesh/cfgmod-server.c @@ -1022,8 +1022,8 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst, uint16_t unicast, if (size != 19) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; + n_idx = l_get_le16(pkt + 1) >> 4; + a_idx = l_get_le16(pkt) & 0xfff; if (opcode == OP_APPKEY_ADD) b_res = appkey_key_add(net, n_idx, a_idx, pkt + 3); @@ -1048,9 +1048,10 @@ static bool cfg_srv_pkt(uint16_t src, uint32_t dst, uint16_t unicast, if (size != 3) return true; - n_idx = l_get_le16(pkt) & 0xfff; - a_idx = l_get_le16(pkt + 1) >> 4; + n_idx = l_get_le16(pkt + 1) >> 4; + a_idx = l_get_le16(pkt) & 0xfff; b_res = appkey_key_delete(net, n_idx, a_idx); + l_debug("Delete AppKey %s Net_Idx %3.3x to App_Idx %3.3x", (b_res == MESH_STATUS_SUCCESS) ? "success" : "fail", n_idx, a_idx); -- 2.21.0