Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1742763rwb; Sun, 2 Oct 2022 07:09:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM42OQSQAuVAZ33Cquznp33fxa7i1jkVyI9veYE7fk1Yfk6rDcJ9PiEn9gZX962+F3lwFVoL X-Received: by 2002:a17:907:3207:b0:741:3a59:738d with SMTP id xg7-20020a170907320700b007413a59738dmr12230814ejb.110.1664719767562; Sun, 02 Oct 2022 07:09:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664719767; cv=none; d=google.com; s=arc-20160816; b=JNUgWz4Q+J8S0rIavxeecFtj+qLvc2Y0VmQHqyBzXHrjMw4K8xJr23HHCmzW7z7K+B kcfh7PkIQSZ+0SUq31V5YGz0Ttrre2OMxX44CDanz8VFl2fBAVuQOn3T5Khq1UXBy4z9 /dKvvcU92ZQ06L+Ijuneyc0WvBDjBeaDte6ftXieRX1L4b+LCvro2m9l70AzXrJKnKrO OA57S4NjV/s2OKmVZcQbvy2dO3U/RolIOcBTXB7On09lrq9BFBgPvsKBJxZhzfRERKaC 0E71HVdmlA/Gg1+WSZ684PktyOY35RpvtA0WfIavByyjMP/Z9OhrSKqm+slPgjVozSog w1sA== 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=smiLOM5TExTlf6zG/jrTnfg1qMQNYyzc2/Zsd8lGKjE=; b=ur1AoH1ac6hwoaT8Ek5hUsZhNI/qbeOZcYkyNcUY9n0gc7J5YAasxLtyCoajQpMX1M IilNXY6uuV1CwzgnMvs6I2VXWXqbH2bAL+CTCrhQoyXQpYgyIbtukQ5/VU3Pkv8Zi25X d1EdkauDFisWC4Rylikz/ZjAwvtNE4fx/ALvVML6gdUbCHutXv1PSUPZUWZPutJSI2Id USdePaKSrAlHtnV0686kPp0D5Md1VCMQpVHOYMBlKMoj0Rr0ySFyRne6NW46sY22Fzav tbDUvEjKcxZNz8V3Zp0UHItOUSfkH4NMcqcJ7OLr7wzUYAFwM3XVsJs+xuMckjuqAoTY kuqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=APKOMb73; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb31-20020a170907161f00b00781599eb7e4si6510081ejc.753.2022.10.02.07.08.35; Sun, 02 Oct 2022 07:09:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=APKOMb73; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229904AbiJBN5D (ORCPT + 99 others); Sun, 2 Oct 2022 09:57:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbiJBN47 (ORCPT ); Sun, 2 Oct 2022 09:56:59 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BAC7532B91; Sun, 2 Oct 2022 06:56:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 63255B80D31; Sun, 2 Oct 2022 13:56:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 897D1C433C1; Sun, 2 Oct 2022 13:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1664719016; bh=YF4OVbnB9hzRJnIWJLAOYnGD8RwPg/JYl59+Nox2ao8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=APKOMb73H16T4v6RELKk2SVdyPtc3sBbH8Zrei+IE9X+o7aCnOaWW/9g++kq5DBwA hXE5uCMN0d/L9PoSXp/z0nQVbQlwnvGm4RDe1MeBvuGz4sYyRXS4jk2hFtLgHou8jc M+plTVFqC31zxaHq0TcS5lwIY7AeKwte2jwSrkgV7NE5eQvI0i7KHQJRCwjjkPCWY9 tzNTg2LNZs68IkAlYLGWCsZ34sAxuMVA+bhI7wDz2KTNV/JRbf3cBLTv8ZvcSpBiD4 lxEFip93DkwZepsZ/5Xlit2UHNKwevdrHkSDtAovppNIvMb0LBHJqLPFKs8uPsw5hL 4m+05kvY4ddrA== Date: Sun, 2 Oct 2022 14:57:08 +0100 From: Jonathan Cameron To: Matti Vaittinen Cc: Matti Vaittinen , Cosmin Tanislav , Lars-Peter Clausen , Michael Hennerich , Eugen Hristev , Nicolas Ferre , Alexandre Belloni , Claudiu Beznea , Benson Leung , Guenter Roeck , Alexandru Ardelean , Srinivas Pandruvada , Uwe =?UTF-8?B?S2xlaW5lLUvDtm5pZw==?= , Nathan Chancellor , Miquel Raynal , Miaoqian Lin , Paul Cercueil , Mihail Chindris , Gwendal Grignou , Douglas Anderson , linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, chrome-platform@lists.linux.dev Subject: Re: [RFT PATCH v2 2/2] iio: Fix unsafe buffer attributes Message-ID: <20221002145644.16db3aec@jic23-huawei> In-Reply-To: <614bb5336c2922578da60a43570f42018623557a.1664610071.git.mazziesaccount@gmail.com> References: <614bb5336c2922578da60a43570f42018623557a.1664610071.git.mazziesaccount@gmail.com> X-Mailer: Claws Mail 4.1.0 (GTK 3.24.34; 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=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org On Sat, 1 Oct 2022 10:44:23 +0300 Matti Vaittinen wrote: > The iio_triggered_buffer_setup_ext() was changed by > commit 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr") > to silently expect that all attributes given in buffer_attrs array are > device-attributes. This expectation was not forced by the API - and some > drivers did register attributes created by IIO_CONST_ATTR(). > > The added attribute "wrapping" does not copy the pointer to stored > string constant and when the sysfs file is read the kernel will access > to invalid location. > > Signed-off-by: Matti Vaittinen > Fixes: 15097c7a1adc ("iio: buffer: wrap all buffer attributes into iio_dev_attr") Hi Matti, This feels like we are doing too much in one go. I would start with fixes for each individual driver, then once those are in we come around again and do the refactor. So for the first patch set (one per driver) just siwtch to yor new dev_attr but still use a struct attribute * array. Second series then does the refactor so we don't introduce any new instances in future. More churn but the code to backport is more tightly confined. Thanks, Jonathan > > --- > > v1 => v2: > fix also industrialio-buffer-dmaengine.c and cros_ec_sensors_core.c > > The fix is only superficially tested by a ROHM/kionix KX022A driver. > Proper testing with real in-tree IIO stuff is _highly_ appreciated.