Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4333694ybl; Mon, 9 Dec 2019 09:06:16 -0800 (PST) X-Google-Smtp-Source: APXvYqxUX2LrURsCtQCmulB1RQRnQ0CYnicpoyco/LVSK2UsMc4EGNVgFqRmVY6nNI4/VUvaG3OE X-Received: by 2002:a9d:7305:: with SMTP id e5mr21446607otk.64.1575911176554; Mon, 09 Dec 2019 09:06:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575911176; cv=none; d=google.com; s=arc-20160816; b=ZDdAkeMm91Vg3xnsnbYiUdwbCkV3sIh8xcLFOCX2HZWnzQhNnMGAfYafvu2Kz3obQC lZr9Gb1NXSpQ206DcH0m5ruteSja7eF41PeKsO5ievJgXZYYTOEfq2CxLle8YyxqYhw9 DOhxwDtRHuKuTzY0148MWxJUO9blhyZD80GwW77IHtGZT2qrxKvjgE2BujCWVDs/spJ+ 3baQ+AmnPid5IPmBIkFt0DgAvmG3uWwUwUIkHYRbFHF8O564M0Q+UP0tXKELp9PvRRHc 9ze511UxpT/W7uNNpa6KPmQvGSqSnY6z/HYeuWxeLWxeccVkAWXfyBAzX+0qPUaEyttX G7ow== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:reply-to:references:cc:to:subject; bh=7QOUlkYUUcL9RJraaiKsihHk7jZjKK6PuheJk93ZnR8=; b=xSaU/LtnUWEo6E7oq9KLHUlG1hd8f4yfU4oZxjh1H3ha1mE2MmiwJ/lAG4DiKRK83j UkqTwZvq3mXAvQJt7jDUIGX+gGy5cgc/J2e+oSgQvtjypRQAVA0XlYyPaiGaThOL+cBL U3rzAFSqHaEFUyGxuJfwqGZAEx53q3IOgNJWDjYSmlwRjvkMt2i2Yrez3pzBijwHMVbQ GQy7cTjZJUu9vDlCOppWe2jZ3J1lp6utx9q1O4bcpjfG0bpGjcKfX2RBcs6KAOPOCfBx Ghe0MrAzylsRRJpwb2euGn7y7zap+h+mfSPsqAbjGPO1cj35v9r9Yyys9faa4Xo6sBxG Q7QQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w16si181638oih.154.2019.12.09.09.06.04; Mon, 09 Dec 2019 09:06:16 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726847AbfLIRDz (ORCPT + 99 others); Mon, 9 Dec 2019 12:03:55 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37883 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726787AbfLIRDy (ORCPT ); Mon, 9 Dec 2019 12:03:54 -0500 Received: by mail-wr1-f66.google.com with SMTP id w15so17117688wru.4; Mon, 09 Dec 2019 09:03:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:reply-to:from :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=7QOUlkYUUcL9RJraaiKsihHk7jZjKK6PuheJk93ZnR8=; b=ctEOjv8hYW1/QL2SnxSD7+hHIKBNiMHTop+gaLx5eyNbx4ti9Pit40arXxbDgusB3P dOiAu0L9eNgHBH1hqDsDpQyl0hd0gEk9b+0Xhssne9CheyfgmUWV+hlQunTxwGBOa+Qf i9xRcfAhazyMkzeWzFLzhZ5uUrxe1Au/Fh5rpUsodcnupBInUb7/jewxaO4/KWHMXthu M62Y7g0WhDyG6BHYAkygS6qTL5bLYc6x1doUXFX6Vw1IfZgtSEaBPNCvNdkOtvLa/wB5 yAi2W9yrrBImkKJk/9LQJcLQvK2/qh3n7V0lxWQkpZdhqbyIoym4AbiczPM7UdezZUqy h6NQ== X-Gm-Message-State: APjAAAWSNAuIkdLCK0btiT1Au1PtgoNKvFnzbkegGlEHYQ3Qmaqw4ORw BmLfca3QO4I4ZplhLcLwNbs= X-Received: by 2002:a5d:5308:: with SMTP id e8mr3274981wrv.77.1575911032440; Mon, 09 Dec 2019 09:03:52 -0800 (PST) Received: from [10.10.2.174] (bran.ispras.ru. [83.149.199.196]) by smtp.gmail.com with ESMTPSA id j12sm78312wrw.54.2019.12.09.09.03.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 09 Dec 2019 09:03:51 -0800 (PST) Subject: Re: [PATCH v3] floppy: hide invalid floppy disk types To: =?UTF-8?Q?Moritz_M=c3=bcller?= , linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@i4.cs.fau.de Cc: "Philip K ." References: <20191209093258.14319-1-moritzm.mueller@posteo.de> Reply-To: efremov@linux.com From: Denis Efremov Message-ID: <6e2c358c-6cfb-88cd-7bc8-3d4c87bb85be@linux.com> Date: Mon, 9 Dec 2019 20:03:50 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 MIME-Version: 1.0 In-Reply-To: <20191209093258.14319-1-moritzm.mueller@posteo.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On 12/9/19 12:32 PM, Moritz Müller wrote: > 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 Thank you for the patch! Have you tested your patch with FLOPPY_ALLOW_UNKNOWN_TYPES and without FLOPPY_ALLOW_UNKNOWN_TYPES? I will answer about motivation for this change in V2 branch of the patch. > --- > 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; Maybe just skip the else branch completely here? This will omit snprintf, following if (name) block and UDP update. +#ifdef CONFIG_FLOPPY_ALLOW_UNKNOWN_TYPES params = &default_drive_params[0].params; snprintf(temparea, sizeof(temparea), "unknown type %d (usb?)", type); name = temparea; +#else + continue; +#endif > @@ -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; > } > > Thanks, Denis