iopl() fails intermittently
I am working on a hardware device, where I have to do some GPIO operations.
At the start of my program, I invoke iopl(3)
. The executable is not root
owned, but has capabilities set - cap_sys_rawio+eip
. Though this works most of the times
sometimes the process fails with:
iopl: Operation not permitted
Is the capability insufficient ? I cannot run the program as root
.
The device is running Ubuntu 14.04.2
. dmesg
/ syslogs
are not giving
any hints!
More details:
The start of my main
has this:
if (iopl(3) != 0)
perror("iopl");
assert(!"Failed to set privilege!");
Though this works most of the times, sometimes on the hardware platform
(Intel Atom based), this fails with perror
printing iopl: Operation not permitted
.
ubuntu-14.04 system-calls
add a comment |
I am working on a hardware device, where I have to do some GPIO operations.
At the start of my program, I invoke iopl(3)
. The executable is not root
owned, but has capabilities set - cap_sys_rawio+eip
. Though this works most of the times
sometimes the process fails with:
iopl: Operation not permitted
Is the capability insufficient ? I cannot run the program as root
.
The device is running Ubuntu 14.04.2
. dmesg
/ syslogs
are not giving
any hints!
More details:
The start of my main
has this:
if (iopl(3) != 0)
perror("iopl");
assert(!"Failed to set privilege!");
Though this works most of the times, sometimes on the hardware platform
(Intel Atom based), this fails with perror
printing iopl: Operation not permitted
.
ubuntu-14.04 system-calls
Care to provide the code to reproduce the problem? Also, what architecture are you running?
– Ulrich Eckhardt
Nov 26 '18 at 8:30
My program main has:if (iopl(3) != 0) perror("iopl");
. I am not able to reproduce the issue at will! :( it happens some times and I am not getting any clue as to whyiopl
failed. This is intel Atom (Intel(R) Atom(TM) CPU C2558 @ 2.40GHz
) CPU. If you need any more details, please let me know.
– vyom
Nov 27 '18 at 3:55
Add the architecture and the code to your question, including amain()
and includes, to make the question more complete. One more think to look at would bestrace
. Capture its output and compare the error case to the non-error case. In particular, whether there are symptoms before theiopl()
-call. Other than that, I'm at a loss, too.
– Ulrich Eckhardt
Nov 27 '18 at 18:31
@UlrichEckhardt sure, if this happens again, willstrace
it
– vyom
Nov 28 '18 at 4:05
add a comment |
I am working on a hardware device, where I have to do some GPIO operations.
At the start of my program, I invoke iopl(3)
. The executable is not root
owned, but has capabilities set - cap_sys_rawio+eip
. Though this works most of the times
sometimes the process fails with:
iopl: Operation not permitted
Is the capability insufficient ? I cannot run the program as root
.
The device is running Ubuntu 14.04.2
. dmesg
/ syslogs
are not giving
any hints!
More details:
The start of my main
has this:
if (iopl(3) != 0)
perror("iopl");
assert(!"Failed to set privilege!");
Though this works most of the times, sometimes on the hardware platform
(Intel Atom based), this fails with perror
printing iopl: Operation not permitted
.
ubuntu-14.04 system-calls
I am working on a hardware device, where I have to do some GPIO operations.
At the start of my program, I invoke iopl(3)
. The executable is not root
owned, but has capabilities set - cap_sys_rawio+eip
. Though this works most of the times
sometimes the process fails with:
iopl: Operation not permitted
Is the capability insufficient ? I cannot run the program as root
.
The device is running Ubuntu 14.04.2
. dmesg
/ syslogs
are not giving
any hints!
More details:
The start of my main
has this:
if (iopl(3) != 0)
perror("iopl");
assert(!"Failed to set privilege!");
Though this works most of the times, sometimes on the hardware platform
(Intel Atom based), this fails with perror
printing iopl: Operation not permitted
.
ubuntu-14.04 system-calls
ubuntu-14.04 system-calls
edited Nov 28 '18 at 9:09
vyom
asked Nov 15 '18 at 5:16
vyomvyom
6651024
6651024
Care to provide the code to reproduce the problem? Also, what architecture are you running?
– Ulrich Eckhardt
Nov 26 '18 at 8:30
My program main has:if (iopl(3) != 0) perror("iopl");
. I am not able to reproduce the issue at will! :( it happens some times and I am not getting any clue as to whyiopl
failed. This is intel Atom (Intel(R) Atom(TM) CPU C2558 @ 2.40GHz
) CPU. If you need any more details, please let me know.
– vyom
Nov 27 '18 at 3:55
Add the architecture and the code to your question, including amain()
and includes, to make the question more complete. One more think to look at would bestrace
. Capture its output and compare the error case to the non-error case. In particular, whether there are symptoms before theiopl()
-call. Other than that, I'm at a loss, too.
– Ulrich Eckhardt
Nov 27 '18 at 18:31
@UlrichEckhardt sure, if this happens again, willstrace
it
– vyom
Nov 28 '18 at 4:05
add a comment |
Care to provide the code to reproduce the problem? Also, what architecture are you running?
– Ulrich Eckhardt
Nov 26 '18 at 8:30
My program main has:if (iopl(3) != 0) perror("iopl");
. I am not able to reproduce the issue at will! :( it happens some times and I am not getting any clue as to whyiopl
failed. This is intel Atom (Intel(R) Atom(TM) CPU C2558 @ 2.40GHz
) CPU. If you need any more details, please let me know.
– vyom
Nov 27 '18 at 3:55
Add the architecture and the code to your question, including amain()
and includes, to make the question more complete. One more think to look at would bestrace
. Capture its output and compare the error case to the non-error case. In particular, whether there are symptoms before theiopl()
-call. Other than that, I'm at a loss, too.
– Ulrich Eckhardt
Nov 27 '18 at 18:31
@UlrichEckhardt sure, if this happens again, willstrace
it
– vyom
Nov 28 '18 at 4:05
Care to provide the code to reproduce the problem? Also, what architecture are you running?
– Ulrich Eckhardt
Nov 26 '18 at 8:30
Care to provide the code to reproduce the problem? Also, what architecture are you running?
– Ulrich Eckhardt
Nov 26 '18 at 8:30
My program main has:
if (iopl(3) != 0) perror("iopl");
. I am not able to reproduce the issue at will! :( it happens some times and I am not getting any clue as to why iopl
failed. This is intel Atom (Intel(R) Atom(TM) CPU C2558 @ 2.40GHz
) CPU. If you need any more details, please let me know.– vyom
Nov 27 '18 at 3:55
My program main has:
if (iopl(3) != 0) perror("iopl");
. I am not able to reproduce the issue at will! :( it happens some times and I am not getting any clue as to why iopl
failed. This is intel Atom (Intel(R) Atom(TM) CPU C2558 @ 2.40GHz
) CPU. If you need any more details, please let me know.– vyom
Nov 27 '18 at 3:55
Add the architecture and the code to your question, including a
main()
and includes, to make the question more complete. One more think to look at would be strace
. Capture its output and compare the error case to the non-error case. In particular, whether there are symptoms before the iopl()
-call. Other than that, I'm at a loss, too.– Ulrich Eckhardt
Nov 27 '18 at 18:31
Add the architecture and the code to your question, including a
main()
and includes, to make the question more complete. One more think to look at would be strace
. Capture its output and compare the error case to the non-error case. In particular, whether there are symptoms before the iopl()
-call. Other than that, I'm at a loss, too.– Ulrich Eckhardt
Nov 27 '18 at 18:31
@UlrichEckhardt sure, if this happens again, will
strace
it– vyom
Nov 28 '18 at 4:05
@UlrichEckhardt sure, if this happens again, will
strace
it– vyom
Nov 28 '18 at 4:05
add a comment |
1 Answer
1
active
oldest
votes
Knowing that you cannot run the program as root, I am guessing if you have tried:
chmod u+s /usr/bin/xinit
or if you have root access,
sudo chmod u+s /usr/bin/xinit
If no setuid has been set (considering running without sudo --since you have already root access)
sudo chown root $prefix/Xorg
sudo chmod u+s $prefix/Xorg
Yes, the executable already has capabilities set, so it does not have to run as root
– vyom
Nov 27 '18 at 3:52
Is Xorg setuid to root?
– UnP
Nov 27 '18 at 7:01
I am not using Xorg at all. This is my own application, for which I am doing setcap and not suid root.
– vyom
Nov 28 '18 at 4:06
add a comment |
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312865%2fiopl-fails-intermittently%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Knowing that you cannot run the program as root, I am guessing if you have tried:
chmod u+s /usr/bin/xinit
or if you have root access,
sudo chmod u+s /usr/bin/xinit
If no setuid has been set (considering running without sudo --since you have already root access)
sudo chown root $prefix/Xorg
sudo chmod u+s $prefix/Xorg
Yes, the executable already has capabilities set, so it does not have to run as root
– vyom
Nov 27 '18 at 3:52
Is Xorg setuid to root?
– UnP
Nov 27 '18 at 7:01
I am not using Xorg at all. This is my own application, for which I am doing setcap and not suid root.
– vyom
Nov 28 '18 at 4:06
add a comment |
Knowing that you cannot run the program as root, I am guessing if you have tried:
chmod u+s /usr/bin/xinit
or if you have root access,
sudo chmod u+s /usr/bin/xinit
If no setuid has been set (considering running without sudo --since you have already root access)
sudo chown root $prefix/Xorg
sudo chmod u+s $prefix/Xorg
Yes, the executable already has capabilities set, so it does not have to run as root
– vyom
Nov 27 '18 at 3:52
Is Xorg setuid to root?
– UnP
Nov 27 '18 at 7:01
I am not using Xorg at all. This is my own application, for which I am doing setcap and not suid root.
– vyom
Nov 28 '18 at 4:06
add a comment |
Knowing that you cannot run the program as root, I am guessing if you have tried:
chmod u+s /usr/bin/xinit
or if you have root access,
sudo chmod u+s /usr/bin/xinit
If no setuid has been set (considering running without sudo --since you have already root access)
sudo chown root $prefix/Xorg
sudo chmod u+s $prefix/Xorg
Knowing that you cannot run the program as root, I am guessing if you have tried:
chmod u+s /usr/bin/xinit
or if you have root access,
sudo chmod u+s /usr/bin/xinit
If no setuid has been set (considering running without sudo --since you have already root access)
sudo chown root $prefix/Xorg
sudo chmod u+s $prefix/Xorg
edited Nov 27 '18 at 7:02
answered Nov 26 '18 at 8:17
UnPUnP
8111
8111
Yes, the executable already has capabilities set, so it does not have to run as root
– vyom
Nov 27 '18 at 3:52
Is Xorg setuid to root?
– UnP
Nov 27 '18 at 7:01
I am not using Xorg at all. This is my own application, for which I am doing setcap and not suid root.
– vyom
Nov 28 '18 at 4:06
add a comment |
Yes, the executable already has capabilities set, so it does not have to run as root
– vyom
Nov 27 '18 at 3:52
Is Xorg setuid to root?
– UnP
Nov 27 '18 at 7:01
I am not using Xorg at all. This is my own application, for which I am doing setcap and not suid root.
– vyom
Nov 28 '18 at 4:06
Yes, the executable already has capabilities set, so it does not have to run as root
– vyom
Nov 27 '18 at 3:52
Yes, the executable already has capabilities set, so it does not have to run as root
– vyom
Nov 27 '18 at 3:52
Is Xorg setuid to root?
– UnP
Nov 27 '18 at 7:01
Is Xorg setuid to root?
– UnP
Nov 27 '18 at 7:01
I am not using Xorg at all. This is my own application, for which I am doing setcap and not suid root.
– vyom
Nov 28 '18 at 4:06
I am not using Xorg at all. This is my own application, for which I am doing setcap and not suid root.
– vyom
Nov 28 '18 at 4:06
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53312865%2fiopl-fails-intermittently%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Care to provide the code to reproduce the problem? Also, what architecture are you running?
– Ulrich Eckhardt
Nov 26 '18 at 8:30
My program main has:
if (iopl(3) != 0) perror("iopl");
. I am not able to reproduce the issue at will! :( it happens some times and I am not getting any clue as to whyiopl
failed. This is intel Atom (Intel(R) Atom(TM) CPU C2558 @ 2.40GHz
) CPU. If you need any more details, please let me know.– vyom
Nov 27 '18 at 3:55
Add the architecture and the code to your question, including a
main()
and includes, to make the question more complete. One more think to look at would bestrace
. Capture its output and compare the error case to the non-error case. In particular, whether there are symptoms before theiopl()
-call. Other than that, I'm at a loss, too.– Ulrich Eckhardt
Nov 27 '18 at 18:31
@UlrichEckhardt sure, if this happens again, will
strace
it– vyom
Nov 28 '18 at 4:05