LCOV - code coverage report
Current view: directory - src/trusted/platform_qualify/linux - nacl_os_qualify.c (source / functions) Found Hit Coverage
Test: coverage.lcov Lines: 15 7 46.7 %
Date: 2014-07-02 Functions: 0 0 -

       1                 : /*
       2                 :  * Copyright (c) 2012 The Native Client Authors. All rights reserved.
       3                 :  * Use of this source code is governed by a BSD-style license that can be
       4                 :  * found in the LICENSE file.
       5                 :  */
       6                 : 
       7                 : #include <string.h>
       8                 : #include <sys/utsname.h>
       9                 : 
      10                 : #include "native_client/src/shared/platform/nacl_log.h"
      11                 : #include "native_client/src/trusted/platform_qualify/kernel_version.h"
      12                 : #include "native_client/src/trusted/platform_qualify/nacl_os_qualify.h"
      13                 : 
      14                 : 
      15                 : #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32
      16                 : 
      17                 : static const char *kMinimumVersion = "2.6.27";
      18                 : 
      19                 : /*
      20                 :  * Checks for this bug:
      21                 :  * http://code.google.com/p/nativeclient/issues/detail?id=2032
      22                 :  */
      23             285 : static int NaClModifyLdtHasProblems(const char *version) {
      24                 :   int res;
      25             285 :   if (!NaClCompareKernelVersions(version, kMinimumVersion, &res)) {
      26               0 :     NaClLog(LOG_ERROR, "NaClModifyLdtHasProblems: "
      27                 :             "Couldn't parse kernel version: %s\n", version);
      28               0 :     return 1;
      29                 :   }
      30             285 :   return res < 0;
      31                 : }
      32                 : 
      33                 : #endif
      34                 : 
      35                 : /*
      36                 :  * Returns 1 if the operating system can run Native Client modules.
      37                 :  */
      38             285 : int NaClOsIsSupported(void) {
      39                 : #if NACL_ARCH(NACL_BUILD_ARCH) == NACL_x86 && NACL_BUILD_SUBARCH == 32
      40                 :   struct utsname info;
      41             285 :   if (uname(&info) != 0) {
      42               0 :     NaClLog(LOG_ERROR, "NaClOsIsSupported: uname() failed\n");
      43               0 :     return 0;
      44                 :   }
      45             285 :   if (NaClModifyLdtHasProblems(info.release)) {
      46               0 :     NaClLog(LOG_ERROR, "NaClOsIsSupported: This system is running an "
      47                 :             "old Linux kernel. This kernel version is buggy and "
      48                 :             "Native Client's x86-32 sandbox might be insecure on "
      49                 :             "this kernel. The fix is to upgrade the kernel to v2.6.27 "
      50                 :             "or later, or, as a workaround, to switch using a 64-bit "
      51                 :             "Native Client sandbox. For more information, see "
      52                 :             "http://code.google.com/p/nativeclient/issues/detail?id=2032\n");
      53               0 :     return 0;
      54                 :   }
      55                 : #endif
      56                 : 
      57             285 :   return 1;
      58                 : }
      59                 : 
      60                 : 
      61                 : /*
      62                 :  * Returns 1 if the operating system is a 64-bit version of
      63                 :  * Windows.  For now, all of these versions are not supported.
      64                 :  */
      65               0 : int NaClOsIs64BitWindows(void) {
      66               0 :   return 0;
      67                 : }

Generated by: LCOV version 1.7