[haiku-commits] haiku: hrev53233 - src/system/kernel/debug src/kits/storage src/system/kernel src/kits/app headers/private/kernel

  • From: waddlesplash <waddlesplash@xxxxxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Thu, 4 Jul 2019 17:00:52 -0400 (EDT)

hrev53233 adds 5 changesets to branch 'master'
old head: 45dcac89df2410054cfb4cbf0a8d246412b7929d
new head: 05901d8963c69b695c9796289213a307cd714afb
overview: 
https://git.haiku-os.org/haiku/log/?qt=range&q=05901d8963c6+%5E45dcac89df24

----------------------------------------------------------------------------

ebb0db62d1a4: kits: Only export private dummy copy constructors for R5 ABI.
  
  Fixes #546 (after all these years!)

6f6cba7c1684: kernel/system_profiler: Do not allow non-root users access.
  
  The single-team profiler can still be used without root access.
  Part of #14961.

a90e9ba7b9cd: kernel/team: Create a team_get_team_struct() function and utilize 
it.
  
  Cleans up some lock/get/unlock sequences, and makes it possible
  for external consumers to get team structs (which will be necessary
  for permissions checks.)

6f0aa00c6be7: kernel/user_debugger: Add missing permissions checks.
  
  Part of #14961.

05901d8963c6: kernel/cpu: Only root can enable or disable CPUs.

                              [ Augustin Cavalier <waddlesplash@xxxxxxxxx> ]

----------------------------------------------------------------------------

12 files changed, 70 insertions(+), 26 deletions(-)
headers/private/kernel/team.h               |  1 +
src/kits/app/Application.cpp                | 16 ++++++++-------
src/kits/app/Handler.cpp                    | 27 ++++++++++++-------------
src/kits/app/Looper.cpp                     |  2 ++
src/kits/app/MessageRunner.cpp              |  2 ++
src/kits/storage/AppFileInfo.cpp            |  6 ++++--
src/kits/storage/MimeType.cpp               |  4 +++-
src/kits/storage/NodeInfo.cpp               |  2 ++
src/system/kernel/cpu.cpp                   |  2 ++
src/system/kernel/debug/system_profiler.cpp | 12 +++++++++++
src/system/kernel/debug/user_debugger.cpp   | 12 +++++++++++
src/system/kernel/team.cpp                  | 10 +++++++--

############################################################################

Commit:      ebb0db62d1a40407f10f4537439be4c7256dfcde
URL:         https://git.haiku-os.org/haiku/commit/?id=ebb0db62d1a4
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Jul  4 19:24:23 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/546

kits: Only export private dummy copy constructors for R5 ABI.

Fixes #546 (after all these years!)

----------------------------------------------------------------------------

diff --git a/src/kits/app/Application.cpp b/src/kits/app/Application.cpp
index 4ceddb847f..d116fa60be 100644
--- a/src/kits/app/Application.cpp
+++ b/src/kits/app/Application.cpp
@@ -291,6 +291,7 @@ BApplication::BApplication(BMessage* data)
 }
 
 
+#ifdef _BEOS_R5_COMPATIBLE_
 BApplication::BApplication(uint32 signature)
 {
 }
@@ -301,6 +302,14 @@ BApplication::BApplication(const BApplication &rhs)
 }
 
 
+BApplication&
+BApplication::operator=(const BApplication &rhs)
+{
+       return *this;
+}
+#endif
+
+
 BApplication::~BApplication()
 {
        Lock();
@@ -340,13 +349,6 @@ BApplication::~BApplication()
 }
 
 
-BApplication&
-BApplication::operator=(const BApplication &rhs)
-{
-       return *this;
-}
-
-
 void
 BApplication::_InitData(const char* signature, bool initGUI, status_t* _error)
 {
diff --git a/src/kits/app/Handler.cpp b/src/kits/app/Handler.cpp
index 72f4b38368..c0547e5677 100644
--- a/src/kits/app/Handler.cpp
+++ b/src/kits/app/Handler.cpp
@@ -642,20 +642,6 @@ BHandler::_ObserverList()
 }
 
 
-BHandler::BHandler(const BHandler &)
-{
-       // No copy construction allowed.
-}
-
-
-BHandler &
-BHandler::operator=(const BHandler &)
-{
-       // No assignments allowed.
-       return *this;
-}
-
-
 void
 BHandler::SetLooper(BLooper* looper)
 {
@@ -682,6 +668,19 @@ _ReservedHandler1__8BHandler(BHandler* handler, uint32 
what,
        handler->BHandler::SendNotices(what, notice);
 }
 
+
+BHandler::BHandler(const BHandler &)
+{
+       // No copy construction allowed.
+}
+
+
+BHandler &
+BHandler::operator=(const BHandler &)
+{
+       // No assignments allowed.
+       return *this;
+}
 #endif
 
 void BHandler::_ReservedHandler2() {}
diff --git a/src/kits/app/Looper.cpp b/src/kits/app/Looper.cpp
index 80086fc1f3..e10f684385 100644
--- a/src/kits/app/Looper.cpp
+++ b/src/kits/app/Looper.cpp
@@ -832,6 +832,7 @@ void BLooper::_ReservedLooper5() {}
 void BLooper::_ReservedLooper6() {}
 
 
+#ifdef _BEOS_R5_COMPATIBLE_
 BLooper::BLooper(const BLooper& other)
 {
        // Copy construction not allowed
@@ -844,6 +845,7 @@ BLooper::operator=(const BLooper& other)
        // Looper copying not allowed
        return *this;
 }
+#endif
 
 
 BLooper::BLooper(int32 priority, port_id port, const char* name)
diff --git a/src/kits/app/MessageRunner.cpp b/src/kits/app/MessageRunner.cpp
index 4a982a47bb..be3f71d484 100644
--- a/src/kits/app/MessageRunner.cpp
+++ b/src/kits/app/MessageRunner.cpp
@@ -168,6 +168,7 @@ void BMessageRunner::_ReservedMessageRunner5() {}
 void BMessageRunner::_ReservedMessageRunner6() {}
 
 
+#ifdef _BEOS_R5_COMPATIBLE_
 //! Privatized copy constructor to prevent usage.
 BMessageRunner::BMessageRunner(const BMessageRunner &)
        :
@@ -182,6 +183,7 @@ BMessageRunner::operator=(const BMessageRunner&)
 {
        return* this;
 }
+#endif
 
 
 /*!    Initializes the BMessageRunner.
diff --git a/src/kits/storage/AppFileInfo.cpp b/src/kits/storage/AppFileInfo.cpp
index f111a582cc..fa8b9425aa 100644
--- a/src/kits/storage/AppFileInfo.cpp
+++ b/src/kits/storage/AppFileInfo.cpp
@@ -65,7 +65,7 @@ static const int32 kIconForTypeResourceID             = 0;
 static const int32 kCatalogEntryResourceID             = 1;
 
 // R5 also exports these (Tracker is using them):
-// (maybe we better want to drop them silently and declare 
+// (maybe we better want to drop them silently and declare
 // the above in a public Haiku header - and use that one in
 // Tracker when compiled for Haiku)
 extern const uint32 MINI_ICON_TYPE, LARGE_ICON_TYPE;
@@ -578,7 +578,7 @@ BAppFileInfo::GetVersionInfo(version_info* info, 
version_kind kind) const
        } else
                return B_ERROR;
 
-       // return result        
+       // return result
        return B_OK;
 }
 
@@ -958,6 +958,7 @@ void BAppFileInfo::_ReservedAppFileInfo2() {}
 void BAppFileInfo::_ReservedAppFileInfo3() {}
 
 
+#ifdef _BEOS_R5_COMPATIBLE_
 //!    Privatized assignment operator to prevent usage.
 BAppFileInfo&
 BAppFileInfo::operator=(const BAppFileInfo&)
@@ -970,6 +971,7 @@ BAppFileInfo::operator=(const BAppFileInfo&)
 BAppFileInfo::BAppFileInfo(const BAppFileInfo&)
 {
 }
+#endif
 
 
 /*!    Initializes a BMimeType to the signature of the associated file.
diff --git a/src/kits/storage/MimeType.cpp b/src/kits/storage/MimeType.cpp
index d03b4d06b2..8dd7a53709 100644
--- a/src/kits/storage/MimeType.cpp
+++ b/src/kits/storage/MimeType.cpp
@@ -1200,6 +1200,7 @@ void BMimeType::_ReservedMimeType2() {}
 void BMimeType::_ReservedMimeType3() {}
 
 
+#ifdef _BEOS_R5_COMPATIBLE_
 // assignment operator.
 // Unimplemented
 BMimeType&
@@ -1215,6 +1216,7 @@ BMimeType::operator=(const BMimeType &)
 BMimeType::BMimeType(const BMimeType &)
 {
 }
+#endif
 
 
 status_t
@@ -1240,7 +1242,7 @@ BMimeType::GetSupportedTypes(BMessage* types)
        \c B_STRING_TYPE in \a types.
 
        For each supported type the result of BMimeType::GetSupportingApps() 
will
-       afterwards include the signature of this application. 
+       afterwards include the signature of this application.
 
        \a fullSync specifies whether or not any types that are no longer
        listed as supported types as of this call to SetSupportedTypes() shall 
be
diff --git a/src/kits/storage/NodeInfo.cpp b/src/kits/storage/NodeInfo.cpp
index 97837b2959..aebb00b658 100644
--- a/src/kits/storage/NodeInfo.cpp
+++ b/src/kits/storage/NodeInfo.cpp
@@ -608,6 +608,7 @@ void BNodeInfo::_ReservedNodeInfo2() {}
 void BNodeInfo::_ReservedNodeInfo3() {}
 
 
+#ifdef _BEOS_R5_COMPATIBLE_
 /*!    Assignment operator is declared private to prevent it from being created
        automatically by the compiler.
 */
@@ -624,3 +625,4 @@ BNodeInfo::operator=(const BNodeInfo &nodeInfo)
 BNodeInfo::BNodeInfo(const BNodeInfo &)
 {
 }
+#endif

############################################################################

Commit:      6f6cba7c1684c794778d5af259c2410c1a3a18b0
URL:         https://git.haiku-os.org/haiku/commit/?id=6f6cba7c1684
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Jul  4 20:41:36 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/14961

kernel/system_profiler: Do not allow non-root users access.

The single-team profiler can still be used without root access.
Part of #14961.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/debug/system_profiler.cpp 
b/src/system/kernel/debug/system_profiler.cpp
index 4902ec7d95..bab5d10b02 100644
--- a/src/system/kernel/debug/system_profiler.cpp
+++ b/src/system/kernel/debug/system_profiler.cpp
@@ -1543,6 +1543,9 @@ stop_system_profiler()
 status_t
 _user_system_profiler_start(struct system_profiler_parameters* userParameters)
 {
+       if (geteuid() != 0)
+               return B_PERMISSION_DENIED;
+
        // copy params to the kernel
        struct system_profiler_parameters parameters;
        if (userParameters == NULL || !IS_USER_ADDRESS(userParameters)
@@ -1606,6 +1609,9 @@ _user_system_profiler_start(struct 
system_profiler_parameters* userParameters)
 status_t
 _user_system_profiler_next_buffer(size_t bytesRead, uint64* _droppedEvents)
 {
+       if (geteuid() != 0)
+               return B_PERMISSION_DENIED;
+
        if (_droppedEvents != NULL && !IS_USER_ADDRESS(_droppedEvents))
                return B_BAD_ADDRESS;
 
@@ -1633,6 +1639,9 @@ _user_system_profiler_next_buffer(size_t bytesRead, 
uint64* _droppedEvents)
 status_t
 _user_system_profiler_stop()
 {
+       if (geteuid() != 0)
+               return B_PERMISSION_DENIED;
+
        team_id team = thread_get_current_thread()->team->id;
 
        InterruptsSpinLocker locker(sProfilerLock);
@@ -1652,6 +1661,9 @@ _user_system_profiler_stop()
 status_t
 _user_system_profiler_recorded(system_profiler_parameters* userParameters)
 {
+       if (geteuid() != 0)
+               return B_PERMISSION_DENIED;
+
        if (userParameters == NULL || !IS_USER_ADDRESS(userParameters))
                return B_BAD_ADDRESS;
        if (sRecordedParameters == NULL)

############################################################################

Commit:      a90e9ba7b9cd11c9996cf38a844a02269854204f
URL:         https://git.haiku-os.org/haiku/commit/?id=a90e9ba7b9cd
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Jul  4 20:47:36 2019 UTC

kernel/team: Create a team_get_team_struct() function and utilize it.

Cleans up some lock/get/unlock sequences, and makes it possible
for external consumers to get team structs (which will be necessary
for permissions checks.)

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/team.h b/headers/private/kernel/team.h
index e376409f75..87bbab6e67 100644
--- a/headers/private/kernel/team.h
+++ b/headers/private/kernel/team.h
@@ -38,6 +38,7 @@ struct job_control_entry* team_get_death_entry(Team *team,
                        thread_id child, bool* _deleteEntry);
 void team_init_exit_info_on_error(Team* team);
 bool team_is_valid(team_id id);
+Team *team_get_team_struct(team_id id);
 Team *team_get_team_struct_locked(team_id id);
 int32 team_max_teams(void);
 int32 team_used_teams(void);
diff --git a/src/system/kernel/team.cpp b/src/system/kernel/team.cpp
index 15cb73f653..a3fb03b484 100644
--- a/src/system/kernel/team.cpp
+++ b/src/system/kernel/team.cpp
@@ -2918,9 +2918,15 @@ team_is_valid(team_id id)
        if (id <= 0)
                return false;
 
-       InterruptsReadSpinLocker teamsLocker(sTeamHashLock);
+       return team_get_team_struct(id) != NULL;
+}
+
 
-       return team_get_team_struct_locked(id) != NULL;
+Team*
+team_get_team_struct(team_id id)
+{
+       InterruptsReadSpinLocker teamsLocker(sTeamHashLock);
+       return team_get_team_struct_locked(id);
 }
 
 

############################################################################

Commit:      6f0aa00c6be763a5e0d95fb8e55a19a080101cbd
URL:         https://git.haiku-os.org/haiku/commit/?id=6f0aa00c6be7
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Jul  4 20:50:17 2019 UTC

Ticket:      https://dev.haiku-os.org/ticket/14961

kernel/user_debugger: Add missing permissions checks.

Part of #14961.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/debug/user_debugger.cpp 
b/src/system/kernel/debug/user_debugger.cpp
index f541adb04b..d20b2102cc 100644
--- a/src/system/kernel/debug/user_debugger.cpp
+++ b/src/system/kernel/debug/user_debugger.cpp
@@ -2834,6 +2834,10 @@ _user_disable_debugger(int state)
 status_t
 _user_install_default_debugger(port_id debuggerPort)
 {
+       // Do not allow non-root processes to install a default debugger.
+       if (geteuid() != 0)
+               return B_PERMISSION_DENIED;
+
        // if supplied, check whether the port is a valid port
        if (debuggerPort >= 0) {
                port_info portInfo;
@@ -2855,6 +2859,14 @@ _user_install_default_debugger(port_id debuggerPort)
 port_id
 _user_install_team_debugger(team_id teamID, port_id debuggerPort)
 {
+       if (geteuid() != 0) {
+               Team* team = team_get_team_struct(teamID);
+               if (team == NULL)
+                       return B_BAD_VALUE;
+               if (team->effective_uid != geteuid())
+                       return B_PERMISSION_DENIED;
+       }
+
        return install_team_debugger(teamID, debuggerPort, -1, false, false);
 }
 

############################################################################

Revision:    hrev53233
Commit:      05901d8963c69b695c9796289213a307cd714afb
URL:         https://git.haiku-os.org/haiku/commit/?id=05901d8963c6
Author:      Augustin Cavalier <waddlesplash@xxxxxxxxx>
Date:        Thu Jul  4 21:00:28 2019 UTC

kernel/cpu: Only root can enable or disable CPUs.

----------------------------------------------------------------------------

diff --git a/src/system/kernel/cpu.cpp b/src/system/kernel/cpu.cpp
index a3da117269..519b05eb2a 100644
--- a/src/system/kernel/cpu.cpp
+++ b/src/system/kernel/cpu.cpp
@@ -367,6 +367,8 @@ _user_set_cpu_enabled(int32 cpu, bool enabled)
 {
        int32 i, count;
 
+       if (geteuid() != 0)
+               return B_PERMISSION_DENIED;
        if (cpu < 0 || cpu >= smp_get_num_cpus())
                return B_BAD_VALUE;
 


Other related posts: