Changeset 66427 in vbox
- Timestamp:
- Apr 5, 2017 10:38:48 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/linux/rtStrFormatKernelAddress-r0drv-linux.c
r66426 r66427 31 31 #define LOG_GROUP RTLOGGROUP_STRING 32 32 #include "the-linux-kernel.h" 33 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38)34 # include <linux/capability.h>35 # include <linux/security.h>36 #endif37 33 #include "internal/iprt.h" 38 34 … … 47 43 { 48 44 #if !defined(DEBUG) && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) 49 bool fRestrict = true; 50 #if 0 51 if (kptr_restrict > 1) 52 fRestrict = true; 53 else if (kptr_restrict == 1) 54 { 55 const struct cred *cred = current_cred(); 56 if ( !has_capability_noaudit(current, CAP_SYSLOG) 57 # if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 13, 0) 58 || !uid_eq(cred->euid, cred->uid) 59 || !gid_eq(cred->egid, cred->gid) 60 # endif 61 ) 62 fRestrict = true; 63 } 64 #endif 65 66 if (fRestrict) 67 { 68 RT_NOREF(uPtr, cchWidth, cchPrecision); 69 # if R0_ARCH_BITS == 64 70 static const char s_szObfuscated[] = "0xXXXXXXXXXXXXXXXX"; 71 # else 72 static const char s_szObfuscated[] = "0xXXXXXXXX"; 73 # endif 74 size_t cbSrc = sizeof(s_szObfuscated); 75 const char *pszSrc = s_szObfuscated; 76 if (!(fFlags & RTSTR_F_SPECIAL)) 77 { 78 pszSrc += 2; 79 cbSrc -= 2; 80 } 81 if (cbSrc <= cbBuf) 82 { 83 memcpy(pszBuf, pszSrc, cbSrc); 84 return cbSrc; 85 } 86 AssertFailed(); 87 memcpy(pszBuf, pszSrc, cbBuf); 88 pszBuf[cbBuf - 1] = '\0'; 89 return cbBuf - 1; 90 } 91 #endif /* DEBUG && LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 38) */ 45 RT_NOREF(cchWidth, cchPrecision); 46 /* use the Linux kernel function which is able to handle "%pK" */ 47 static const char s_szFmt[] = "0x%pK"; 48 const char *pszFmt = s_szFmt; 49 if (!(fFlags & RTSTR_F_SPECIAL)) 50 pszFmt += 2; 51 return snprintf(pszBuf, cbBuf, pszFmt, uPtr); 52 #else 92 53 Assert(cbBuf >= 64); 93 54 return RTStrFormatNumber(pszBuf, uPtr, 16, cchWidth, cchPrecision, fFlags); 55 #endif 94 56 }
Note:
See TracChangeset
for help on using the changeset viewer.