Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3175566ybl; Sun, 8 Dec 2019 09:00:44 -0800 (PST) X-Google-Smtp-Source: APXvYqycBdxwY/rkE8sHxxHcAVMIwK6iAGqI4jUButbMAx6vSZ5Xgyp+xxSsQc5DB7nto4P8/LKZ X-Received: by 2002:a05:6830:10c6:: with SMTP id z6mr19915009oto.203.1575824443860; Sun, 08 Dec 2019 09:00:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575824443; cv=none; d=google.com; s=arc-20160816; b=RaEdwB5+j+J76aXy1tU16r2vz8ByhTClmpY17BnXuPsslLO7kQ9JT+dh1X0AEnjsTP k6WnYhr5/5gCuGSAgVQ3G5e5+SL+QeEAOkCqAiWuALgApv31+buvqgd4Y5hVhANSDg+D ELzheP7hfxjZrjAy90OIyoUXRoDYFJVQnUfPnRl8xEvKyW0SEFMP44oisbJj/XdElj7G BSn/LIHD+s6EBNUiJ4ur5k5a0lm2h/ZO7R3ZXUgnsAqDXWu6JPLtnEzIZjDXSN6kcOaw 5y0e6BJdBb/xaWAOsSnwJvycIQZcwQOh/dk/suKLrnlkAN+ISE71aoK79KLnq6/7xWzq EVqg== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=+tAPf1uRi4PofMVA8m3Q6APDxB0CEBASS8sRBk1/Kzs=; b=kk1y+k2gW8PRFlpz4reYJHC+65GfVKEWdBcCHawZJfaFKsspY5VxHJ+awsx+BFoCdh +EvreZa800qGLvAHPUOItrNAfemY46eAyjkd0SsKzDS7fDnBWCjmO9giFJ3K3+4qP8WV MxiSuSGgcyiaLVTm2arP63OjTr1GvgCDsmPLLk0sVI+YMTfFtu73olFPLGcqErLbjwKV Ven8dShuULqf407nLu0ahIFZA3kxH3e1xC1LdTdYhIvhnHuK938n//AYwLbNMO1tUDkK Z1n4QUM2A/gpB5i+j6tsA+hEZcfDPSqyvDxoV2rjXW8maAFZlVSRMeA2yjXxSvdL0csF Pe5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=hnanfFNk; 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 l1si11711098otn.98.2019.12.08.09.00.32; Sun, 08 Dec 2019 09:00:43 -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=hnanfFNk; 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 S1726491AbfLHRAI (ORCPT + 99 others); Sun, 8 Dec 2019 12:00:08 -0500 Received: from mout01.posteo.de ([185.67.36.65]:59364 "EHLO mout01.posteo.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726472AbfLHRAI (ORCPT ); Sun, 8 Dec 2019 12:00:08 -0500 Received: from submission (posteo.de [89.146.220.130]) by mout01.posteo.de (Postfix) with ESMTPS id AFAD1160064 for ; Sun, 8 Dec 2019 18:00:05 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1575824405; bh=YFoFHhM4VD18eShuz4mN7CRcZATk+krghvupPMPzEP4=; h=From:To:Cc:Subject:Date:From; b=hnanfFNki6YEUXmB6dssFQhzY8hOLrjsJ6lEV5hlLDpSTId9Lb8+dmOLfrH9DvvFc PSJx3rJ745k6XqvYFE/aQ0n/LQbYqDlD2FS4ECVUT+p/sn4ww8SzRHfWcAoqvAyyyP VPFHCo1dsYPGEH9y9XJynWxvSbjH1WNGByKvZgEtdSwlWtLuSgRtcxupSfQt/nKfwb w97cnGfMmXeMHahzGEzPdmk1mLPxAuB9pcW0C6SGHAa5uNxCmb+sqTF6TEpOa+sO3z QwMeiAu5lmRH+DJfn7n/EehFCmp6vxe5io1P/5HKKjM3pqo7atIxO93NQbwktsFSP1 NQd00H24qXEGQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 47WCHT0q04z6tmG; Sun, 8 Dec 2019 18:00:05 +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] floppy: hide invalid floppy disk types Date: Sun, 8 Dec 2019 17:59:00 +0100 Message-Id: <20191208165900.25588-1-moritzm.mueller@posteo.de> X-Mailer: git-send-email 2.20.1 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 recognised even though no such device exists. In our case this has been caused by the CMOS-RAM having a few wrong bits. This caused a non-existent floppy disk with the type 13 (for example) to be registered as an available 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 recongizes 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,9 @@ 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; +#ifdef snprintf(temparea, sizeof(temparea), "unknown type %d (usb?)", type); name = temparea; @@ -4518,6 +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 (type >= ARRAY_SIZE(default_drive_params)) + return false; +#endif return true; } -- 2.20.1