Skip to content
Permalink
Browse files

Merge branch 'floppy'

Merge floppy ioctl verification fixes from Denis Efremov.

This also marks the floppy driver as orphaned - it turns out that Jiri
no longer has working hardware.

Actual working physical floppy hardware is getting hard to find, and
while Willy was able to test this, I think the driver can be considered
pretty much dead from an actual hardware standpoint.  The hardware that
is still sold seems to be mainly USB-based, which doesn't use this
legacy driver at all.

The old floppy disk controller is still emulated in various VM
environments, so the driver isn't going away, but let's see if anybody
is interested to step up to maintain it.

The lack of hardware also likely means that the ioctl range verification
fixes are probably mostly relevant to anybody using floppies in a
virtual environment.  Which is probably also going away in favor of USB
storage emulation, but who knows.

Will Decon reviewed the patches but I'm not rebasing them just for that,
so I'll add a

  Reviewed-by: Will Deacon <will@kernel.org>

here instead.

* floppy:
  MAINTAINERS: mark floppy.c orphaned
  floppy: fix out-of-bounds read in copy_buffer
  floppy: fix invalid pointer dereference in drive_name
  floppy: fix out-of-bounds read in next_valid_format
  floppy: fix div-by-zero in setup_format_params
  • Loading branch information...
torvalds committed Jul 18, 2019
2 parents 22051d9 + be2ece4 commit 47d6a7607443ea43dbc4d0f371bf773540a8f8f4
Showing with 34 additions and 5 deletions.
  1. +2 −3 MAINTAINERS
  2. +32 −2 drivers/block/floppy.c
@@ -6321,9 +6321,8 @@ F: Documentation/devicetree/bindings/counter/ftm-quaddec.txt
F: drivers/counter/ftm-quaddec.c

FLOPPY DRIVER
M: Jiri Kosina <jikos@kernel.org>
T: git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/floppy.git
S: Odd fixes
S: Orphan
L: linux-block@vger.kernel.org
F: drivers/block/floppy.c

FMC SUBSYSTEM
@@ -2120,6 +2120,9 @@ static void setup_format_params(int track)
raw_cmd->kernel_data = floppy_track_buffer;
raw_cmd->length = 4 * F_SECT_PER_TRACK;

if (!F_SECT_PER_TRACK)
return;

/* allow for about 30ms for data transport per track */
head_shift = (F_SECT_PER_TRACK + 5) / 6;

@@ -3230,8 +3233,12 @@ static int set_geometry(unsigned int cmd, struct floppy_struct *g,
int cnt;

/* sanity checking for parameters. */
if (g->sect <= 0 ||
g->head <= 0 ||
if ((int)g->sect <= 0 ||
(int)g->head <= 0 ||
/* check for overflow in max_sector */
(int)(g->sect * g->head) <= 0 ||
/* check for zero in F_SECT_PER_TRACK */
(unsigned char)((g->sect << 2) >> FD_SIZECODE(g)) == 0 ||
g->track <= 0 || g->track > UDP->tracks >> STRETCH(g) ||
/* check if reserved bits are set */
(g->stretch & ~(FD_STRETCH | FD_SWAPSIDES | FD_SECTBASEMASK)) != 0)
@@ -3375,6 +3382,24 @@ static int fd_getgeo(struct block_device *bdev, struct hd_geometry *geo)
return 0;
}

static bool valid_floppy_drive_params(const short autodetect[8],
int native_format)
{
size_t floppy_type_size = ARRAY_SIZE(floppy_type);
size_t i = 0;

for (i = 0; i < 8; ++i) {
if (autodetect[i] < 0 ||
autodetect[i] >= floppy_type_size)
return false;
}

if (native_format < 0 || native_format >= floppy_type_size)
return false;

return true;
}

static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int cmd,
unsigned long param)
{
@@ -3501,6 +3526,9 @@ static int fd_locked_ioctl(struct block_device *bdev, fmode_t mode, unsigned int
SUPBOUND(size, strlen((const char *)outparam) + 1);
break;
case FDSETDRVPRM:
if (!valid_floppy_drive_params(inparam.dp.autodetect,
inparam.dp.native_format))
return -EINVAL;
*UDP = inparam.dp;
break;
case FDGETDRVPRM:
@@ -3698,6 +3726,8 @@ static int compat_setdrvprm(int drive,
return -EPERM;
if (copy_from_user(&v, arg, sizeof(struct compat_floppy_drive_params)))
return -EFAULT;
if (!valid_floppy_drive_params(v.autodetect, v.native_format))
return -EINVAL;
mutex_lock(&floppy_mutex);
UDP->cmos = v.cmos;
UDP->max_dtr = v.max_dtr;

28 comments on commit 47d6a76

@starhawk64

This comment has been minimized.

Copy link

replied Jul 26, 2019

I have at least one 720k 3.5" 34pin floppy drive and one 5.25" 1.2k floppy drive, although I would need to test them first... a 1440k 3.5" working drive would not be hard to scrounge up, either.

I would be happy to send them to your friend Jiri for cost of shipping (sorry, I can't cover that myself... I am of extremely limited financial means) to help continue this effort. I also have some floppy/HDD controller cards that may be of use, although all are ISA-16 interface, not PCI...

If you (or he) wants to get in touch with me, my email address is found by replacing 'star' with 'laser' in my username here, and appending Google's usual email service to the other end.

As an aside... I still have (and it still works) my first computer, and it's remarkably similar in spec to the machine you had at around the same time (c.1994 for me, about a year earlier for you, IIRC) that started it all... funny how that works.

@gigatexal

This comment has been minimized.

Copy link

replied Jul 27, 2019

I’ll spot you on the shipping costs provided it’s not exorbitant— that said what’s the audience here? Does anyone know how many people use a physical floppy drive aka what’s the impact of this?

@hackman

This comment has been minimized.

Copy link

replied Jul 27, 2019

there are still, old boxes that do boot from floppy drives.
I think I can find a PCI controller for the drives and send 3.5' and 5.25' anywhere.

@kisik21

This comment has been minimized.

Copy link

replied Jul 28, 2019

I have a 1.44M 3.5" floppy drive in my old x86 machine (and it seems to work!) but I don't wanna part with it 😭

@zoobab

This comment has been minimized.

Copy link

replied Jul 28, 2019

I have many IDE floppy drives, if Jiri wants some.

@JoonasD6

This comment has been minimized.

Copy link

replied Jul 28, 2019

Can also send a drive or two, but it's understandable the driver probably doesn't need much development any longer.

@gjyoung

This comment has been minimized.

Copy link

replied Jul 28, 2019

NOOOOOOOO!!! Now what will i use for swap space!! :)

@zboszor

This comment has been minimized.

Copy link

replied Jul 28, 2019

I have a 3" Amstrad drive that works with an adaptor ribbon cable on a PC so I can occasionally write ZX Spectrum +3 DSK images to real disks using http://www.seasip.info/Unix/LibDsk/ - obscure use case but works nicely with Linux...

@strongholdmedia

This comment has been minimized.

Copy link

replied Jul 28, 2019

I have many IDE floppy drives, if Jiri wants some.

..pardon, but what?
IIRC FDD controllers use a 34-pin interface with a twist. :P (P unintended)
You instead mean a real IDE (that is, 40 pin) interface?

@starhawk64

This comment has been minimized.

Copy link

replied Jul 28, 2019

@Palladini

This comment has been minimized.

Copy link

replied Jul 28, 2019

I have built several computers in the past 3 years, an none of them have a floppy disk unit in them, although a couple of them had 2 DVD drives in them, and the latest computer I built has no DVD drive, because I built that computer for NAS use only And every one of them Computers has a Version of Linux Mint running on it

@starhawk64

This comment has been minimized.

Copy link

replied Jul 28, 2019

@goshhhy

This comment has been minimized.

Copy link

replied Jul 29, 2019

thanks for this, i actually ran into these issues the other day and was trying to debug them.
i think a lot more people than most realise use old hardware like this, but tend not to go to upstream projects for support as we retrocomputing enthusiasts are often scoffed at when we do so.

@starhawk64

This comment has been minimized.

Copy link

replied Jul 29, 2019

@sruggier

This comment has been minimized.

Copy link

replied Jul 29, 2019

@starhawk64 "To this day" may be a bit of an exaggeration:

$ apt-cache policy xserver-xorg-video-openchrome
xserver-xorg-video-openchrome:
  Installed: 1:0.5.0-3
  Candidate: 1:0.5.0-3
  Version table:
     1:0.6.0-3+b1 103
        103 https://deb.debian.org/debian buster/main amd64 Packages
        102 https://deb.debian.org/debian testing/main amd64 Packages
        101 https://deb.debian.org/debian unstable/main amd64 Packages
 *** 1:0.5.0-3 500
        500 https://deb.debian.org/debian stretch/main amd64 Packages
        100 /var/lib/dpkg/status

If a bug exists in both Debian and Ubuntu, go to Debian first. They really are the upstream for Ubuntu, and updates to Debian packages will automatically propagate to the latest Ubuntu version in a few months, depending on where in the Ubuntu release cycle the update happens.

@starhawk64

This comment has been minimized.

Copy link

replied Jul 29, 2019

@zakmackraken

This comment has been minimized.

Copy link

replied Jul 29, 2019

Jesus Christ! Tell Jiri to post a hackerspace address to send him/her a working floppy drive for free so he/she can pick it up from there. Else if he/she is on Dallas area there is a huge warehouse liquidation of retro computers called "Computer Reset", there will find a ton of old floppies. At https://www.facebook.com/groups/627459117730981/ can find the opening schedule.

@cpcbegin

This comment has been minimized.

Copy link

replied Jul 30, 2019

I still use 3.5" DD floppy disk to transfer info between my PC (with internal drive) and my Amstrad CPC, USB floppy drive are much more limited as internal ones.

@X3NoMoRPH

This comment has been minimized.

Copy link

replied Jul 30, 2019

I still use 3.5" DD floppy disk too !!

@Sauraus

This comment has been minimized.

Copy link

replied Jul 30, 2019

I've got one of those 8" monsters sitting around collecting dust... 😇

@chusiang

This comment has been minimized.

Copy link

replied Aug 1, 2019

Wow, when I beginning the GNU/Linux at the university, I used the CD and USB Flash Disk, so I have not use the floppy on GNU/Linux yet. 😆

Linus Torvalds:已無開發人員維護 Linux 軟碟機驅動程式 | iThome

@zoomer296

This comment has been minimized.

Copy link

replied Aug 1, 2019

I have all the necessary hardware if somebody needs it.

@trevorgale

This comment has been minimized.

Copy link

replied Aug 2, 2019

I'm an R.F. design engineer, use several computers for various developments - most of them with a floppy drive or more. PLEASE KEEP the Linix drivers for the internal drives - there are more people using these than one might realise, since most are not "computer whizzes" but use reliable and safe systems (e.g. Linux boxen) for many tasks.

@sruggier

This comment has been minimized.

Copy link

replied Aug 2, 2019

I don't think it's fair to ask a maintainer to keep working on something for free at the time they've decided to step down. It might be reasonable to reach out to him directly and offer to ship him floppy hardware for free, but from the commit description, it sounds like he's done.

The driver isn't going to disappear overnight. If it breaks in the future, you can report bugs and offer to test fixes, and that might be enough to keep it working in the future.

@jwich71

This comment has been minimized.

Copy link

replied Aug 7, 2019

Yes, floppy drives are history! But there are still many historical computers out there that are maintained and kept alive by enthusiastic people. For these people Linux is the ideal platform to transfer images to floppy disks.
Please don't let the retro computer scene hang and don't let the old computers die.

@goshhhy

This comment has been minimized.

Copy link

replied Aug 7, 2019

and it's not just enthusiasts - computers with floppy drives are still heavily used in industrial and scientific applications.

@trevorgale

This comment has been minimized.

Copy link

replied Aug 7, 2019

goshhhy: this is very true - and many of these machines with working and used floppy drives aren't just in corners of universities or small dedicated companies - they are out there in outfits such as NASA, ESA, aerospace companies, pharmaceutical concerns, as well as other research organisations. Many of the applications using these systems and their floppy drives simply cannot be practically transported to other systems with different storage media such as USB sticks. I'm not suggesting we go back to using feather quills and ink to write our reports on vellum, just to keep the ability to use pen and paper.

@LarryLynnmail

This comment has been minimized.

Copy link

replied Sep 2, 2019

I have lots of floppy disks. If Jiri need, I can it to him.

Please sign in to comment.
You can’t perform that action at this time.