Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp318400rda; Sat, 21 Oct 2023 08:56:21 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGKTI6UmJiP7GZzKiw2BjZDlyLQGd5v6jzDSAoVZ5LpdNasaOj2y+pOAiYobK7RuiRKghen X-Received: by 2002:a05:6808:291:b0:3a5:a78b:f773 with SMTP id z17-20020a056808029100b003a5a78bf773mr5136403oic.6.1697903781500; Sat, 21 Oct 2023 08:56:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697903781; cv=none; d=google.com; s=arc-20160816; b=wV45SZec4P0XZJitVDWTF3X+SDXeW/mob8LdEkx98Lp5WYSPTpJwzMJcCY7zhOdBD4 TLRuwOCEvVmxYpWLZFdOjRLVjSpaqJGzUep/GVS8atLvpS5qmLI3jjipsybHDKB4XKjL 2n8KX1FOqVVTz0UKoBSAmVEe3h9h0u3mPacrEMgEdGumfD+fI1uRay17fh0eOIbBTnA6 m6toisYt9O8QbExj7ZcgAgzpMsZs50Qry5KgukiAAS2PoTCLdGYngasjDYV1ExoHzGxx suRoiLkZz6/kSfryruwiUyayT5Q7KIUyn4rXlciLMBIfQF/KhLyK1joFut76GKwYH19S X8Cg== 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:subject:cc:to:from:date :dkim-signature; bh=SUO9I0CEuZ1wnukRZkUIHoL4kTRxinIpVkmVp8nozz0=; fh=/VP8wnGJxj4RZEiUggbFzzqmab1L5RcmHMz1AJF0GB8=; b=E52q7rTRf+qga6KzB3gvZVsT2cHfRAmqayukPERv3twHxprv/fSD8HV9SRQ2EJkz4A yLEe7nK3qw/pgizahY+CINJsB87Iyt3fEU8ChZ52Mlx5Ko/b21IQ7vFNsz6r69pE3mXv XxrGGr/ikfan1LeidhR8ivBKWoSltXb60Wgi7lBjog7CseNxUrcPdTrl2BzmazRLCMs1 wE4VLyRIMVY2uS1rNxAJLXXLog0WwlTFqUUqDZV9htVxuqDUQbsyyWvub3O2CDqTU3FV 0xdwcpk4SH6Ahvlmeq7IYSMkC2twnlZu59CRFqgH5fl+A13D9dTDAROlT5u0Es1f+qzb C2Mg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LQ56t8Gy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id g21-20020a170902869500b001c9e3c866casi3472560plo.19.2023.10.21.08.56.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 21 Oct 2023 08:56:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LQ56t8Gy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 19B508082854; Sat, 21 Oct 2023 08:55:54 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231596AbjJUPzq (ORCPT + 99 others); Sat, 21 Oct 2023 11:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231604AbjJUPzo (ORCPT ); Sat, 21 Oct 2023 11:55:44 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 196D61A4; Sat, 21 Oct 2023 08:55:43 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8CD7FC433C7; Sat, 21 Oct 2023 15:55:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697903742; bh=hwuLjwamauGBX49+ZMEyvP+u0WgatDfDReunLsuxivY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=LQ56t8Gyrec0S5bFF2ewoXMPh25xVNQ1SmvlkIqX34Z1/2BtczQkEa9Y9TlKNm9iN YY6QhRK/6vDJF9Ic3FUdcEWfIlkJXZIH5/B8sx63M3EZ2Xz6ovqHu+Sw5GPfpzL/0R Pn83s+adJAuWQ/kkHWT3KEwscIoVC72AmVw0rDSURZ3t2BH+Tux2etXdYcpbzPLr48 ru3CD/Hbryl1++oqedwq2g9xXCfQprOPk7DgdW4KQtdGBOOFOsFtrQsvtYQuZBJooQ tua2FKpDbgiotYrJsGQenYGVMp3nLzsqY3G/W1vfyA48Q3juySSCmIYDUWeuMOR8Au 2k9hqccy4Gv2Q== Date: Sat, 21 Oct 2023 16:55:35 +0100 From: Jonathan Cameron To: Matti Vaittinen Cc: Matti Vaittinen , Lars-Peter Clausen , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/2] Sanity-check available_scan_masks array Message-ID: <20231021165535.34dcb94b@jic23-huawei> In-Reply-To: References: X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Sat, 21 Oct 2023 08:55:54 -0700 (PDT) On Mon, 16 Oct 2023 14:04:11 +0300 Matti Vaittinen wrote: > Sanity-check available_scan_masks array > > The available_scan_masks is an array of bitmasks representing the > channels which can be simultaneously(*) scanned by a driver from the > device. Following special characteristics apply: > > - When IIO is scanning through the array it will use the first mask > which can be used to scan all enabled channels. This means drivers > should order the array in the order of the preference. This does also > mean that a mask which is a subset of a mask located earler in array > will never be used because the earlier one will be picked by the core. > - Masks wider than size of long are supported only to some extent. The > code scanning through the array will interpret the first mask with > first long zeroed as end-of-array terminator. Changing this behaviour > would make mask-arrays for multi-long masks to be terminated by more > than one zero long. Failure to do so would result kernel to read > beyond the array generating a potentially hazardous bug. > > Add a sanity-check to IIO-device registration emitting a warning if > available_scan_mask array is misordered or if mask width is larger than > a long while available_scan_mask-array is populated. Currently there > should be no in-tree drivers with available_scan_mask populated and mask > wider than a long. > > Revision history: > v1 => v2: > - Add patch 2/2 documenting why iio_scan_mask_match() checks only > a long worth of bits while searching for the end of the > available_scan_mask-array. > - Styling of patch 1/2 as per comments from Jonathan > v1 and related discussion here: > https://lore.kernel.org/lkml/ZRvjuZaQWdZw1U1I@dc78bmyyyyyyyyyyyyydt-3.rev.dnainternet.fi/ > > Matti Vaittinen (2): > iio: sanity check available_scan_masks array > iio: buffer: document known issue > > drivers/iio/industrialio-buffer.c | 16 ++++++++ > drivers/iio/industrialio-core.c | 63 +++++++++++++++++++++++++++++++ > 2 files changed, 79 insertions(+) > Hi Matti, Just a quick note to say this looks fine to me, but I don't want to queue it up just yet given proximity to merge window etc. I'll aim to pick it up early in next cycle. Give me a poke if I still haven't by rc3 or so. Thanks, Jonathan