[PATCH] hdparm: "Bad address" fix

John Brandwood john at telzey.com
Sat Jan 12 15:33:42 PST 2008


Sorry for the double-post, I'm trying to get Outlook to send the attachment
correctly.

---

Hi, guys. This is my first post, so please let me know if I'm doing this
wrong.

There seems to be a bug in the current busybox "hdparm" applet.

Here is an example of the problem ...

	root at linux:/usr/src/busybox-1.8.2/_install/bin# ./busybox hdparm
/dev/hda

	/dev/hda:
	 multcount      =  0 (off)
	 IO_support     =  0 (default 16-bit)
	hdparm: HDIO_GET_UNMASKINTR: Bad address
	 using_dma      =  1 (on)
	hdparm: HDIO_GET_KEEPSETTINGS: Bad address
	hdparm: BLKROGET: Bad address
	hdparm: BLKRAGET: Bad address
	 geometry       = 30515/255/63, sectors = 490234752, start = 0

I’ve tracked it down to a bunch of calls in miscutils/hdparm.c like ...

	if(!ioctl_or_warn(fd, HDIO_GET_UNMASKINTR, (unsigned long *)parm))

instead of ...

	if(!ioctl_or_warn(fd, HDIO_GET_UNMASKINTR, &parm))

I've patched all the suspect function calls, and now get the proper result
...

	root at linux:/usr/src/busybox-1.8.2/_install/bin# ./busybox hdparm
/dev/hda

	/dev/hda:
	 multcount      =  0 (off)
	 IO_support     =  0 (default 16-bit)
	 unmaskirq      =  0 (off)
	 using_dma      =  1 (on)
	 keepsettings   =  0 (off)
	 readonly       =  0 (off)
	 readahead      = 256 (on)
	 geometry       = 30515/255/63, sectors = 490234752, start = 0

I've looked back as far as the busybox 1.6.2 release, and the problem goes
back at least that long.

I'm attaching a patch that works for the 1.7.4, 1.8.2, 1.9.0 and current
source trees.

The problem also appears in the 1.6.2 source, but the source code changes in
miscutils/hdparm.c between 1.6.2 and 1.7 were too great for the patch to
apply successfully.

Thanks,

John Brandwood


No virus found in this outgoing message.
Checked by AVG Free Edition. 
Version: 7.5.516 / Virus Database: 269.19.2/1221 - Release Date: 1/12/2008
2:04 PM
 
  
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hdparm.patch.txt
Url: http://busybox.net/lists/busybox/attachments/20080112/a37fbbc4/attachment.txt 


More information about the busybox mailing list