Skip to contentSkip to conversation

UML/man: BLKGETSIZE takes a long, not an int

PATCH In review Nicolas George 2 participants 4 messages Aug 13, 2007 – Aug 16, 2007 User-mode Linux (UML)

lore
Share & tools
lore
#0 lore raw

Hi.

I found a type mismatch in UML that makes host block devices unusable as ubd devices on x86_64 and other 64 bits systems (segfault of the mm subsystem):

In block/ioctl.c, the following lines show that the BLKGETSIZE ioctl expects a pointer to a long:

	case BLKGETSIZE:
		if ((bdev->bd_inode->i_size >> 9) > ~0UL)
			return -EFBIG;
		return put_ulong(arg, bdev->bd_inode->i_size >> 9);

In arch/um/os-Linux/file.c, os_file_size calls it with an int.

The ioctl_list man page should be fixed as well.

Regards,

Signature · 1 line
  Nicolas George
arch/um/os-Linux/file.c +2 -1
index 6f92f73..c3ecc2a 100644
@@ -320,7 +320,8 @@ int os_file_size(char *file, unsigned long long *size_out)
 	}
 
 	if(S_ISBLK(buf.ust_mode)){
-		int fd, blocks;
+		int fd;
+		long blocks;
 
 		fd = os_open_file(file, of_read(OPENFLAGS()), 0);
 		if(fd < 0){
#1 lore raw
Quoted 2 lines · Nicolas George

I found a type mismatch in UML that makes host block devices unusable as ubd devices on x86_64 and other 64 bits systems (segfault of the mm subsystem):

Looks sane, can I have a properly Signed-off-by: version of the patch?

Jeff

Signature · 1 line
Work email - jdike at linux dot intel dot com
#2 lore raw

PATCH 1/1 UML: BLKGETSIZE takes a long, not an int

The BLKGETSIZE ioctl expects a pointer to a long, os_file_size was providing an int. Therefore, ubd access to host block devices caused a segmentation fault on 64 bits systems.

---

Quoted 1 line · Jeff Dike

Looks sane, can I have a properly Signed-off-by: version of the patch?

Of course. I should have sent it correctly the first time. And I am terribly sorry for the mess my mailer have done with my second mail.

Here is the hopefully correct patch, against current git.

Regards.

arch/um/os-Linux/file.c +2 -1
index 6f92f73..c3ecc2a 100644
@@ -320,7 +320,8 @@ int os_file_size(char *file, unsigned long long *size_out)
 	}
 
 	if(S_ISBLK(buf.ust_mode)){
-		int fd, blocks;
+		int fd;
+		long blocks;
 
 		fd = os_open_file(file, of_read(OPENFLAGS()), 0);
 		if(fd < 0){

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
User-mode-linux-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

#3 lore raw

Re: [PATCH] UML: BLKGETSIZE takes a long, not an int

Quoted 1 line · Nicolas George

Here is the hopefully correct patch, against current git.

Thanks, I'll forward it upstream.

Jeff

Signature · 11 lines
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel