Maurizio Avogadro wrote:
> Il 13/02/2009 00:14, Corey Hickey ha scritto:
>> There aren't any flags on the open() system call; O_CREAT would be
>> needed.
> 
> The data file is actually created on the first write:
> 
> modem/modem_datafile.c:110, function datafile_save_info()
> ----------------------------------------------------------------------
>       int fd;
> 
>       fd = open(file_name,O_CREAT|O_WRONLY,(S_IRUSR|S_IWUSR));
>       if(fd < 0)
>               return -errno;
>               [...]
> ----------------------------------------------------------------------
> 
> During my quick tests the file has been created the second time I tried
> to start slmodemd; notice that the first datafile_load_info() happens
> before dropping privileges: if the file is created at that time it will
> be root:root.

You're right, and I see that behavior now too. The file is created on
the first run, before slmodemd exits. On the second run, the file is
available, and slmodemd can open it for reading.

I just did a quick grep of the source, before, and I didn't realize the
file was created elsewhere from where it was read; sorry for wasting
your time on that.

Anyway, to answer your original question about the file's permissions:

# ls -l /var/lib/slmodem/data.modem\:1
-rw------- 1 Slmodemd Slmodemd 24 Feb 14 20:14 /var/lib/slmodem/data.modem:1

>> In case it's of any use, I'm attaching a couple log files:
>>
>> slmodemd_2.6.26-1-686.log
>> slmodemd_2.6.26-1-686_no-drop-privs.log
> 
> I couldn't get your logs, please send them again.

Argh, I forgot them. They're attached this time.

> Anyway, I made some tests and - since now - I couldn't reproduce this
> issue, at least with current 2.6.26-1 Lenny kernel.

I think at this point it would be useful for me to summarize my current
understanding of what's going on in this bug report, since it has sort
of split into three different issues.

1. slmodemd hangs and isn't killable under kernels configured with a
particular realtime scheduling configuration. This was the original
reason for my bug report, and I have tracked it down to a kernel bug (or
at least some nasty behavior, if the kernel developers decide it's not a
bug). I sent a report and a test program to the LKML several hours ago:
http://lkml.org/lkml/2009/2/14/272

2. slmodemd creates /var/lib/slmodem/data.modem:1 before exit; that was
just me being confused, so I think this issue can be dropped.

3. On a non-realtime kernel, such as the standard Debian 2.6.26-1-686
kernel, slmodemd doesn't work for me with 10_drop_priveliges.diff
applied, with this error:
<164.501196> err: modem:1: modem start = -1: cannot start device.


On that last issue, I dug around with gdb a bit, starting with the
function in which that error message is printed.

modem.c:1140, function modem_start()
modem_comp_init() fails

modem_comp.c:795, function modem_comp_init()
comp_init() fails

modem_comp.c:730, function comp_init()
COMP_ALLOC(dict_size*sizeof(*d));   fails

That last part turns into:
malloc(2048 * 8);


I don't know why the malloc() fails. I went to the same line in my
slmodemd binary that doesn't have 10_drop_privileges.diff, and that
malloc() succeeded, with the same arguments.

Going back to the regular privilege-dropping binary, I used gdb to run
some malloc() tests immediately before and immediately after the
setuid() call. The results showed that malloc() could only allocate a
small amount of memory after the setuid().

I still don't know why that is. I cut modem_main.c down to just the
privilege-dropping code and made it a standalone program, and that
didn't have any trouble allocating lots of memory after the setuid().

My Slmodemd user doesn't have any memory allocation limits, as far as I
can tell (ulimit -a).


I'll do some more investigation, but that will have to wait a day or
two. If you have any tips meanwhile, please let me know.

Thanks,
Corey
<161.740201> SmartLink Soft Modem: version 2.9.11 Feb 11 2009 17:18:39
<161.740285> modem:1: startup modem...
<161.740448> modem:1: update termios...
symbolic link `/dev/ttySL0' -> `/dev/pts/0' created.
modem `modem:1' created. TTY is `/dev/pts/0'
<161.741660> open file: /var/lib/slmodem/data.modem:1...
<161.742914> main: rt applyed: SCHED_FIFO, pri 99
<161.743206> main: dropped privileges to 114.105
Use `/dev/ttySL0' as modem device, Ctrl+C for termination.
<163.934191> main: termios changed.
<163.934234> modem:1: update termios...
<164.000320> main: termios changed.
<164.000344> modem:1: update termios...
<164.101065> modem:1: run cmd: AT
<164.101090> modem:1: modem report result: 0 (OK)
<164.200483> modem:1: run cmd: AT&F&C1&D2V1S0=0
<164.200515> modem:1: modem report result: 0 (OK)
<164.301602> modem:1: run cmd: ATS7=60S30=0M1%C1\N3&K3N1X1
<164.301641> main: alsa_ioctl: cmd 8, arg 0...
<164.301680> modem:1: modem report result: 0 (OK)
<164.401317> modem:1: run cmd: AT+MS=34
<164.401364> modem:1: modem report result: 0 (OK)
<164.500957> modem:1: run cmd: ATDT1-760-933-2451
<164.500994> modem:1: modem dial: T1-760-933-2451...
<164.501004> modem:1: modem_dial_start...
<164.501053> modem:1: modem_start..
<164.501063> modem:1: modem set state: 1 --> 2...
<164.501072> modem:1: new state: DP_ESTAB
<164.501079> main: alsa_ioctl: cmd 8, arg 0...
<164.501096> modem:1: modem set hook: 0 --> 1...
<164.501106> main: alsa_ioctl: cmd 2, arg 1...
<164.501168> main: alsa_ioctl: cmd 11, arg 0...
<164.501196> err: modem:1: modem start = -1: cannot start device.
<164.501205> modem:1: modem_stop..
<164.501213> modem:1: modem set hook: 1 --> 0...
<164.501221> main: alsa_ioctl: cmd 2, arg 0...
<164.501240> main: alsa_ioctl: cmd 8, arg 0...
<164.501258> modem:1: modem set state: 2 --> 1...
<164.501267> modem:1: new state: MODEM_IDLE
<164.501274> modem:1: modem report result: 3 (NO CARRIER)
<164.501289> modem:1: modem report result: 4 (ERROR)
<164.800525> modem:1: run cmd: ATDT1-760-933-2451
<164.800566> modem:1: modem dial: T1-760-933-2451...
<164.800576> modem:1: modem_dial_start...
<164.800619> modem:1: modem_start..
<164.800630> modem:1: modem set state: 1 --> 2...
<164.800639> modem:1: new state: DP_ESTAB
<164.800646> main: alsa_ioctl: cmd 8, arg 0...
<164.800663> modem:1: modem set hook: 0 --> 1...
<164.800673> main: alsa_ioctl: cmd 2, arg 1...
<164.800711> main: alsa_ioctl: cmd 11, arg 0...
<164.800738> err: modem:1: modem start = -1: cannot start device.
<164.800748> modem:1: modem_stop..
<164.800755> modem:1: modem set hook: 1 --> 0...
<164.800763> main: alsa_ioctl: cmd 2, arg 0...
<164.800781> main: alsa_ioctl: cmd 8, arg 0...
<164.800799> modem:1: modem set state: 2 --> 1...
<164.800808> modem:1: new state: MODEM_IDLE
<164.800816> modem:1: modem report result: 3 (NO CARRIER)
<164.800831> modem:1: modem report result: 4 (ERROR)
<165.101324> modem:1: run cmd: ATDT1-760-933-2451
<165.101364> modem:1: modem dial: T1-760-933-2451...
<165.101374> modem:1: modem_dial_start...
<165.101418> modem:1: modem_start..
<165.101428> modem:1: modem set state: 1 --> 2...
<165.101437> modem:1: new state: DP_ESTAB
<165.101444> main: alsa_ioctl: cmd 8, arg 0...
<165.101461> modem:1: modem set hook: 0 --> 1...
<165.101471> main: alsa_ioctl: cmd 2, arg 1...
<165.101510> main: alsa_ioctl: cmd 11, arg 0...
<165.101538> err: modem:1: modem start = -1: cannot start device.
<165.101547> modem:1: modem_stop..
<165.101554> modem:1: modem set hook: 1 --> 0...
<165.101562> main: alsa_ioctl: cmd 2, arg 0...
<165.101580> main: alsa_ioctl: cmd 8, arg 0...
<165.101597> modem:1: modem set state: 2 --> 1...
<165.101606> modem:1: new state: MODEM_IDLE
<165.101614> modem:1: modem report result: 3 (NO CARRIER)
<165.101629> modem:1: modem report result: 4 (ERROR)
<165.401620> modem:1: run cmd: ATDT1-760-933-2451
<165.401667> modem:1: modem dial: T1-760-933-2451...
<165.401677> modem:1: modem_dial_start...
<165.401723> modem:1: modem_start..
<165.401733> modem:1: modem set state: 1 --> 2...
<165.401742> modem:1: new state: DP_ESTAB
<165.401749> main: alsa_ioctl: cmd 8, arg 0...
<165.401766> modem:1: modem set hook: 0 --> 1...
<165.401777> main: alsa_ioctl: cmd 2, arg 1...
<165.401821> main: alsa_ioctl: cmd 11, arg 0...
<165.401849> err: modem:1: modem start = -1: cannot start device.
<165.401859> modem:1: modem_stop..
<165.401866> modem:1: modem set hook: 1 --> 0...
<165.401874> main: alsa_ioctl: cmd 2, arg 0...
<165.401893> main: alsa_ioctl: cmd 8, arg 0...
<165.401911> modem:1: modem set state: 2 --> 1...
<165.401920> modem:1: new state: MODEM_IDLE
<165.401928> modem:1: modem report result: 3 (NO CARRIER)
<165.401943> modem:1: modem report result: 4 (ERROR)
<165.691200> main: termios changed.
<165.691232> modem:1: update termios...
<165.691254> main: pty closed.
<348.200741> SmartLink Soft Modem: version 2.9.11 Feb 12 2009 15:04:30
<348.200843> modem:1: startup modem...
<348.201003> modem:1: update termios...
symbolic link `/dev/ttySL0' -> `/dev/pts/3' created.
modem `modem:1' created. TTY is `/dev/pts/3'
<348.202099> open file: /var/lib/slmodem/data.modem:1...
<348.203674> main: rt applyed: SCHED_FIFO, pri 99
Use `/dev/ttySL0' as modem device, Ctrl+C for termination.
<351.354122> main: termios changed.
<351.354164> modem:1: update termios...
<351.415415> main: termios changed.
<351.415446> modem:1: update termios...
<351.515889> modem:1: run cmd: AT
<351.515916> modem:1: modem report result: 0 (OK)
<351.616325> modem:1: run cmd: AT&F&C1&D2V1S0=0
<351.616369> modem:1: modem report result: 0 (OK)
<351.716395> modem:1: run cmd: ATS7=60S30=0M1%C1\N3&K3N1X1
<351.716436> main: alsa_ioctl: cmd 8, arg 0...
<351.716471> modem:1: modem report result: 0 (OK)
<351.816370> modem:1: run cmd: AT+MS=34
<351.816417> modem:1: modem report result: 0 (OK)
<351.916822> modem:1: run cmd: ATDT1-760-933-2451
<351.916865> modem:1: modem dial: T1-760-933-2451...
<351.916874> modem:1: modem_dial_start...
<351.916919> modem:1: modem_start..
<351.916929> modem:1: modem set state: 1 --> 2...
<351.916938> modem:1: new state: DP_ESTAB
<351.916945> main: alsa_ioctl: cmd 8, arg 0...
<351.916960> modem:1: modem set hook: 0 --> 1...
<351.916970> main: alsa_ioctl: cmd 2, arg 1...
<351.917034> main: alsa_ioctl: cmd 11, arg 0...
<351.917359> main: alsa_ioctl: cmd 4, arg 2580...
<351.917371> main: alsa_ioctl: cmd 7, arg 30...
<351.917378> main: alsa_start...
Hooks PCM
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 1
  rate         : 9600
  exact rate   : 9600 (9600/1)
  msbits       : 16
  buffer_size  : 1536
  period_size  : 48
  period_time  : 5000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 48
  start_threshold  : 2147483647
  stop_threshold   : 1536
  silence_threshold: 0
  silence_size : 0
  boundary     : 1610612736
Slave: Hardware PCM card 1 'Intel 82801CA-ICH3 Modem' device 0 subdevice 0
Its setup is:
  stream       : PLAYBACK
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 1
  rate         : 9600
  exact rate   : 9600 (9600/1)
  msbits       : 16
  buffer_size  : 1536
  period_size  : 48
  period_time  : 5000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 48
  start_threshold  : 2147483647
  stop_threshold   : 1536
  silence_threshold: 0
  silence_size : 0
  boundary     : 1610612736
Hooks PCM
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 1
  rate         : 9600
  exact rate   : 9600 (9600/1)
  msbits       : 16
  buffer_size  : 1536
  period_size  : 48
  period_time  : 5000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 48
  start_threshold  : 2147483647
  stop_threshold   : 1536
  silence_threshold: 0
  silence_size : 0
  boundary     : 1610612736
Slave: Hardware PCM card 1 'Intel 82801CA-ICH3 Modem' device 0 subdevice 0
Its setup is:
  stream       : CAPTURE
  access       : RW_INTERLEAVED
  format       : S16_LE
  subformat    : STD
  channels     : 1
  rate         : 9600
  exact rate   : 9600 (9600/1)
  msbits       : 16
  buffer_size  : 1536
  period_size  : 48
  period_time  : 5000
  tstamp_mode  : NONE
  period_step  : 1
  avail_min    : 48
  start_threshold  : 2147483647
  stop_threshold   : 1536
  silence_threshold: 0
  silence_size : 0
  boundary     : 1610612736
<351.918286> main: startup write: 384...
<351.926319> main: alsa xrun: try to recover...
<351.926452> main: alsa xrun: recovered.
<351.926461> main: dev read = 0
<351.934427> main: alsa xrun: try to recover...
<351.934536> main: alsa xrun: recovered.
<351.934544> main: dev read = 0
<351.942507> main: alsa xrun: try to recover...
<351.942612> main: alsa xrun: recovered.
<351.942620> main: dev read = 0
<351.950613> main: alsa xrun: try to recover...
<351.950728> main: alsa xrun: recovered.
<351.950737> main: dev read = 0
<351.958705> main: alsa xrun: try to recover...
<351.958821> main: alsa xrun: recovered.
<351.958830> main: dev read = 0
<351.966806> main: alsa xrun: try to recover...
<351.966913> main: alsa xrun: recovered.
<351.966921> main: dev read = 0

Reply via email to