1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-04 09:09:56 +00:00

Introduce mac_check_system_settime(), a MAC check allowing policies to

augment the system policy for changing the system time.

Obtained from:	TrustedBSD Project
Sponsored by:	DARPA, Network Associates Laboratories
This commit is contained in:
Robert Watson 2002-11-03 02:39:42 +00:00
parent 62b693d7db
commit 4b8d5f2d97
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106369
14 changed files with 134 additions and 0 deletions

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -34,6 +34,8 @@
* $FreeBSD$
*/
#include "opt_mac.h"
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
@ -42,6 +44,7 @@
#include <sys/resourcevar.h>
#include <sys/signalvar.h>
#include <sys/kernel.h>
#include <sys/mac.h>
#include <sys/systm.h>
#include <sys/sysent.h>
#include <sys/proc.h>
@ -182,6 +185,11 @@ clock_settime(struct thread *td, struct clock_settime_args *uap)
struct timespec ats;
int error;
#ifdef MAC
error = mac_check_system_settime(td->td_ucred);
if (error)
return (error);
#endif
if ((error = suser(td)) != 0)
return (error);
if (SCARG(uap, clock_id) != CLOCK_REALTIME)
@ -351,6 +359,11 @@ settimeofday(struct thread *td, struct settimeofday_args *uap)
struct timezone atz;
int error = 0;
#ifdef MAC
error = mac_check_system_settime(td->td_ucred);
if (error)
return (error);
#endif
if ((error = suser(td)))
return (error);
/* Verify all parameters before changing time. */

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -255,6 +255,7 @@ int mac_check_socket_receive(struct ucred *cred, struct socket *so);
int mac_check_socket_send(struct ucred *cred, struct socket *so);
int mac_check_socket_visible(struct ucred *cred, struct socket *so);
int mac_check_system_reboot(struct ucred *cred, int howto);
int mac_check_system_settime(struct ucred *cred);
int mac_check_system_swapon(struct ucred *cred, struct vnode *vp);
int mac_check_system_sysctl(struct ucred *cred, int *name,
u_int namelen, void *old, size_t *oldlenp, int inkernel,

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -316,6 +316,7 @@ struct mac_policy_ops {
int (*mpo_check_socket_visible)(struct ucred *cred,
struct socket *so, struct label *socketlabel);
int (*mpo_check_system_reboot)(struct ucred *cred, int howto);
int (*mpo_check_system_settime)(struct ucred *cred);
int (*mpo_check_system_swapon)(struct ucred *cred,
struct vnode *vp, struct label *label);
int (*mpo_check_system_sysctl)(struct ucred *cred, int *name,

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -2491,6 +2491,19 @@ mac_check_system_reboot(struct ucred *cred, int howto)
return (error);
}
int
mac_check_system_settime(struct ucred *cred)
{
int error;
if (!mac_enforce_system)
return (0);
MAC_CHECK(check_system_settime, cred);
return (error);
}
int
mac_check_system_swapon(struct ucred *cred, struct vnode *vp)
{

View File

@ -255,6 +255,7 @@ int mac_check_socket_receive(struct ucred *cred, struct socket *so);
int mac_check_socket_send(struct ucred *cred, struct socket *so);
int mac_check_socket_visible(struct ucred *cred, struct socket *so);
int mac_check_system_reboot(struct ucred *cred, int howto);
int mac_check_system_settime(struct ucred *cred);
int mac_check_system_swapon(struct ucred *cred, struct vnode *vp);
int mac_check_system_sysctl(struct ucred *cred, int *name,
u_int namelen, void *old, size_t *oldlenp, int inkernel,

View File

@ -316,6 +316,7 @@ struct mac_policy_ops {
int (*mpo_check_socket_visible)(struct ucred *cred,
struct socket *so, struct label *socketlabel);
int (*mpo_check_system_reboot)(struct ucred *cred, int howto);
int (*mpo_check_system_settime)(struct ucred *cred);
int (*mpo_check_system_swapon)(struct ucred *cred,
struct vnode *vp, struct label *label);
int (*mpo_check_system_sysctl)(struct ucred *cred, int *name,