Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp866768rwb; Fri, 23 Sep 2022 05:20:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4e0rTsJsNsvh88GIAGcjIXfBY/jVBdt1nxNImPffOM8N//W1iLDciwF9AyCmX9K1/xfpXK X-Received: by 2002:a17:906:ee8e:b0:730:3646:d178 with SMTP id wt14-20020a170906ee8e00b007303646d178mr7003154ejb.426.1663935640274; Fri, 23 Sep 2022 05:20:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663935640; cv=none; d=google.com; s=arc-20160816; b=yQs5AIBtc7bIhAAnDEtuRzJhm5PkfzDIrJkQlepnhrjzDZ4SRFo9nL8Sbz6VRQbU2n HNCMFSstz2OAoc7suNyVLLRUVYRwoBQePHdNVw9LfOKpkPqOxO6Ro0OEznukpixieqxw B5SgnDdMUZTku9Il3ogLyOQjsxsnkrNYyb35nD91DZQxEuIyMzMVMne86U0fk/g01wDe 1Ef8Gz9QSRa6U/jWYXKMBVy+uVC7enG1RrMUKTGBtMbyIPn3TKsAf1vbQXaCj4/AJVs2 8Vy3atpQ8/JZwV4PLgBSPu1FR9n05Ef94TSof54HCTQgjs7PFerkTbsZ9mvxlnqJNIsr nI8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=wGXM19aSumVkd8n4Kh7GpPWa0SydqHFadLNhGr5DEkk=; b=U17Upg+jzO0Figx+E+Asl2DTHqOtoNHKenEwyTS/NKHKmBnspp3kgnz/smdbSK2/FV 9eJDLoIH7jxDjdzNnfmVcjNg7YyHcTHuV4ZuCJDrANtPuFCsXzXTpQSuG56SkvqVswdK uqtGm6/3AXfw+PQi+rEVc0dmlxd5DRCO5Ztz4KoL1sQLWLHLd4SHzYsZ83i7RyUOfn59 iQyO2sSwIvAjGyHCgi6kEXRVrwJid8guc1h+KuislTRx0H9AYVy6xhw2iVrzjrPctePc atuoiSzJZCKRIDVMoIf+gsR1BhN29+grejf2Pg1IXulLC+AR1NjO2d8sIac3RrOnqgeV YLKg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr13-20020a170907720d00b007815b8c72c1si8943383ejc.423.2022.09.23.05.20.11; Fri, 23 Sep 2022 05:20:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231127AbiIWMIl (ORCPT + 99 others); Fri, 23 Sep 2022 08:08:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52534 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232040AbiIWMGR (ORCPT ); Fri, 23 Sep 2022 08:06:17 -0400 Received: from voyager.loytec.com (voyager.loytec.com [88.198.4.4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7BCAB135047 for ; Fri, 23 Sep 2022 05:03:57 -0700 (PDT) Received: from 212-17-98-152.static.upcbusiness.at ([212.17.98.152] helo=lexx.office.loytec.com) by voyager.loytec.com with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1obguy-0000M6-WC for linux-bluetooth@vger.kernel.org; Fri, 23 Sep 2022 13:32:29 +0200 Received: from loytec-dev-vm.delta.corp ([10.101.25.21]) by lexx.office.loytec.com (8.15.2/8.15.2/Some OS 1.2.3-4.5) with ESMTP id 28NBWF7i3687927; Fri, 23 Sep 2022 13:32:26 +0200 From: Isak Westin To: linux-bluetooth@vger.kernel.org Cc: Isak Westin Subject: [PATCH BlueZ 2/2] mesh: Reply error if appkey added for wrong netkey Date: Fri, 23 Sep 2022 13:31:49 +0200 Message-Id: <20220923113149.14209-3-isak.westin@loytec.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20220923113149.14209-1-isak.westin@loytec.com> References: <20220923113149.14209-1-isak.westin@loytec.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 212.17.98.152 X-SA-Exim-Mail-From: isak.westin@loytec.com X-SA-Exim-Scanned: No (on voyager.loytec.com); SAEximRunCond expanded to false X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org If a known appkey is added for a different netkey, the status reply should be Invalid NetKey. --- mesh/appkey.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mesh/appkey.c b/mesh/appkey.c index 52fed8c31..f31d81942 100644 --- a/mesh/appkey.c +++ b/mesh/appkey.c @@ -296,7 +296,9 @@ int appkey_key_add(struct mesh_net *net, uint16_t net_idx, uint16_t app_idx, key = l_queue_find(app_keys, match_key_index, L_UINT_TO_PTR(app_idx)); if (key) { - if (memcmp(new_key, key->key, 16) == 0) + if (key->net_idx != net_idx) + return MESH_STATUS_INVALID_NETKEY; + else if (memcmp(new_key, key->key, 16) == 0) return MESH_STATUS_SUCCESS; else return MESH_STATUS_IDX_ALREADY_STORED; -- 2.20.1