Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Jul 2010 15:49:05 +0400
From:      Andrey Zonov <andrey.zonov@gmail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: How change process flags from userland?
Message-ID:  <AANLkTik5-O1UDrunEps0x5TAxtpnLYvAzob9Xw_nguxd@mail.gmail.com>
In-Reply-To: <4C2AE37C.5060000@gmail.com>
References:  <4C2AE37C.5060000@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

I resolve this problem (thanks Julian Elischer for his thoughts):

===
    int fd;
    int cnt;
    off_t off;
    void *p;
    kvm_t *kd;
    struct kinfo_proc *kip;
    struct proc *p_mmap;

    kd = kvm_open(NULL, _PATH_MEM, NULL, O_RDONLY, NULL);
    kip = kvm_getprocs(kd, KERN_PROC_PID, pid, &cnt);
    fd = open(_PATH_KMEM, O_RDWR, 0);
    off = (off_t)((uintptr_t)kip->ki_paddr);
    p = mmap(0, sizeof(struct proc), PROT_READ | PROT_WRITE,
MAP_SHARED, fd, off);
    p_mmap = (struct proc *)p;
    p_mmap->p_flag |= P_PROTECTED;
...
===

I wrote daemon [1] that set P_PROTECTED flag for applications. May be
it useful for someone.

[1] http://zonov.pp.ru/pprotectd/pprotectd.tbz

-- 
Andrey Zonov

2010/6/30 Andrey Zonov <andrey.zonov@gmail.com>:
> Hi,
>
> I want to set P_PROTECTED flag for some daemons after it start, without
> patching application and kernel.
> It possible?



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTik5-O1UDrunEps0x5TAxtpnLYvAzob9Xw_nguxd>