Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp566853pxb; Wed, 1 Sep 2021 05:29:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlYnKM9Y4Vc2nHKbIU9Y9jM3ZLR5nDvHsoqS2DkpK1zgLCzF6l+dPmLBosOMzsfOsTmffa X-Received: by 2002:a05:6402:2d8:: with SMTP id b24mr34512785edx.176.1630499386583; Wed, 01 Sep 2021 05:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630499386; cv=none; d=google.com; s=arc-20160816; b=gEMQ1E3FknECvFOfxWtbjXESpJSlSier6E74Cuk/YLxXdL8Iq+612v/yFCz8Km4vHA t3uc9Ig7MA/HqIl0VJFaLiBCpwDfAK/A9WbMMNO+k0HqFa0gZBkhIK1tyH+6Km+YruEG Cr/SEA0abQ70JNvTzVqNdqNmRphHRMVkcL1uWu617FV0up52IeZyMc9ansK6IjtgBUU9 k06d8SlxnuVWdIlixhxfr6i48QvuqPPnifMJSdLIpgxI6+d+rqsphcANreMItvKbQ3+M VC4RM293mdcU+hnEs9+Es5zaCvZuSett0ly5MFxd4ua4N7kCK99xeLhTC3lghAX6uiwa 8BCg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iNDcH0I85Gh1n+GU55JzHsfpJkh9xpGy6qoFrLN2Rm4=; b=vbrp0nowukxsOD/eXoJUmxZUYLJrKSU5/f2W2326Z5zi6zdeJzPhPlm1+l7VK64d1i 54oMdk/jCbKtvKMLDY1x9xk12iEYO1nRm26IMYS+LyzHpPd6OHOZlKATFvBbr90veuCA R/5ZUKdEZkiMxC13v1wFr9FPueUHuQ7dpCijyiCvyMv8c+aQgSWtWSwgFV7lQ/+61XGD 7ehKiUX0Ai15RbIkVyN4JlVom4LiyXhRJeX1/T8FXZoQZPZ7qiVbiKhtasNiF+a5IYR7 8ciomw9bhjCVfieUlVjzVzboqh8g12oHCLT0VMX184FVxti0cfDYEjq6PIa0GljBTRfv fqBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mvvpDM8W; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si21040080edv.518.2021.09.01.05.28.58; Wed, 01 Sep 2021 05:29:46 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=mvvpDM8W; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244079AbhIAM1b (ORCPT + 99 others); Wed, 1 Sep 2021 08:27:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:56518 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244076AbhIAM1b (ORCPT ); Wed, 1 Sep 2021 08:27:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 042EA6101B; Wed, 1 Sep 2021 12:26:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1630499194; bh=nbDaieXQmUkIedNlAIj4P9JNKmxJvEcQAwDf9D18Ao8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mvvpDM8WYt++lyNm5y7i/RagIN1SzEaSznxaC3h2/yg2ceoXsLDun/JLiMfpgjwmb Ey4NiTn3f7GKLL+pMPg9rrbNFejwbQ6gycVAzdRFCdaBWdMZAJBWmknTl/Wm6EbieV RFJU2HsxraImcdL2CeYoPgA5+LK9iMVBtxL6vR5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Hounschell , Jiri Kosina , Wim Osterholt , Kurt Garloff , Denis Efremov Subject: [PATCH 4.4 10/10] Revert "floppy: reintroduce O_NDELAY fix" Date: Wed, 1 Sep 2021 14:26:24 +0200 Message-Id: <20210901122248.380753301@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210901122248.051808371@linuxfoundation.org> References: <20210901122248.051808371@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Denis Efremov commit c7e9d0020361f4308a70cdfd6d5335e273eb8717 upstream. The patch breaks userspace implementations (e.g. fdutils) and introduces regressions in behaviour. Previously, it was possible to O_NDELAY open a floppy device with no media inserted or with write protected media without an error. Some userspace tools use this particular behavior for probing. It's not the first time when we revert this patch. Previous revert is in commit f2791e7eadf4 (Revert "floppy: refactor open() flags handling"). This reverts commit 8a0c014cd20516ade9654fc13b51345ec58e7be8. Link: https://lore.kernel.org/linux-block/de10cb47-34d1-5a88-7751-225ca380f735@compro.net/ Reported-by: Mark Hounschell Cc: Jiri Kosina Cc: Wim Osterholt Cc: Kurt Garloff Cc: Signed-off-by: Denis Efremov Signed-off-by: Greg Kroah-Hartman --- drivers/block/floppy.c | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4066,22 +4066,21 @@ static int floppy_open(struct block_devi if (UFDCS->rawcmd == 1) UFDCS->rawcmd = 2; - if (mode & (FMODE_READ|FMODE_WRITE)) { - UDRS->last_checked = 0; - clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); - check_disk_change(bdev); - if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) - goto out; - if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) + if (!(mode & FMODE_NDELAY)) { + if (mode & (FMODE_READ|FMODE_WRITE)) { + UDRS->last_checked = 0; + clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); + check_disk_change(bdev); + if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) + goto out; + if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) + goto out; + } + res = -EROFS; + if ((mode & FMODE_WRITE) && + !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) goto out; } - - res = -EROFS; - - if ((mode & FMODE_WRITE) && - !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) - goto out; - mutex_unlock(&open_lock); mutex_unlock(&floppy_mutex); return 0;