Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2132999iob; Fri, 20 May 2022 02:48:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZhzvILHkmSLY7TYI5mEp1ULJBx5EmKL9V14XYArAWzFjRraoONKN5LXH2vbzj+6cXrz+c X-Received: by 2002:a17:907:72ca:b0:6f9:8675:6a2a with SMTP id du10-20020a17090772ca00b006f986756a2amr8244758ejc.98.1653040097785; Fri, 20 May 2022 02:48:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653040097; cv=none; d=google.com; s=arc-20160816; b=lurQQk9NuMRLTfP4WJpO7Z+e6hQos/PJNCWvUVEIPGg2rNvCsjoWVW70SxcWsZF0D2 0vT6sX3nYSXfRecqJWJeJzeorpf8NTXnKa8+mtJFcgm1xN71FDY3ZCDk6tbySf0BKnrT u72rQ/bwvNXii5XGzGGLqgfU9eKl+AdIS/Mhz3cpcu/v99G1zrn5W2fbEb3tAXkLV9ge LZomq8yBdLdF9dwvV3X/qhRFlCTCDmtQH0TH2huasbFg70uYqCVNgQMM5Kc578ENx0kP /PePYyvhlNsZG6/ZmR56R/rtPOFn8kJ60VtmG3QUAWddjgEFJ6IYJIoYCQfmPoZGkweq S1bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=AXA9VgBeApux2Vj2JdcQEO7tKhstXLL4GMIv5mpTOck=; b=tnNxK7sJLrxsp+u2G+BBNmSi5bz1O1naIxO4USI81ck0hcv+BGvb42CQfAWrgRXOrM fpEcmgTH31dxykskIjUExR7/UuE3yWNz4vs4IzzbPhcYRpwq90Qq7Y/2Pstho1mOsM0H xF4UaZIDQVqzaxD0+Mzaib9epWxanDwNUMjZRna8AAhd8j0j15sNpVqMVJoKPriQxXso yzRkuCjTZe32XtRgrjNscj6246TWR9zFp3gWPm1ZmX2FIvVxp3FfGjuH35lRUE+x9n97 CEVFvVr2HfvYa/29TkJ/N7KdRaMZZKJxoEVwKvpProl/52GVPVz818lLFq/JyNBAszjr SO/Q== 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 u19-20020a170906c41300b006fe111bf3c2si8021106ejz.440.2022.05.20.02.47.44; Fri, 20 May 2022 02:48:16 -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 S243652AbiESSJJ convert rfc822-to-8bit (ORCPT + 99 others); Thu, 19 May 2022 14:09:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243654AbiESSJE (ORCPT ); Thu, 19 May 2022 14:09:04 -0400 Received: from mail.holtmann.org (coyote.holtmann.net [212.227.132.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 259B7DE31F for ; Thu, 19 May 2022 11:09:02 -0700 (PDT) Received: from smtpclient.apple (p4ff9fb9d.dip0.t-ipconnect.de [79.249.251.157]) by mail.holtmann.org (Postfix) with ESMTPSA id 27214CECFA; Thu, 19 May 2022 20:09:02 +0200 (CEST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.100.31\)) Subject: Re: [PATCH v2] Bluetooth: MGMT: Fix uses of bitmap_from_u64 From: Marcel Holtmann In-Reply-To: <20220516203539.1708251-1-luiz.dentz@gmail.com> Date: Thu, 19 May 2022 20:09:01 +0200 Cc: linux-bluetooth@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <4A5486C7-C1E8-41A3-9E7F-E627BBA79503@holtmann.org> References: <20220516203539.1708251-1-luiz.dentz@gmail.com> To: Luiz Augusto von Dentz X-Mailer: Apple Mail (2.3696.100.31) X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Luiz, > bitmap_from_u64 expects at least 8 bytes to be declared since it doesn't > take any parameter regarding the number of bits causing the following > warnings: > > In file included from include/linux/cpumask.h:12, > from include/linux/mm_types_task.h:14, > from include/linux/mm_types.h:5, > from include/linux/buildid.h:5, > from include/linux/module.h:14, > from net/bluetooth/mgmt.c:27: > In function 'bitmap_copy', > inlined from 'bitmap_copy_clear_tail' at include/linux/bitmap.h:270:2, > inlined from 'bitmap_from_u64' at include/linux/bitmap.h:622:2, > inlined from 'set_device_flags' at net/bluetooth/mgmt.c:4534:4: > include/linux/bitmap.h:261:9: warning: 'memcpy' forming offset [4, 7] is > out of the bounds [0, 4] of object 'flags' with type > 'long unsigned int[1]' [-Warray-bounds] > 261 | memcpy(dst, src, len); > | ^~~~~~~~~~~~~~~~~~~~~ > In file included from include/linux/kasan-checks.h:5, > from include/asm-generic/rwonce.h:26, > from ./arch/arm/include/generated/asm/rwonce.h:1, > from include/linux/compiler.h:248, > from include/linux/build_bug.h:5, > from include/linux/container_of.h:5, > from include/linux/list.h:5, > from include/linux/module.h:12, > from net/bluetooth/mgmt.c:27: > net/bluetooth/mgmt.c: In function 'set_device_flags': > net/bluetooth/mgmt.c:4532:40: note: 'flags' declared here > 4532 | DECLARE_BITMAP(flags, __HCI_CONN_NUM_FLAGS); > | ^~~~~ > include/linux/types.h:11:23: note: in definition of macro 'DECLARE_BITMAP' > 11 | unsigned long name[BITS_TO_LONGS(bits)] > | ^~~~ > > In order to fix the above this initializes a variable using > DECLARE_BITMAP with the current_flags and then uses bitmap_subset to > check if the flags being set are a subset of hdev->conn_flags that way > all the checks are performed using bitmap APIs and conversion to u32 > only happen when really needed. > > Fixes: a9a347655d22 ("Bluetooth: MGMT: Add conditions for setting HCI_CONN_FLAG_REMOTE_WAKEUP") > Reported-by: Stephen Rothwell > Suggested-by: Yury Norov > Signed-off-by: Luiz Augusto von Dentz > --- > net/bluetooth/mgmt.c | 43 ++++++++++++++++++------------------------- > 1 file changed, 18 insertions(+), 25 deletions(-) what is up with the kbot issues? Regards Marcel