Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 472766 - media-gfx/imagemagick[opencl]: sandbox violation at /dev/dri/card* in executables linked to imagemagick and opencl libraries
Summary: media-gfx/imagemagick[opencl]: sandbox violation at /dev/dri/card* in executa...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] KDE (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Gentoo Graphics Project
URL:
Whiteboard: was: media-plugins/kipi-plugins-3.2.0...
Keywords:
: 472688 482976 485422 490457 505490 (view as bug list)
Depends on:
Blocks:
 
Reported: 2013-06-09 18:12 UTC by Jason Lamb
Modified: 2016-09-29 00:44 UTC (History)
10 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build log (kipi-plugins-3.2.0-build.log,15.07 KB, text/plain)
2013-06-09 18:12 UTC, Jason Lamb
Details
sandbox log (kipi-plugins-3.2.0-sandbox.log,407 bytes, text/plain)
2013-06-09 18:13 UTC, Jason Lamb
Details
emerge --info (emerge-info.log,6.20 KB, text/plain)
2013-06-09 18:13 UTC, Jason Lamb
Details
imagemagick-6.8.5.4 build log (imagemagick-6.8.5.4-build.log,931.38 KB, text/plain)
2013-06-13 18:06 UTC, Jason Lamb
Details
imagemagick-6.8.5.4 sandbox log (imagemagick-6.8.5.4-sandbox.log,817 bytes, text/plain)
2013-06-13 18:06 UTC, Jason Lamb
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Lamb 2013-06-09 18:12:25 UTC
emerging media-plugins/kipi-plugins-3.2.0 fails right after the source configure phase with a sandbox access violation in /dev/dri/card0
Comment 1 Jason Lamb 2013-06-09 18:12:46 UTC
Created attachment 350546 [details]
build log
Comment 2 Jason Lamb 2013-06-09 18:13:00 UTC
Created attachment 350548 [details]
sandbox log
Comment 3 Jason Lamb 2013-06-09 18:13:15 UTC
Created attachment 350550 [details]
emerge --info
Comment 4 Andreas K. Hüttel archtester gentoo-dev 2013-06-09 19:18:38 UTC
Which version of media-gfx/imagemagick do you have?
What use-flags are set on imagemagick?
Comment 5 Jason Lamb 2013-06-09 20:59:57 UTC
media-gfx/imagemagick-6.8.5.4  USE="X bzip2 corefonts cxx djvu fontconfig graphviz jpeg jpeg2k lcms opencl openmp pango perl png postscript svg tiff truetype wmf xml zlib -autotrace -fftw -fpx -hdri -jbig -lqr -lzma -openexr -q32 -q64 -q8 -raw -static-libs {-test} -webp"
Comment 6 Andreas K. Hüttel archtester gentoo-dev 2013-06-09 21:25:50 UTC
(In reply to Jason Lamb from comment #5)
> media-gfx/imagemagick-6.8.5.4  USE="X bzip2 corefonts cxx djvu fontconfig
> graphviz jpeg jpeg2k lcms opencl openmp pango perl png postscript svg tiff
> truetype wmf xml zlib -autotrace -fftw -fpx -hdri -jbig -lqr -lzma -openexr
> -q32 -q64 -q8 -raw -static-libs {-test} -webp"

OK right as I suspected, opencl. This will be fun. No idea yet how to handle it.

Could you please also add the output of "eselect opencl list" ?
Comment 7 Jason Lamb 2013-06-09 22:08:32 UTC
eselect opencl list
Available OpenCL implementations:
  [1]   mesa *


FWIW, I only added opencl support to my system because of the work devs had been doing to bring it to the open source radeon driver. Even though I only have one opencl app, bfgminer, (that I'm aware of), that can even work on my system, I thought it would be fun to experiment with.

I guess I don't know how likely you are to see this combination again, anytime soon..

Thanks..
Comment 8 Jason Lamb 2013-06-13 18:06:11 UTC
Created attachment 350904 [details]
imagemagick-6.8.5.4 build log

Including here because it's likely related. When attempting to emerge media-gfx/imagemagick-6.8.5.4 using the opencl flags also generates a sandbox violation by 'identify -list Configure' during the install phase in /dev/dri/card0
Comment 9 Jason Lamb 2013-06-13 18:06:35 UTC
Created attachment 350906 [details]
imagemagick-6.8.5.4 sandbox log
Comment 10 Torsten Kaiser 2013-09-06 09:38:40 UTC
imagemagick[opencl] behaves very strange...

Trying to upgrade from media-gfx/imagemagick-6.8.6.8 to media-gfx/imagemagick-6.8.6.8-r1 failed for me with the same sandbox violations as Jason Lamb has posted.

But even USE=-opencl emerge -1 imagemagick failed!
But unmerging the currently installed USE=opencl version and then emerging 6.8.6.8-r1 even with USE=opencl set did work!

It seems imagemagick is wrongly running the 'identify' tool from the currently installed version and that causes theses sandbox problems.

Note: I'm using media-libs/mesa-9.2.0 as my opencl provider. I have a radeon card and am only using its open source drivers. fglrx was never installed on that system.
Comment 11 Samuli Suominen (RETIRED) gentoo-dev 2013-09-19 20:09:50 UTC
*** Bug 485422 has been marked as a duplicate of this bug. ***
Comment 12 Samuli Suominen (RETIRED) gentoo-dev 2013-09-19 20:15:10 UTC
I guess I'll apply this hack in imagemagick's ebuild, but it doesn't solve the problem elsewhere than in imagemagick build:

shopt -s nullglob
cards=$(echo -n /dev/dri/card* | sed 's/ /:/g')
if test -n "${cards}"; then
       addpredict "${cards}"
fi
shopt -u nullglob
Comment 13 Alexey Shvetsov archtester gentoo-dev 2014-01-01 17:36:37 UTC
Same here
Comment 14 Johannes Huber (RETIRED) gentoo-dev 2014-03-19 16:40:54 UTC
How about to put opencl in use.mask for media-gfx/imagemagick?
Comment 15 Samuli Suominen (RETIRED) gentoo-dev 2014-03-19 17:11:21 UTC
(In reply to Johannes Huber from comment #14)
> How about to put opencl in use.mask for media-gfx/imagemagick?

but the problem is opencl implementation specific, I, for example, don't have the problem with nvidia drivers

how wide spread you think the problem is? i've seen /usr/bin/mogrify triggering it. i don't think use of mogrify in build systems is that common

so either apply the workaround from Comment #12 to the package using mogrify during build
or, move the workaround from Comment #12 to an opencl.eclass and call it a sandbox_disable_dri() or whatever
or provide complete solution that stops the mesa from trying to access the card's dri during the build? this used to not be a problem, what changed?
Comment 16 Samuli Suominen (RETIRED) gentoo-dev 2014-03-19 17:16:38 UTC
(In reply to Johannes Huber from comment #14)
> How about to put opencl in use.mask for media-gfx/imagemagick?

base/

+  19 Mar 2014; Samuli Suominen <ssuominen@gentoo.org> package.use.stable.mask:
+  Mask USE="opencl" for stable users of media-gfx/imagemagick wrt #472766

http://sources.gentoo.org/viewvc.cgi/gentoo-x86/profiles/base/package.use.stable.mask?r1=1.3&r2=1.4
Comment 17 Chí-Thanh Christopher Nguyễn gentoo-dev 2014-03-19 17:56:15 UTC
Is masking not a little too invasive? What happens if you "addpredict /dev/dri/card0"?
Comment 18 Samuli Suominen (RETIRED) gentoo-dev 2014-03-19 18:48:59 UTC
(In reply to Chí-Thanh Christopher Nguyễn from comment #17)
> Is masking not a little too invasive? What happens if you "addpredict
> /dev/dri/card0"?

that's what Comment #12 is about -- addpredict works, but you have to add it per package

so while eg. this bug was filed against kipi-plugins, i don't see the solution in kipi-plugins ebuild yet, and kipi-plugins is not the only package using mogrify (or some other executable) from imagemagick that triggers the same problem

so propably use this bug as a Tracker if the wanted solution is to apply the workaround to every affected package
Comment 19 Andreas K. Hüttel archtester gentoo-dev 2014-03-19 19:18:03 UTC
It's kinda pointless to add an openca-whatever eclass to any ebuild that uses imagemagick (or something else) as (indirect) dependency... :(

This is something that calls for a more global solution, like portage functionality (afaik sandbox is not in the scope of PMS, correct me if I'm wrong). I.e. define a file that generates addpredicts based on useflag settings.

Then again, this defines the purpose of the sandbox.
Comment 20 Dennis Schridde 2014-03-21 09:59:28 UTC
See-Also: bug #472688, bug #485422, bug #490457
Comment 21 Samuli Suominen (RETIRED) gentoo-dev 2014-04-02 09:58:14 UTC
Does this work for you guys?

/etc/sandbox.d/99imagemagick file with content of:

SANDBOX_PREDICT="/dev/dri/card*"

The main question here is that, I don't know if * wildcards are supported in the file format
Comment 22 Samuli Suominen (RETIRED) gentoo-dev 2014-04-02 09:58:43 UTC
*** Bug 490457 has been marked as a duplicate of this bug. ***
Comment 23 Samuli Suominen (RETIRED) gentoo-dev 2014-04-02 10:01:00 UTC
*** Bug 472688 has been marked as a duplicate of this bug. ***
Comment 24 Samuli Suominen (RETIRED) gentoo-dev 2014-04-02 14:34:19 UTC
It's "/dev/dri/card" and rest is filled up automatically by sandbox.

Should be fixed (well, workarounded) by version 6.8.8.10 in Portage now:

$ cat /etc/sandbox.d/99imagemagick 
SANDBOX_PREDICT="/dev/dri/card"

$ qfile -b 99imagemagick
media-gfx/imagemagick (/etc/sandbox.d/99imagemagick)

the file is installed only with USE=opencl

please test :)
Comment 25 Chí-Thanh Christopher Nguyễn gentoo-dev 2014-04-02 15:22:55 UTC
I think it would be better to create a tracker bug instead of marking the other opencl sandbox violation bugs as duplicates of this one.

Google reveals that imagemagick can be prevented from using opencl by setting MAGICK_OCL_DEVICE=OFF per http://www.imagemagick.org/script/opencl.php
Comment 26 Samuli Suominen (RETIRED) gentoo-dev 2014-04-02 15:26:04 UTC
(In reply to Chí-Thanh Christopher Nguyễn from comment #25)
> I think it would be better to create a tracker bug instead of marking the
> other opencl sandbox violation bugs as duplicates of this one.

To add duplicate solution to every package that happens to call imagemagick binaries, or other binaries that link to imagemagick's libraries?
That's propably hundreds of packages in the end. I don't like that idea, nor think it's the correct solution here.

> 
> Google reveals that imagemagick can be prevented from using opencl by
> setting MAGICK_OCL_DEVICE=OFF per
> http://www.imagemagick.org/script/opencl.php

That'd mean shipping a env.d file in ImageMagick that sets that, and then, it would affect also packages outside of Portage :/
Comment 27 Radoslaw Szkodzinski 2014-04-02 15:30:33 UTC
/dev/card/dri* in SANDBOX_PREDICT is highly unsafe - it is quite easy to get root access using 3D driver holes.

The environment variable could be set in make.globals or /etc/portage/env.
Comment 28 Samuli Suominen (RETIRED) gentoo-dev 2014-04-02 15:56:41 UTC
(In reply to Radoslaw Szkodzinski from comment #27)
> /dev/card/dri* in SANDBOX_PREDICT is highly unsafe - it is quite easy to get
> root access using 3D driver holes.
> 
> The environment variable could be set in make.globals or /etc/portage/env.

make.globals is for Portage's own settings, shipped with Portage itself
and /etc/portage/env is user-defined settings

and /dev/dri/card* is owned by root:video, so you'd have to be in the video group, and if you are in the video group, then you have access to the video device anyway, and sandbox doesn't increase the problem from that any
futher
Comment 29 Samuli Suominen (RETIRED) gentoo-dev 2014-04-02 15:57:42 UTC
and it's 'addpredict', not 'addwrite', that's used here
Comment 30 Radoslaw Szkodzinski 2014-04-03 14:19:36 UTC
Ah, right, sorry about the spam then.
Comment 31 Wojtek Arabczyk 2014-09-06 15:57:35 UTC
should also contain:

/dev/nvidiactl when using nvidia opencl library.

stumbled upon this just yesterday
Comment 32 Samuli Suominen (RETIRED) gentoo-dev 2014-09-17 13:55:54 UTC
(In reply to Wojtek Arabczyk from comment #31)
> should also contain:
> 
> /dev/nvidiactl when using nvidia opencl library.
> 
> stumbled upon this just yesterday

I've extended the workaround to /dev/nvidiactl in imagemagick-6.8.9.7's ebuild and up
Comment 33 Samuli Suominen (RETIRED) gentoo-dev 2014-09-17 13:56:27 UTC
*** Bug 482976 has been marked as a duplicate of this bug. ***
Comment 34 Samuli Suominen (RETIRED) gentoo-dev 2014-09-17 14:16:46 UTC
*** Bug 505490 has been marked as a duplicate of this bug. ***
Comment 35 Chris Larson 2016-09-29 00:44:31 UTC
I see that 'media-gfx/imagemagick opencl' is now stable across the board at 6.9.4.6, and yet remains in /usr/portage/profiles/base/package.use.stable.mask.

Has this issue not been addressed since media-gfx/imagemagick-6.8.5.4, or is it now time to remove the package.use.stable.mask entry?

Removing the mask on my machine and recompiling seems to go smoothly.