Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3895219ybl; Mon, 9 Dec 2019 01:50:31 -0800 (PST) X-Google-Smtp-Source: APXvYqz6YJFY8BChUUlIk6lwepdlQQ4JVsV1BM+euuaoN4IHnNvFr36XfOEkEwsT2RKiZOZL5KT7 X-Received: by 2002:a05:6830:60f:: with SMTP id w15mr20776151oti.225.1575885031073; Mon, 09 Dec 2019 01:50:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575885031; cv=none; d=google.com; s=arc-20160816; b=xZP0iBS7Xiql4nOzQ5UwwvgYGe4Iu2aPqfj3sfnUM5kYn4tVmJPnCzYUkJZAwLUtHF 3hNPBvnMrk9wsuevlgxshn8exyW8zUC6fivXjUPBmcioeQBc8jY/SOQtB+b3YW7FXmfg xDkuOwjvWYFEjZtqxnusLkHpKo30fqL7/DBZWk3vaJp+0kR96FBHeovFAq+tK8ZgpIt3 E9c2haiYfEqdYQmZwbSo6g4qoDhDDPBgwV8/JZx/a14PPJfugqDisc86cqRdhevU87KM lH4Ed6o1svjXmoz5rMVnWOvwRppNxkJYKh/afGphwDosqnHcWY+TfblHREX6A53hDtni EBDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=q8ZtFjkzbPZaLOGf/erzEvW2B1TT3oTZrg7O3ileW4c=; b=HJSFxAERuuRLO1/b/PuFIhuNOobTYIIQSYzW5IUQ0UBaEL+NEX5bjIg2Nh2Ve/I7xF 0kVnvcTDVEzgbM/YtAe+xLkOyMORMzUZ5R8IGyI28SHnNAEIGE0gmcnQ0fKIRnSD/o6R 7aol4susjZ+WaRzd6dxITq1CYdLPzLHiosbdsXh0H4b8i/NDyi6oREppjB598quLm4fm XCdv/IYUwUL1hRQ1AgIjSCoT0XRfs+xvWM7D+r/xU4fanEd7+IlkFuWxh/S32z+pCH6s 6tgg3Ra0S5GvIQHErMBJddytzvKReIRvnF0Lx3bFbeczbs8g4zjxpyHcxxOZoNsQ74RW hFYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=ld0SiPNH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p124si1586401oib.224.2019.12.09.01.50.19; Mon, 09 Dec 2019 01:50:30 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=ld0SiPNH; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727436AbfLIJe2 (ORCPT + 99 others); Mon, 9 Dec 2019 04:34:28 -0500 Received: from mout01.posteo.de ([185.67.36.65]:55087 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727359AbfLIJe1 (ORCPT ); Mon, 9 Dec 2019 04:34:27 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id 496BD160062 for ; Mon, 9 Dec 2019 10:34:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1575884064; bh=WKh0sIAEhxAQidqExK43MxzbufOPA+awPeWCVoz6J8k=; h=From:To:Cc:Subject:Date:From; b=ld0SiPNHHIr0xU0YACrKiiwfB2QhUmq9gZMmJXGuevqvck4JgEfhTBfduZOjbvEIJ YJH9+6oSVtm5O0cWz6jJqlAFncEjxSyuAQRWeAdptYa9kTeyISEChGrrSrpXvbI2KO a+ee9AA71HJpigFEpDc2mfvleTpOvC2KgMHrVJZF6H6l6GCbeMWNYUVz5FR01IVNMT xCH8gNDbEEorJrfUCR47TRQxzvrnbaKRBtDaiRrH+zGTcsfGyOap699uOHMvupgVul bxfmtU30wxqRvIvuMARsx3usScx6tu+b3MtGqmcbKmvrNIEiQhxMBDa+Jo4bukFsAL K0YhpoTPgo5tw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 47WdLk5X4sz6tmH; Mon, 9 Dec 2019 10:34:22 +0100 (CET) From: =?UTF-8?q?Moritz=20M=C3=BCller?= To: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@i4.cs.fau.de Cc: =?UTF-8?q?Moritz=20M=C3=BCller?= , "Philip K ." Subject: [PATCH v3] floppy: hide invalid floppy disk types Date: Mon, 9 Dec 2019 10:32:59 +0100 Message-Id: <20191209093258.14319-1-moritzm.mueller@posteo.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In some cases floppy disks are being indexed, even though no actual device exists. In our case this was caused by the CMOS-RAM having a few peculiar bits. This caused a non-existent floppy disk of the type 13 (in our case) to be registered as an possibly mountable device, even though it could not be mounted by any user. We believe this to be an instance of this bug: https://bugzilla.kernel.org/show_bug.cgi?id=13486 https://bugs.launchpad.net/ubuntu/+source/linux/+bug/384579 This patch adds the option FLOPPY_ALLOW_UNKNOWN_TYPES to prevent the additional check that fixed the issue on our reference system, and increases the startup time of affected systems by over a minute. Co-developed-by: Philip K. Signed-off-by: Philip K. Signed-off-by: Moritz Müller --- drivers/block/Kconfig | 10 ++++++++++ drivers/block/floppy.c | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 1bb8ec575352..9e6b32c50b67 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -72,6 +72,16 @@ config AMIGA_Z2RAM To compile this driver as a module, choose M here: the module will be called z2ram. +config FLOPPY_ALLOW_UNKNOWN_TYPES + bool "Allow floppy disks of unknown type to be registered." + default n + help + Select this option if you want the Kernel to register floppy + disks of an unknown type. + + This should usually not be enabled, because of cases where the + system falsely recognizes a non-existent floppy disk as mountable. + config CDROM tristate select BLK_SCSI_REQUEST diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 485865fd0412..9439444d46d0 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -3949,7 +3949,11 @@ static void __init config_types(void) } else allowed_drive_mask &= ~(1 << drive); } else { +#ifdef CONFIG_FLOPPY_ALLOW_UNKNOWN_TYPES params = &default_drive_params[0].params; +#else + params = UDP; +#endif snprintf(temparea, sizeof(temparea), "unknown type %d (usb?)", type); name = temparea; @@ -4518,7 +4520,10 @@ static bool floppy_available(int drive) return false; if (fdc_state[FDC(drive)].version == FDC_NONE) return false; +#ifndef CONFIG_FLOPPY_ALLOW_UNKNOWN_TYPES + if (UDP->cmos >= ARRAY_SIZE(default_drive_params)) + return false; +#endif return true; } -- 2.20.1