Hey everyone,

I've been at this all day and I'm stuck.. I run `sudo make setuid` after 
compiling LinuxCNC master branch and then I run latency-test and then I get 
this error (the latency-test window still comes up):

cannot gain I/O privileges - forgot 'sudo make setuid' or using secure boot? 
-parallel port access is not allow

LinuxCNC itself says the same problem.. Now, I remember about a year ago I was 
doing RTAI work and this problem never happened, even without a parallel port 
card in the system. I have never seen this message before.. I have tried 
several different parallel port cards, making sure parport_pc parport_serial 
and ppdev are loaded, `lspci -k` output is irrelevant, whether the kernel finds 
the parallel port card or not, I still get the "cannot gain I/O privileges" 
error.

I am using PREEMPT_RT, this is a Gentoo system but the entire parallel port 
stack are modules, ppdev is module, /dev/port and /dev/mem are enabled, 
filtering I/O access to /dev/mem is disabled. After countless kernel changes, 
IOMMU, PCI reallocation etc etc nothing changes the error.

Section of code where problem occurs:

static int harden_rt()
{
    if(!rtapi_is_realtime()) return -EINVAL;

    WITH_ROOT;
#if defined(__linux__) && (defined(__x86_64__) || defined(__i386__))
    if (iopl(3) < 0) {
        rtapi_print_msg(RTAPI_MSG_ERR,
                        "cannot gain I/O privileges - "
                        "forgot 'sudo make setuid' or using secure boot? -"
                        "parallel port access is not allow\n");
    }
#endif

The man page for iopl is interesting, specifically:

This  call is deprecated, is significantly slower than ioperm(2), and is only 
provided for older X servers which require
       access to all 65536 I/O ports.  It is mostly for the i386 architecture.  
On many other architectures it does  not  exist
       or will always return an error.

I have ran LinuxCNC before in simulators and latency-test and never saw this 
message before.. Does anyone know what's going on? I am using glibc 2.35 if 
that's relevant..

Much help is greatly appreciated, I don't know what else to try. Everything on 
the parallel port side in terms of the kernel is fine, this looks to be a 
problem with either LinuxCNC or the iopl() C function call. I have disabled all 
kernel hardening features for this test, nothing should be blocking LinuxCNC 
from accessing the card however I have built fully hardened kernels before for 
LinuxCNC and never saw this message. I have been using LinuxCNC for years on 
custom kernels and systems, this is definitely new. Is it possible that 
something changed in Glibc and LinuxCNC is using iopl() instead of ioperm() ? 
Problem is, if that's true, I suck at C and don't know how to migrate to that 
new behavior. Here is an ioperm() example:

/*
* example.c: very simple example of port I/O
*
* This code does nothing useful, just a port write, a pause,
* and a port read. Compile with `gcc -O2 -o example example.c',
* and run as root with `./example'.
*/

#include <stdio.h>
#include <unistd.h>
#include <asm/io.h>

#define BASEPORT 0x378 /* lp1 */

int main()
{
  /* Get access to the ports */
  if (ioperm(BASEPORT, 3, 1)) {perror("ioperm"); exit(1);}
  
  /* Set the data signals (D0-7) of the port to all low (0) */
  outb(0, BASEPORT);
  
  /* Sleep for a while (100 ms) */
  usleep(100000);
  
  /* Read from the status port (BASE+1) and display the result */
  printf("status: %d\n", inb(BASEPORT + 1));

  /* We don't need the ports anymore */
  if (ioperm(BASEPORT, 3, 0)) {perror("ioperm"); exit(1);}

  exit(0);
}

/* end of example.c */

I'm seriously stuck, please help!

Alec


_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to