From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Y29SVj0Q" Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7FC21B5; Tue, 5 Dec 2023 01:28:27 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 293681BF213; Tue, 5 Dec 2023 09:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701768505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ah8rFZzaoCOG6tWC+OXcYVYNejwejwSxxUHciVjGroI=; b=Y29SVj0QfTDCsTjUMTpzzAWrkPNnENITOnw2ALozUKcgKRn1+/uJ9HIv0/EpPUbdl5nAmE +/TlRd27EpqNsRN1/wTe4Rv/cuHxjUuvrMtAymZc1Ao/QfNVTbFYDLQ2EUwe0I3LaUEHOo kFAQ6/YIk57tWPRVyxNcyaO5/OusZTN/iSCP2cVIuRQEUdl0IePkhKOI/rwlWV17018pdI GElj2pBAFov0MkIT/+FOwBg7IUfkUMlhXDBOO4sZBN7ai3NHnPVo1NUG1OA9E2XVqO5KoJ LXhRBWjg6075Uu+w42xAY5K0flUAVT6tmpxZvxaU4+HyvD361IrMWwTVlf5idg== Date: Tue, 5 Dec 2023 10:28:21 +0100 From: Miquel Raynal To: Richard Weinberger Cc: Mark Brown , linux-spi , Thomas Petazzoni , Ryan Wanner , Ronald Wahl , David Laight , Nicolas Ferre , Claudiu Beznea , Alexandre Belloni , linux-arm-kernel , stable Subject: Re: [PATCH] spi: atmel: Prevent spi transfers from being killed Message-ID: <20231205102821.224ccbe6@xps-13> In-Reply-To: <1788823860.72909.1701768176780.JavaMail.zimbra@nod.at> References: <20231205083102.16946-1-miquel.raynal@bootlin.com> <1788823860.72909.1701768176780.JavaMail.zimbra@nod.at> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) Precedence: bulk X-Mailing-List: linux-spi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com Hi Richard, richard@nod.at wrote on Tue, 5 Dec 2023 10:22:56 +0100 (CET): > ----- Urspr=C3=BCngliche Mail ----- > > Von: "Miquel Raynal" > > All being well, it was reported that JFFS2 was showing a splat when > > interrupting a transfer. After some more debate about whether JFFS2 > > should be fixed and how, it was also pointed out that the whole > > consistency of the filesystem in case of parallel I/O would be > > compromised. Changing JFFS2 behavior would in theory be possible but > > nobody has the energy and time and knowledge to do this now, so better > > prevent spi transfers to be interrupted by the user. =20 >=20 > Well, it's not really an JFFS2 issue. > The real problem is, that with the said change anyone can abort an IO. > Usually file systems assume that an IO can only fail in fatal situations. > That's why UBIFS, for example, switches immediately to read-only mode. > So, an unprivileged user can force UBIFS into read-only mode, which is a > local DoS attack vector. Right. > JFFS2, on the other hand, dies a different death. If you abort one IO, > another IO path can still be active and will violate the order of written > data. >=20 > Long story short, aborting pure user inflicted IO is fine. This is the "d= d" > use case. > But as soon a filesystem is on top, things get complicated. >=20 > Maybe it is possible to teach the SPI subsystem whether an IO comes from = spidev > or the kernel itself? Well, it would only partially fix the problem, I was playing with a spi-nor or spi-nand chip (don't remember) which was supported in the kernel, just making big reads/writes (without fs, at this time). I don't think deliberating on whether the driver requesting the transfer is in the kernel or in userspace matters, but whether there is a filesystem on top or not. But TBH I don't think this can be solved without ugly hacks... Thanks, Miqu=C3=A8l From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DED92C4167B for ; Tue, 5 Dec 2023 09:28:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pd9SLirrgVMf38GukOCol1QgUiPad32BZ6P1DjZJGq0=; b=18eudEhKxIIlkO FwUzDrBbIjnI3RyE81tiVLFtTMSKzsMpm/9gclXPm+Iscfo80pZr7zleARDhKGOcMl4cv0YH8BLFB 4UN/4KM/gutGQpOpR+9L2JlA69vIBMwY6qsieD5jfb9B94afPu0Iot8cg7vFzsFnNqQ8yIZaYilYD /3KN9h2BdRGiG8y2CrMx9qHlF4zQEhXAYl7BniLm5dqSDYhAh4t4UTYl1JO7cr2wF86FpDDN+O4QQ 8wSDqu+tkO9BJiPTruw3fV4J8FQPiZ4SZ+q9PxgNhO4lbaxSX61TkM9q48UqmLAgyMJu4HLmA9J/z ZC8oGqsIrkuy9IdJlVAw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rARjF-006nkB-1q; Tue, 05 Dec 2023 09:28:33 +0000 Received: from relay8-d.mail.gandi.net ([2001:4b98:dc4:8::228]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rARjB-006ndt-0Y for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 09:28:31 +0000 Received: by mail.gandi.net (Postfix) with ESMTPSA id 293681BF213; Tue, 5 Dec 2023 09:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701768505; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ah8rFZzaoCOG6tWC+OXcYVYNejwejwSxxUHciVjGroI=; b=Y29SVj0QfTDCsTjUMTpzzAWrkPNnENITOnw2ALozUKcgKRn1+/uJ9HIv0/EpPUbdl5nAmE +/TlRd27EpqNsRN1/wTe4Rv/cuHxjUuvrMtAymZc1Ao/QfNVTbFYDLQ2EUwe0I3LaUEHOo kFAQ6/YIk57tWPRVyxNcyaO5/OusZTN/iSCP2cVIuRQEUdl0IePkhKOI/rwlWV17018pdI GElj2pBAFov0MkIT/+FOwBg7IUfkUMlhXDBOO4sZBN7ai3NHnPVo1NUG1OA9E2XVqO5KoJ LXhRBWjg6075Uu+w42xAY5K0flUAVT6tmpxZvxaU4+HyvD361IrMWwTVlf5idg== Date: Tue, 5 Dec 2023 10:28:21 +0100 From: Miquel Raynal To: Richard Weinberger Subject: Re: [PATCH] spi: atmel: Prevent spi transfers from being killed Message-ID: <20231205102821.224ccbe6@xps-13> In-Reply-To: <1788823860.72909.1701768176780.JavaMail.zimbra@nod.at> References: <20231205083102.16946-1-miquel.raynal@bootlin.com> <1788823860.72909.1701768176780.JavaMail.zimbra@nod.at> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-GND-Sasl: miquel.raynal@bootlin.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_012829_356351_8851F357 X-CRM114-Status: GOOD ( 22.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexandre Belloni , Ryan Wanner , David Laight , stable , linux-spi , Mark Brown , Thomas Petazzoni , Claudiu Beznea , Ronald Wahl , linux-arm-kernel Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org SGkgUmljaGFyZCwKCnJpY2hhcmRAbm9kLmF0IHdyb3RlIG9uIFR1ZSwgNSBEZWMgMjAyMyAxMDoy Mjo1NiArMDEwMCAoQ0VUKToKCj4gLS0tLS0gVXJzcHLDvG5nbGljaGUgTWFpbCAtLS0tLQo+ID4g Vm9uOiAiTWlxdWVsIFJheW5hbCIgPG1pcXVlbC5yYXluYWxAYm9vdGxpbi5jb20+Cj4gPiBBbGwg YmVpbmcgd2VsbCwgaXQgd2FzIHJlcG9ydGVkIHRoYXQgSkZGUzIgd2FzIHNob3dpbmcgYSBzcGxh dCB3aGVuCj4gPiBpbnRlcnJ1cHRpbmcgYSB0cmFuc2Zlci4gQWZ0ZXIgc29tZSBtb3JlIGRlYmF0 ZSBhYm91dCB3aGV0aGVyIEpGRlMyCj4gPiBzaG91bGQgYmUgZml4ZWQgYW5kIGhvdywgaXQgd2Fz IGFsc28gcG9pbnRlZCBvdXQgdGhhdCB0aGUgd2hvbGUKPiA+IGNvbnNpc3RlbmN5IG9mIHRoZSBm aWxlc3lzdGVtIGluIGNhc2Ugb2YgcGFyYWxsZWwgSS9PIHdvdWxkIGJlCj4gPiBjb21wcm9taXNl ZC4gQ2hhbmdpbmcgSkZGUzIgYmVoYXZpb3Igd291bGQgaW4gdGhlb3J5IGJlIHBvc3NpYmxlIGJ1 dAo+ID4gbm9ib2R5IGhhcyB0aGUgZW5lcmd5IGFuZCB0aW1lIGFuZCBrbm93bGVkZ2UgdG8gZG8g dGhpcyBub3csIHNvIGJldHR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