Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp270924pxb; Thu, 21 Jan 2021 06:48:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJyM43RWCwU8Ggq8T9KMLTgRCTxiqegjaCIrkTsycuo+FYRj89KXjKtrQFc5SOp+T6RfWfLB X-Received: by 2002:a05:6402:6c4:: with SMTP id n4mr11674975edy.257.1611240533679; Thu, 21 Jan 2021 06:48:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611240533; cv=none; d=google.com; s=arc-20160816; b=Yl9+M6roQRtomkzJzYlCEt9nRO2WsAGrPoA7LhjQxzmqkt2BWoIjC3FuFsrI3hOYE/ 4FTDt0DHXRtUEy6pRESN+uguB8IfRptq68iVlDnTvlrw0WZ4BUfv+HC5YSbJxUjpB1Dr PzQceIE2ET+SnO2hY/WnmJPffJMToXQK/E9CNXr2bPN5w4sdWi1v2Tj8AlwwUu4Jz4hb vPO2t7O1aZbgQa04TJ19ZELyaDY6qAWTKYSWwhjS1YWBmsoTL6UkHYQuFdT9Vn0BrNti LIwhIJR3yFrXXeC9eYHB2+7rU2c+Bghduza6cS6rr/eY2lRiOSbHWWHDlfwuTg8GKvMy to9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=k90jG6oYLNwmvRpMYgIGt67bRitjO4mb5fxx8zuid0g=; b=fqIfw3zQ5pa4Mgf31ruhQzphGMl3tp/MTjkGjI1NoeA2kY94HYQ5F15evj0jKizahu lgNxDHO/AVBvO7dKDuwHi3nS4ZmsgVinWAdGnYEy59pqLZqawVM11AP6Qp1MMRJIlQVD HV7HpfRh/i4skmyKqKGqQBovZgG49P8outAWIBJVBGJswtnDXSNZVgOICAkLrjjRbP76 AZTrpNcU6w4bX2Sl06pdYfuMhimFh8RTuFQt6oai5HbZ06Lh7kqADbpcPBGELqsXcgyT UFQB0OWc5iCrnVxEf8iy5P/Et64oMp34cFdGwLOResvEH5rB0Nfeyl624J2s28uWRTR8 Yksg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UlCF76E+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f10si1858837ejb.622.2021.01.21.06.48.29; Thu, 21 Jan 2021 06:48:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=UlCF76E+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1732107AbhAUOpW (ORCPT + 99 others); Thu, 21 Jan 2021 09:45:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:36400 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729685AbhAUOpQ (ORCPT ); Thu, 21 Jan 2021 09:45:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 75CE022248; Thu, 21 Jan 2021 14:44:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1611240271; bh=MdhOmJTeoY10X6IiIajHpF8R5t8U+MEBa16TKOVmcxk=; h=Date:From:To:cc:Subject:In-Reply-To:References:From; b=UlCF76E+cG7SVrvDlxBW6kUNw6ABi2JMPYXC33kkI+DBB325QdZfrHjo07Ko0lu/J ZBvTYV4yHy8kArJDt0mVwm8aqyz12wwQnt2BZkyZTLQRFna4ZWWKkQK+jdgcMAWzLF C/2miJtDj5UiHP8jXj1Q68xFWgEIZCo4ZmlNdJejewXnX32J1gD076Lh9G+zRKuVsm v4cNZ7N5AkIflcBWoRLYpVwP9epVzH9zIwSRR1FU2pMTI5PHzJkvpxn3RLAeF5uhW/ g77dCVbFNvgM9w0JHeYyT+FYPNKn/UGIbUf0Y5uH4EprGePvvPgoUpMP+JU1Go1um+ tr2JJTn9b6Pyw== Date: Thu, 21 Jan 2021 15:44:28 +0100 (CET) From: Jiri Kosina To: Denis Efremov cc: Jens Axboe , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Wim Osterholt Subject: Re: [PATCH RESEND] floppy: fix open(O_ACCMODE) for ioctl-only open In-Reply-To: Message-ID: References: <20160610230255.GA27770@djo.tudelft.nl> <20160614184308.GA6188@djo.tudelft.nl> <20160615132040.GZ14480@ZenIV.linux.org.uk> <20160615224722.GA9545@djo.tudelft.nl> <9c713fa8-9da1-47b5-0d5d-92f4cd13493a@kernel.dk> <5cb57175-7f0b-5536-925d-337241bcda93@linux.com> User-Agent: Alpine 2.21 (LSU 202 2017-01-01) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 21 Jan 2021, Jiri Kosina wrote: > I am currently waiting for confirmation by the original reporter that the > patch below fixes the issue. ... a now a patch that actually compiles :) (made a mistake when forward-porting from the older kernel on which this has been reported). From: Jiri Kosina Subject: [PATCH v2] floppy: reintroduce O_NDELAY fix Originally fixed in 09954bad4 ("floppy: refactor open() flags handling") then reverted for unknown reason in f2791e7eadf437 instead of taking the open(O_ACCMODE) for ioctl-only open fix, which had the changelog below ==== Commit 09954bad4 ("floppy: refactor open() flags handling"), as a side-effect, causes open(/dev/fdX, O_ACCMODE) to fail. It turns out that this is being used setfdprm userspace for ioctl-only open(). Reintroduce back the original behavior wrt !(FMODE_READ|FMODE_WRITE) modes, while still keeping the original O_NDELAY bug fixed. Cc: stable@vger.kernel.org # v4.5+ Reported-by: Wim Osterholt Tested-by: Wim Osterholt Signed-off-by: Jiri Kosina ===== Fixes: 09954bad4 ("floppy: refactor open() flags handling") Fixes: f2791e7ead ("Revert "floppy: refactor open() flags handling"") Signed-off-by: Jiri Kosina --- v1 -> v2: fix build issue due to bad forward-port drivers/block/floppy.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index dfe1dfc901cc..f9e839c8c5aa 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4121,23 +4121,23 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) if (fdc_state[FDC(drive)].rawcmd == 1) fdc_state[FDC(drive)].rawcmd = 2; - if (!(mode & FMODE_NDELAY)) { - if (mode & (FMODE_READ|FMODE_WRITE)) { - drive_state[drive].last_checked = 0; - clear_bit(FD_OPEN_SHOULD_FAIL_BIT, - &drive_state[drive].flags); - if (bdev_check_media_change(bdev)) - floppy_revalidate(bdev->bd_disk); - if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags)) - goto out; - if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags)) - goto out; - } - res = -EROFS; - if ((mode & FMODE_WRITE) && - !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags)) + if (mode & (FMODE_READ|FMODE_WRITE)) { + UDRS->last_checked = 0; + clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags); + if (bdev_check_media_change(bdev)) + floppy_revalidate(bdev->bd_disk); + if (test_bit(FD_DISK_CHANGED_BIT, &drive_state[drive].flags)) + goto out; + if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &drive_state[drive].flags)) goto out; } + + res = -EROFS; + + if ((mode & FMODE_WRITE) && + !test_bit(FD_DISK_WRITABLE_BIT, &drive_state[drive].flags)) + goto out; + mutex_unlock(&open_lock); mutex_unlock(&floppy_mutex); return 0; -- Jiri Kosina SUSE Labs