https://bugs.kde.org/show_bug.cgi?id=506929

--- Comment #2 from Mark Wielaard <m...@klomp.org> ---
All the syswrap-<arch>-linux.c wiring seems correct.

Removing the mips specific wrapper seems correct too.

> +PRE(sys_sysfs)                                                               
> +{                                                                            
> +   FUSE_COMPATIBLE_MAY_BLOCK();                                              
> +   switch (ARG1) {                                                           
> +      case 1:                                                                
> +         PRINT("sys_sysfs ( %lu, %lu )", ARG1, ARG2);                        
> +         PRE_REG_READ2(long, "sysfs", int, flags, const void *, path);       
> +         break;

I think your want a PRE_MEM_RASCIIZ("sysfs(path)", ARG2) here to check path
points to a defined string.

> +      case 2:                                                                
> +         PRINT("sys_sysfs ( %lu, %lu, %#" FMT_REGWORD "x )",                 
> +               ARG1, ARG2, ARG3);                                            
> +         PRE_REG_READ3(long, "sysfs", int, flags, int, desc, void *, path);  
> +         break;

As you note below we don't know how big the path is or should be.
But at least one byte should be writable. So maybe add
PRE_MEM_WRITE("sysfs(path)", ARG3, 1) ?

> +      case 3:                                                                
> +         PRINT("sys_sysfs ( %lu )", ARG1);                                   
> +         PRE_REG_READ1(long, "sysfs", int, flags);                           
> +         break;                                                              
> +      default:                                                               
> +         if (VG_(clo_verbosity) >= 1) {                                      
> +            VG_(message)(Vg_DebugMsg,                                        
> +               "WARNING: unhandled sysfs option %lu\n", ARG1);               
> +         }                                                                   
> +         break;                                                              
> +   }                                                                         
> +}                                                                            

Ack.

> +vki_size_t my_strlen(const char *s);                                         
> +vki_size_t my_strlen(const char *s) {                                        
> +    vki_size_t len = 0;                                                      
> +    while (s[len] != '\0') {                                                 
> +        len++;                                                               
> +    }                                                                        
> +    return len;                                                              
> +}                                                                            

We already have VG_(strlen) see include/pub_tool_libcbase.h for some
"standalone libc stuff".

> +POST(sys_sysfs)                                                              
> +{                                                                            
> +   if (ARG1 == 2) {                                                          
> +      // For option 2, getting the fsname, there is no way to know how big 
> the buffer needs to be.                                                       
>    
> +      POST_MEM_WRITE(ARG3, my_strlen((void *)ARG3));                         
> +   }                                                                         
> +}                                                                            
> +                                                                             

Right. This should work (use VG_(strlen) here) because the POST handler is only
called when the syscall succeeds.
So marking that range of memory as being defined should be fine. Otherwise the
syscall would have failed with EFAULT.

> diff --git a/include/vki/vki-scnums-32bit-linux.h b/include/vki/vki-scnums-32\
bit-linux.h                                                                     
> index f276ddaed..9fa6b6183 100644                                             
> --- a/include/vki/vki-scnums-32bit-linux.h                                    
> +++ b/include/vki/vki-scnums-32bit-linux.h                                    
> @@ -25,6 +25,7 @@                                                             
>  // Derived from the __BITS_PER_LONG == 32 sections in                        
>  // linux-5.2/include/uapi/asm-generic/unistd.h                               
>                                                                               
> +#define __NR_sysfs   135                                                     
>  #define __NR_clock_gettime64 403                                             
>  #define __NR_clock_settime64 404                                             
>  #define __NR_clock_adjtime64 405                                             

I think this bit is wrong. It looks like __NR_sysfs is already defined for all
32bit linux arches in their include/vki/vki-scnums-<arch>-linux.h file. So
redefining it in vki-scnums-32bit-linux.h will clash on 32bit arches.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to