On Wed, Sep 28, 2016 at 02:22:00PM +0200, Sebastien Marie wrote:
> Hi,
> 
> With a -current from this morning, I have this in my logs:
> 
> Sep 28 12:27:37 flynn console-kit-daemon[1113]: WARNING: kvm_openfiles 
> failed: /dev/mem: Operation not permitted
> Sep 28 12:28:30 flynn last message repeated 12 times
> 
> It seems that sysutils/consolekit try to play with /dev/mem via kvm(3)
> interface, and since the introduction of kern.allowkmem it isn't
> possible anymore by default.
> 
> Looking at source code, console-kit use only kvm_getenvv(3) function.
> 
> As this function is available via kvm(3) for alive kernel (using sysctl
> variant), this diff below (untested, sorry) change kvm_openfiles(3) flag
> from O_RDONLY to KVM_NO_FILES.

Thanks Sebastien. I'll try and have a look once I have a bit more time on my 
hand...


> 
> Thanks.
> -- 
> Sebastien Marie
> 
> 
> Index: Makefile
> ===================================================================
> RCS file: /cvs/ports/sysutils/consolekit/Makefile,v
> retrieving revision 1.58
> diff -u -p -r1.58 Makefile
> --- Makefile  19 Mar 2016 17:51:34 -0000      1.58
> +++ Makefile  28 Sep 2016 12:11:52 -0000
> @@ -8,6 +8,8 @@ GH_TAGNAME=           1.0.2
>  GH_ACCOUNT=          ConsoleKit2
>  GH_PROJECT=          ConsoleKit2
>  
> +REVISION=            0
> +
>  CATEGORIES=          sysutils        
>  
>  SHARED_LIBS +=  ck-connector         1.1      # 0.0
> Index: patches/patch-src_ck-sysdeps-openbsd_c
> ===================================================================
> RCS file: patches/patch-src_ck-sysdeps-openbsd_c
> diff -N patches/patch-src_ck-sysdeps-openbsd_c
> --- /dev/null 1 Jan 1970 00:00:00 -0000
> +++ patches/patch-src_ck-sysdeps-openbsd_c    28 Sep 2016 12:11:52 -0000
> @@ -0,0 +1,13 @@
> +$OpenBSD$
> +No need to open /dev/mem to use kvm_getenvv(3) on live kernel.
> +--- src/ck-sysdeps-openbsd.c.orig    Wed Sep 28 14:08:07 2016
> ++++ src/ck-sysdeps-openbsd.c Wed Sep 28 14:08:09 2016
> +@@ -248,7 +248,7 @@ ck_unix_pid_get_env_hash (pid_t pid)
> +         struct kinfo_proc p;
> +         int               i;
> + 
> +-        kd = kvm_openfiles (NULL, NULL, NULL, O_RDONLY, errbuf);
> ++        kd = kvm_openfiles (NULL, NULL, NULL, KVM_NO_FILES, errbuf);
> +         if (kd == NULL) {
> +             g_warning ("kvm_openfiles failed: %s", errbuf);
> +                 return NULL;

-- 
Antoine

Reply via email to