~n-muench/ubuntu/precise/open-vm-tools/open-vm-tools.raring-precise.backport

« back to all changes in this revision

Viewing changes to modules/linux/vmci/common/vmciCommonInt.h

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2011-03-31 14:20:05 UTC
  • mfrom: (1.4.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110331142005-3n9red91p7ogkweo
Tags: 2011.03.28-387002-0ubuntu1
* Merge latest upstream git tag.  This has the unlocked_ioctl change
  needed to fix dkms build failures (LP: #727342)
* Changes in debian/rules:
  - work around a bug in toolbox/Makefile, where install-exec-hook is
    not happening.  This needs to get fixed the right way.
  - don't install 'vmware-user' which seems to no longer exist
  - move /etc/xdg into open-vm-toolbox (which should be done using .install)
* debian/open-vm-tools.init: add 'modprobe [-r] vmblock'. (LP: #332323)
* debian/rules and debian/open-vm-toolbox.lintian-overrides:
  - Make vmware-user-suid-wrapper suid-root (LP: #332323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*********************************************************
 
2
 * Copyright (C) 2006 VMware, Inc. All rights reserved.
 
3
 *
 
4
 * This program is free software; you can redistribute it and/or modify it
 
5
 * under the terms of the GNU General Public License as published by the
 
6
 * Free Software Foundation version 2 and no later version.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful, but
 
9
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 
10
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 
11
 * for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU General Public License along
 
14
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
15
 * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
16
 *
 
17
 *********************************************************/
 
18
 
 
19
/*
 
20
 * vmciCommonInt.h --
 
21
 *
 
22
 * Struct definitions for VMCI internal common code.
 
23
 */
 
24
 
 
25
#ifndef _VMCI_COMMONINT_H_
 
26
#define _VMCI_COMMONINT_H_
 
27
 
 
28
#define INCLUDE_ALLOW_MODULE
 
29
#define INCLUDE_ALLOW_VMMON
 
30
#define INCLUDE_ALLOW_VMCORE
 
31
#define INCLUDE_ALLOW_VMKERNEL
 
32
#include "includeCheck.h"
 
33
 
 
34
#include "vm_atomic.h"
 
35
#include "vmci_defs.h"
 
36
#include "vmci_call_defs.h"
 
37
#include "vmci_infrastructure.h"
 
38
#include "vmci_handle_array.h"
 
39
#include "vmci_kernel_if.h"
 
40
 
 
41
 
 
42
/*
 
43
 *  The DatagramQueueEntry is a queue header for the in-kernel VMCI
 
44
 *  datagram queues. It is allocated in non-paged memory, as the
 
45
 *  content is accessed while holding a spinlock. The pending datagram
 
46
 *  itself may be allocated from paged memory. We shadow the size of
 
47
 *  the datagram in the non-paged queue entry as this size is used
 
48
 *  while holding the same spinlock as above.
 
49
 */
 
50
 
 
51
typedef struct DatagramQueueEntry {
 
52
   VMCIListItem   listItem;  /* For queuing. */
 
53
   size_t         dgSize;    /* Size of datagram. */
 
54
   VMCIDatagram   *dg;       /* Pending datagram. */
 
55
} DatagramQueueEntry;
 
56
 
 
57
 
 
58
struct VMCIContext {
 
59
   VMCIListItem       listItem;         /* For global VMCI list. */
 
60
   VMCIId             cid;
 
61
   Atomic_uint32      refCount;
 
62
   VMCIList           datagramQueue;    /* Head of per VM queue. */
 
63
   uint32             pendingDatagrams;
 
64
   size_t             datagramQueueSize;/* Size of datagram queue in bytes. */
 
65
   int                userVersion;      /*
 
66
                                         * Version of the code that created
 
67
                                         * this context; e.g., VMX.
 
68
                                         */
 
69
   VMCILock           lock;             /* Locks callQueue and handleArrays. */
 
70
   VMCIHandleArray    *wellKnownArray;  /* WellKnown mappings owned by context. */
 
71
   VMCIHandleArray    *queuePairArray;  /*
 
72
                                         * QueuePairs attached to.  The array of
 
73
                                         * handles for queue pairs is accessed
 
74
                                         * from the code for QP API, and there
 
75
                                         * it is protected by the QP lock.  It
 
76
                                         * is also accessed from the context
 
77
                                         * clean up path, which does not
 
78
                                         * require a lock.  VMCILock is not
 
79
                                         * used to protect the QP array field.
 
80
                                         */
 
81
   VMCIHandleArray    *doorbellArray;   /* Doorbells created by context. */
 
82
   VMCIHandleArray    *pendingDoorbellArray; /* Doorbells pending for context. */
 
83
   VMCIHandleArray    *notifierArray;   /* Contexts current context is subscribing to. */
 
84
   VMCIHost           hostContext;
 
85
   VMCIPrivilegeFlags privFlags;
 
86
   VMCIHostUser       user;
 
87
   Bool               validUser;
 
88
#ifdef VMKERNEL
 
89
   char               domainName[VMCI_DOMAIN_NAME_MAXLEN];
 
90
   Bool               isQuiesced;       /* Whether current VM is quiesced */
 
91
   VMCIId             migrateCid;       /* The migrate cid if it is migrating */
 
92
#endif
 
93
#ifndef VMX86_SERVER
 
94
   Bool               *notify;          /* Notify flag pointer - hosted only. */
 
95
#  ifdef __linux__
 
96
   struct page        *notifyPage;      /* Page backing the notify UVA. */
 
97
#  endif
 
98
#endif
 
99
};
 
100
 
 
101
 
 
102
/*
 
103
 *------------------------------------------------------------------------------
 
104
 *
 
105
 *  VMCIDenyInteraction --
 
106
 *
 
107
 *     Utilility function that checks whether two entities are allowed
 
108
 *     to interact. If one of them is restricted, the other one must
 
109
 *     be trusted. On ESX, the vmci domain must match for unrestricted
 
110
 *     domains.
 
111
 *
 
112
 *  Result:
 
113
 *     TRUE if the two entities are not allowed to interact. FALSE otherwise.
 
114
 *
 
115
 *  Side effects:
 
116
 *     None.
 
117
 *
 
118
 *------------------------------------------------------------------------------
 
119
 */
 
120
 
 
121
static INLINE Bool
 
122
VMCIDenyInteraction(VMCIPrivilegeFlags partOne,  // IN
 
123
                    VMCIPrivilegeFlags partTwo,  // IN
 
124
                    const char *srcDomain,       // IN:  Unused on hosted
 
125
                    const char *dstDomain)       // IN:  Unused on hosted
 
126
{
 
127
#ifndef VMKERNEL
 
128
   return (((partOne & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
 
129
            !(partTwo & VMCI_PRIVILEGE_FLAG_TRUSTED)) ||
 
130
           ((partTwo & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
 
131
            !(partOne & VMCI_PRIVILEGE_FLAG_TRUSTED)));
 
132
#else
 
133
   /*
 
134
    * If source or destination is trusted (hypervisor), we allow the
 
135
    * communication.
 
136
    */
 
137
   if ((partOne & VMCI_PRIVILEGE_FLAG_TRUSTED) ||
 
138
       (partTwo & VMCI_PRIVILEGE_FLAG_TRUSTED)) {
 
139
      return FALSE;
 
140
   }
 
141
   /*
 
142
    * If source or destination is restricted, we deny the communication.
 
143
    */
 
144
   if ((partOne & VMCI_PRIVILEGE_FLAG_RESTRICTED) ||
 
145
       (partTwo & VMCI_PRIVILEGE_FLAG_RESTRICTED)) {
 
146
      return TRUE;
 
147
   }
 
148
   /*
 
149
    * We are here, means that neither of source or destination are trusted, and
 
150
    * both are unrestricted.
 
151
    */
 
152
   ASSERT(!(partOne & VMCI_PRIVILEGE_FLAG_TRUSTED) &&
 
153
          !(partTwo & VMCI_PRIVILEGE_FLAG_TRUSTED));
 
154
   ASSERT(!(partOne & VMCI_PRIVILEGE_FLAG_RESTRICTED) &&
 
155
          !(partTwo & VMCI_PRIVILEGE_FLAG_RESTRICTED));
 
156
   /*
 
157
    * We now compare the source and destination domain names, and allow
 
158
    * communication iff they match.
 
159
    */
 
160
   return strcmp(srcDomain, dstDomain) ? TRUE : /* Deny. */
 
161
                                         FALSE; /* Allow. */
 
162
#endif
 
163
}
 
164
 
 
165
#endif /* _VMCI_COMMONINT_H_ */