Skip to contentSkip to conversation

uselib, mincore and readahead syscalls

PATCH In review Riku Voipio 2 participants 4 messages Sep 17, 2008 – Sep 19, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uselib, mincore and readahead syscalls

These have been carried in Debian since forever. Added lock_user() calls for mincore before submitting, I'm not sure if that's the correct way?

Signature · 1 line
"rm -rf" only sounds scary if you don't have backups
linux-user/syscall.c +22 -3
Index: trunk/linux-user/syscall.c
===================================================================
@@ -276,6 +276,7 @@
 extern int setfsuid(int);
 extern int setfsgid(int);
 extern int setgroups(int, gid_t *);
+extern int uselib(const char*);
 
 #define ERRNO_TABLE_SIZE 1200
 
@@ -4226,7 +4227,13 @@
 #endif
 #ifdef TARGET_NR_uselib
     case TARGET_NR_uselib:
-        goto unimplemented;
+		{
+			if(!(p = lock_user_string(arg1)))
+				goto efault;
+        	ret = get_errno(uselib(path(p)));
+			unlock_user(p, arg1, 0);
+		}
+        break;
 #endif
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:
@@ -5512,7 +5519,18 @@
         goto unimplemented;
 #ifdef TARGET_NR_mincore
     case TARGET_NR_mincore:
-        goto unimplemented;
+		{
+			void *a;
+			if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
+            	goto efault;
+        	if (!(p = lock_user_string(arg3)))
+            	goto mincore_fail;
+        	ret = get_errno(mincore((void*)a, (size_t)arg2, (unsigned char*)p));
+			unlock_user(p, arg3, ret);
+			mincore_fail:
+			unlock_user(a, arg1, 0);
+		}
+        break;
 #endif
 #ifdef TARGET_NR_madvise
     case TARGET_NR_madvise:
@@ -5652,7 +5670,8 @@
         break;
 #ifdef TARGET_NR_readahead
     case TARGET_NR_readahead:
-        goto unimplemented;
+        ret = get_errno(readahead((int)arg1, (off64_t)arg2, (size_t)arg3));
+        break;
 #endif
 #ifdef TARGET_NR_setxattr
     case TARGET_NR_setxattr:
#1 lore raw
Quoted 8 lines · Riku Voipio

These have been carried in Debian since forever. Added lock_user() calls for mincore before submitting, I'm not sure if that's the correct way?

Signature · 1 line
"rm -rf" only sounds scary if you don't have backups

I think this patch should be splited by syscall.

linux-user/syscall.c line 279

Quoted 9 lines

Index: trunk/linux-user/syscall.c
===================================================================

linux-user/syscall.c +1 -0
@@ -276,6 +276,7 @@
 extern int setfsuid(int);
 extern int setfsgid(int);
 extern int setgroups(int, gid_t *);
+extern int uselib(const char*);

Probably, we should use _syscall1 macros instead.

Quoted 19 lines
linux-user/syscall.c +7 -1
 #define ERRNO_TABLE_SIZE 1200
 
@@ -4226,7 +4227,13 @@
 #endif
 #ifdef TARGET_NR_uselib
     case TARGET_NR_uselib:
-        goto unimplemented;
+		{
+			if(!(p = lock_user_string(arg1)))
+				goto efault;
+        	ret = get_errno(uselib(path(p)));
+			unlock_user(p, arg1, 0);
+		}
+        break;
 #endif
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:
@@ -5512,7 +5519,18 @@
         goto unimplemented;

linux-user/syscall.c line 5528

Quoted 10 lines
linux-user/syscall.c +7 -1
 #ifdef TARGET_NR_mincore
     case TARGET_NR_mincore:
-        goto unimplemented;
+		{
+			void *a;
+			if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
+            	goto efault;
+        	if (!(p = lock_user_string(arg3)))
+            	goto mincore_fail;
+        	ret = get_errno(mincore((void*)a, (size_t)arg2, (unsigned char*)p));

Type casting is unneeded here.

linux-user/syscall.c line 5531

Quoted 3 lines
linux-user/syscall.c +3 -0
+			unlock_user(p, arg3, ret);
+			mincore_fail:
+			unlock_user(a, arg1, 0);

You should set ret here.

linux-user/syscall.c line 5673

Quoted 11 lines
linux-user/syscall.c +3 -1
+		}
+        break;
 #endif
 #ifdef TARGET_NR_madvise
     case TARGET_NR_madvise:
@@ -5652,7 +5670,8 @@
         break;
 #ifdef TARGET_NR_readahead
     case TARGET_NR_readahead:
-        goto unimplemented;
+        ret = get_errno(readahead((int)arg1, (off64_t)arg2, (size_t)arg3));

Type casting is unneeded here.

Quoted 4 lines
linux-user/syscall.c +1 -0
+        break;
 #endif
 #ifdef TARGET_NR_setxattr
     case TARGET_NR_setxattr:
Signature · 3 lines
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/
#2 lore raw
Quoted 8 lines · Kirill A. Shutemov
Quoted 5 lines · Riku Voipio

These have been carried in Debian since forever. Added lock_user() calls for mincore before submitting, I'm not sure if that's the correct way?

I think this patch should be splited by syscall.

Yes, but expecting that these patches as going to be ignored I didn't want to put too much effort in them..

Quoted 11 lines

linux-user/syscall.c line 279

Quoted 9 lines

Index: trunk/linux-user/syscall.c
===================================================================

linux-user/syscall.c +1 -0
@@ -276,6 +276,7 @@
 extern int setfsuid(int);
 extern int setfsgid(int);
 extern int setgroups(int, gid_t *);
+extern int uselib(const char*);

Probably, we should use _syscall1 macros instead.

Why? More specifically, in which cases should we use _syscall macros and which cases the libc versions? I don't see much logic in the current mix of both being used in syscall.c

Quoted 23 lines
Quoted 23 lines
linux-user/syscall.c +8 -2
 #define ERRNO_TABLE_SIZE 1200
 
@@ -4226,7 +4227,13 @@
 #endif
 #ifdef TARGET_NR_uselib
     case TARGET_NR_uselib:
-        goto unimplemented;
+		{
+			if(!(p = lock_user_string(arg1)))
+				goto efault;
+        	ret = get_errno(uselib(path(p)));
+			unlock_user(p, arg1, 0);
+		}
+        break;
 #endif
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:
@@ -5512,7 +5519,18 @@
         goto unimplemented;
 #ifdef TARGET_NR_mincore
     case TARGET_NR_mincore:
-        goto unimplemented;
+		{
Quoted 8 lines

linux-user/syscall.c line 5528

Quoted 6 lines
linux-user/syscall.c +6 -0
+			void *a;
+			if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
+            	goto efault;
+        	if (!(p = lock_user_string(arg3)))
+            	goto mincore_fail;
+        	ret = get_errno(mincore((void*)a, (size_t)arg2, (unsigned char*)p));

Type casting is unneeded here.

Will fix

Quoted 5 lines

linux-user/syscall.c line 5531

Quoted 3 lines
linux-user/syscall.c +3 -0
+			unlock_user(p, arg3, ret);
+			mincore_fail:
+			unlock_user(a, arg1, 0);

You should set ret here.

Will fix

Quoted 5 lines
Quoted 5 lines
linux-user/syscall.c +2 -0
+		}
+        break;
 #endif
 #ifdef TARGET_NR_madvise
     case TARGET_NR_madvise:
Quoted 8 lines

linux-user/syscall.c line 5673

Quoted 6 lines
linux-user/syscall.c +1 -1
@@ -5652,7 +5670,8 @@
         break;
 #ifdef TARGET_NR_readahead
     case TARGET_NR_readahead:
-        goto unimplemented;
+        ret = get_errno(readahead((int)arg1, (off64_t)arg2, (size_t)arg3));

Type casting is unneeded here.

Will fix

Quoted 9 lines
Quoted 4 lines
linux-user/syscall.c +1 -0
+        break;
 #endif
 #ifdef TARGET_NR_setxattr
     case TARGET_NR_setxattr:
Signature · 3 lines
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/
Signature · 1 line
"rm -rf" only sounds scary if you don't have backups
#3 lore raw
Quoted 25 lines · Riku Voipio
Quoted 8 lines · Kirill A. Shutemov
Quoted 5 lines · Riku Voipio

These have been carried in Debian since forever. Added lock_user() calls for mincore before submitting, I'm not sure if that's the correct way?

I think this patch should be splited by syscall.

Yes, but expecting that these patches as going to be ignored I didn't want to put too much effort in them..

Quoted 11 lines

linux-user/syscall.c line 279

Quoted 9 lines

Index: trunk/linux-user/syscall.c
===================================================================

linux-user/syscall.c +1 -0
@@ -276,6 +276,7 @@
 extern int setfsuid(int);
 extern int setfsgid(int);
 extern int setgroups(int, gid_t *);
+extern int uselib(const char*);

Probably, we should use _syscall1 macros instead.

Quoted 3 lines

Why? More specifically, in which cases should we use _syscall macros and which cases the libc versions? I don't see much logic in the current mix of both being used in syscall.c

Sorry. I'm wrong.

Quoted 75 lines
Quoted 24 lines
Quoted 24 lines
linux-user/syscall.c +8 -2
 #define ERRNO_TABLE_SIZE 1200
 
@@ -4226,7 +4227,13 @@
 #endif
 #ifdef TARGET_NR_uselib
     case TARGET_NR_uselib:
-        goto unimplemented;
+		{
+			if(!(p = lock_user_string(arg1)))
+				goto efault;
+        	ret = get_errno(uselib(path(p)));
+			unlock_user(p, arg1, 0);
+		}
+        break;
 #endif
 #ifdef TARGET_NR_swapon
     case TARGET_NR_swapon:
@@ -5512,7 +5519,18 @@
         goto unimplemented;
 #ifdef TARGET_NR_mincore
     case TARGET_NR_mincore:
-        goto unimplemented;
+		{
Quoted 8 lines

linux-user/syscall.c line 5528

Quoted 6 lines
linux-user/syscall.c +6 -0
+			void *a;
+			if (!(a = lock_user(VERIFY_READ, arg1,arg2, 0)))
+            	goto efault;
+        	if (!(p = lock_user_string(arg3)))
+            	goto mincore_fail;
+        	ret = get_errno(mincore((void*)a, (size_t)arg2, (unsigned char*)p));

Type casting is unneeded here.

Will fix

Quoted 5 lines

linux-user/syscall.c line 5531

Quoted 3 lines
linux-user/syscall.c +3 -0
+			unlock_user(p, arg3, ret);
+			mincore_fail:
+			unlock_user(a, arg1, 0);

You should set ret here.

Will fix

Quoted 5 lines
Quoted 5 lines
linux-user/syscall.c +2 -0
+		}
+        break;
 #endif
 #ifdef TARGET_NR_madvise
     case TARGET_NR_madvise:
Quoted 8 lines

linux-user/syscall.c line 5673

Quoted 6 lines
linux-user/syscall.c +1 -1
@@ -5652,7 +5670,8 @@
         break;
 #ifdef TARGET_NR_readahead
     case TARGET_NR_readahead:
-        goto unimplemented;
+        ret = get_errno(readahead((int)arg1, (off64_t)arg2, (size_t)arg3));

Type casting is unneeded here.

Will fix

Quoted 9 lines
Quoted 4 lines
linux-user/syscall.c +1 -0
+        break;
 #endif
 #ifdef TARGET_NR_setxattr
     case TARGET_NR_setxattr:
Signature · 3 lines
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/
Signature · 1 line
"rm -rf" only sounds scary if you don't have backups
Signature · 3 lines
Regards,  Kirill A. Shutemov
 + Belarus, Minsk
 + ALT Linux Team, http://www.altlinux.com/