Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-21 Thread Rick Friedman
Well, I just installed the latest version of cron, version 3.0pl1-91. I've 
tested it out and it definitely solves the segfault problem for me.

good work!

Regards,
Rick


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Javier Fernández-Sanguino Peña
tags 324017 moreinfo unreproducible
thanks

On Fri, Aug 19, 2005 at 03:45:58PM -0400, Rick Friedman wrote:
 Package: cron
 Version: 3.0pl1-88
 Severity: grave
 Justification: renders package unusable
 
 
 The cron daemon runs as normal until a cronjob starts up. Actually, I
 don't even know if the cronjob actually starts. What I DO know is that
 at the start time of any cronjob, the cron daemon process mysteriously
 dies. No messages in any logs. Before a cronjob starts, the cron daemon
 process is running. After the (supposed) start of a cronjob, the cron
 daemon process is gone.

I'm sorry but I can't reproduce this and you're the only one seeing this.
I'm pretty sure that if 3.0pl1-88 introduce a bug of this kind I would
be flooded with similar bug reports already since it is a base package.

Could you please send a trace of the cron daemon _before_ a cronjob
starts so we can actually determine why it's dying? You can do this
with 'strace' (use the -p option to tell it which pid to trace and the -f
option to follow forks)

Regards

Javier


signature.asc
Description: Digital signature


Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Mike Hokenson


On Sunday, August 21, 2005 at 12:15AM, Javier Fern?ndez-Sanguino Pe?a wrote:

I'm sorry but I can't reproduce this and you're the only one seeing this.
I'm pretty sure that if 3.0pl1-88 introduce a bug of this kind I would
be flooded with similar bug reports already since it is a base package.

Could you please send a trace of the cron daemon _before_ a cronjob
starts so we can actually determine why it's dying? You can do this
with 'strace' (use the -p option to tell it which pid to trace and the -f
option to follow forks)


I'm having this problem also, but haven't tried 3.0pl1-87. I'm also having 
problems with my clock running too fast, so I'm frequently running ntpdate 
until I can figure out what's going on when I get back to work on Monday. Not 
sure if that would have anything to do with it...

I've rebuilt the cron daemon with -g to try and get something good out of the 
core, but now it's not crashing. :/

A strace I captured earlier looks like this:

[snip]
1523  open(/etc/cron.d, O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4
1523  fstat64(4, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
1523  fcntl64(4, F_SETFD, FD_CLOEXEC)   = 0
1523  getdents64(4, /* 5 entries */, 4096) = 136
1523  lstat64(/etc/cron.d/sendmail, {st_mode=S_IFREG|0644, st_size=7, ...}) = 0
1523  open(/etc/cron.d/sendmail, O_RDONLY) = 5
1523  fstat64(5, {st_mode=S_IFREG|0644, st_size=7, ...}) = 0
1523  close(5)  = 0
1523  lstat64(/etc/cron.d/php4, {st_mode=S_IFREG|0644, st_size=456, ...}) = 0
1523  open(/etc/cron.d/php4, O_RDONLY) = 5
1523  fstat64(5, {st_mode=S_IFREG|0644, st_size=456, ...}) = 0
1523  close(5)  = 0
1523  getdents64(4, /* 0 entries */, 4096) = 0
1523  close(4)  = 0
1523  open(crontabs, O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4
1523  fstat64(4, {st_mode=S_IFDIR|S_ISVTX|0730, st_size=4096, ...}) = 0
1523  fcntl64(4, F_SETFD, FD_CLOEXEC)   = 0
1523  getdents64(4, /* 4 entries */, 4096) = 104
1523  open(crontabs/root, O_RDONLY|O_NOFOLLOW) = 5
1523  fstat64(5, {st_mode=S_IFREG|0600, st_size=1011, ...}) = 0
1523  --- SIGSEGV (Segmentation fault) @ 0 (0) ---

It seemed stable when I commented everyone's crontabs.

Mike


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Rick Friedman
On Saturday 20 August 2005 07:21 pm, Mike Hokenson wrote:
 I'm having this problem also, but haven't tried 3.0pl1-87. I'm also having
 problems with my clock running too fast, so I'm frequently running ntpdate
 until I can figure out what's going on when I get back to work on Monday.
 Not sure if that would have anything to do with it...

 I've rebuilt the cron daemon with -g to try and get something good out of
 the core, but now it's not crashing. :/

 A strace I captured earlier looks like this:

 [snip]
 1523  open(/etc/cron.d, O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4
 1523  fstat64(4, {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
 1523  fcntl64(4, F_SETFD, FD_CLOEXEC)   = 0
 1523  getdents64(4, /* 5 entries */, 4096) = 136
 1523  lstat64(/etc/cron.d/sendmail, {st_mode=S_IFREG|0644, st_size=7,
 ...}) = 0 1523  open(/etc/cron.d/sendmail, O_RDONLY) = 5
 1523  fstat64(5, {st_mode=S_IFREG|0644, st_size=7, ...}) = 0
 1523  close(5)  = 0
 1523  lstat64(/etc/cron.d/php4, {st_mode=S_IFREG|0644, st_size=456, ...})
 = 0 1523  open(/etc/cron.d/php4, O_RDONLY) = 5
 1523  fstat64(5, {st_mode=S_IFREG|0644, st_size=456, ...}) = 0
 1523  close(5)  = 0
 1523  getdents64(4, /* 0 entries */, 4096) = 0
 1523  close(4)  = 0
 1523  open(crontabs, O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4
 1523  fstat64(4, {st_mode=S_IFDIR|S_ISVTX|0730, st_size=4096, ...}) = 0
 1523  fcntl64(4, F_SETFD, FD_CLOEXEC)   = 0
 1523  getdents64(4, /* 4 entries */, 4096) = 104
 1523  open(crontabs/root, O_RDONLY|O_NOFOLLOW) = 5
 1523  fstat64(5, {st_mode=S_IFREG|0600, st_size=1011, ...}) = 0
 1523  --- SIGSEGV (Segmentation fault) @ 0 (0) ---

 It seemed stable when I commented everyone's crontabs.

 Mike

It certainly seems more than coincidental to me that your strace shows the 
same seg fault that my strace shows... immediately after opening 
crontabs/root.

Rick


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Javier Fernández-Sanguino Peña
On Sat, Aug 20, 2005 at 07:28:25PM -0400, Rick Friedman wrote:
 It certainly seems more than coincidental to me that your strace shows the 
 same seg fault that my strace shows... immediately after opening 
 crontabs/root.

Oh, and BTW, the only change in -88 that might affect cron's behaviour
is either SElinux support or the enabling of pam_limits.so. You might
want to review /etc/security/limits.conf and see that it has sane
values there just in case.

Regards

Javier


signature.asc
Description: Digital signature


Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Mike Hokenson


On Sunday, August 21, 2005 at 01:57AM, Javier Fern?ndez-Sanguino Pe?a wrote:

On Sat, Aug 20, 2005 at 07:28:25PM -0400, Rick Friedman wrote:
Oh, and BTW, the only change in -88 that might affect cron's behaviour
is either SElinux support or the enabling of pam_limits.so. You might
want to review /etc/security/limits.conf and see that it has sane
values there just in case.


I don't have SElinux enabled and there's only comments in that file. I know 
this may not help much, but here's some bits from the core of the stripped 
binary.

Loaded symbols for /lib/ld-linux.so.2
#0  0x400a4e69 in free ()
  from /lib/tls/libc.so.6
(gdb) bt
#0  0x400a4e69 in free () from /lib/tls/libc.so.6
#1  0x40033e6c in freecon () from /lib/libselinux.so.1
#2  0x0804af20 in ?? ()
#3  0x000a6575 in ?? ()
#4  0xbfefad18 in ?? ()
[ on and on ]
#21 0x401739d4 in daylight () from /lib/tls/libc.so.6
[ and on some more ]

In -88, u-scontext is set to NULL if get_security_context() fails (i think) and 
in free_user() there's a freecon() call on u-scontext but no NULL check. Maybe 
that's where the problem is?


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Javier Fernández-Sanguino Peña
On Sat, Aug 20, 2005 at 07:11:43PM -0500, Mike Hokenson wrote:
 
 In -88, u-scontext is set to NULL if get_security_context() fails (i 
 think) and in free_user() there's a freecon() call on u-scontext but no 
 NULL check. Maybe that's where the problem is?

Your assessment looks quite correct. Libselinux does this:

void freecon(security_context_t con)
{
free(con);
}

So it might be the source of the error. This code was introduced by
#264320. I'm going to upload a new version right away, please let
me now if this fixes the bug.

Thanks for your help assessing this issue.

Regards

Javier



signature.asc
Description: Digital signature


Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Javier Fernández-Sanguino Peña
On Sat, Aug 20, 2005 at 07:51:17PM -0500, Mike Hokenson wrote:
 
 I just noticed I was building cron w/out selinux support. :P

Yes, I guessed as much :-)

 
 Here's a backtrace of a -g:
(..)
 
 Which still pretty much leads back to the same place...

Yes.

 I'm not sure what your patch looks like, but just testing for a NULL 
 u-scontext didn't work, I had to do this:

Why not? This is the patch I used:

@@ -133,7 +133,8 @@
free_entry(e);
}
 #ifdef WITH_SELINUX
-freecon(u-scontext);
+   if (u-scontext != NULL)
+   freecon(u-scontext);
 #endif
free(u);
 }

 #ifdef WITH_SELINUX
 +u-scontext = NULL;
 +

Hmm.. this might look like is needed too but I would like Russel to
confirm it.

 I originally pulled the other u-scontext = NULL;, but wasn't sure if the 
 security context would ever be set when get_security_context() returns -1. 
 It's working right now without, been runnin for 10 minutes.

Please let me know if the single patch I sent out works for you. I'm
not sure why you are seeing this and nobody else is reporting it...
There's definitely something which is system-specific here but I'm no
SElinux expert.

Regards

Javier


signature.asc
Description: Digital signature


Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Javier Fernández-Sanguino Peña
On Sat, Aug 20, 2005 at 07:51:17PM -0500, Mike Hokenson wrote:
 I'm not sure what your patch looks like, but just testing for a NULL 
 u-scontext didn't work, I had to do this:

Aggg.. you are right, I don't think clearly this late, the problem is that
u-scontext is undefined, that's why free() segfaults.
How about this patch? It should also fix other segfaults which were fixed
on a Fedora patch.

Javier
diff -Nru cron-3.0pl1-88/do_command.c cron-3.0pl1-91/do_command.c
--- cron-3.0pl1-88/do_command.c 2005-08-21 03:17:04.0 +0200
+++ cron-3.0pl1-91/do_command.c 2005-08-21 03:13:58.0 +0200
@@ -331,7 +331,7 @@
fprintf(stdout,error);
 #endif
 #ifdef WITH_SELINUX
-   if (is_selinux_enabled()  0) {
+   if ((is_selinux_enabled()  0)  (u-scontext != 0L)) {
 security_context_t scontext;
 if (setexeccon(u-scontext)  0) {
 if (security_getenforce()  0) {
diff -Nru cron-3.0pl1-88/user.c cron-3.0pl1-91/user.c
--- cron-3.0pl1-88/user.c   2005-08-21 03:17:04.0 +0200
+++ cron-3.0pl1-91/user.c   2005-08-21 03:15:37.0 +0200
@@ -36,7 +36,7 @@
 
 static int get_security_context(char *name, int crontab_fd, security_context_t
 *rcontext, char *tabname) {
-security_context_t scontext;
+security_context_t scontext=NULL;
 security_context_t  file_context=NULL;
 struct av_decision avd;
 int retval=0;
@@ -50,6 +50,7 @@
 log_it(name, getpid(),
No security context but SELinux in permissive mode,
 continuing, tabname);
+   return 0;
 }
 }
 
@@ -133,7 +134,8 @@
free_entry(e);
}
 #ifdef WITH_SELINUX
-freecon(u-scontext);
+   if (u-scontext)
+   freecon(u-scontext);
 #endif
free(u);
 }
@@ -175,6 +177,7 @@
u-crontab = NULL;
 
 #ifdef WITH_SELINUX
+   u-scontext = NULL;
 if (is_selinux_enabled()  0) {
 char *sname=uname;
 if (pw==NULL) {


signature.asc
Description: Digital signature


Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Javier Fernández-Sanguino Peña
On Sat, Aug 20, 2005 at 08:21:35PM -0500, Mike Hokenson wrote:
 If it only contains the NULL pointer check, it won't (already tried), Rick 
 will probably be able to confirm this when he updates. I'm not familiar 
 with the mirroring system, do you think it'll appear shortly or is there a 
 place I can go to get packages that are pending approval?

Yes, I noticed that already. In any case, I've uploaded -91 just now
fixing that and some other segfaults that the people at Fedora have
fixed (patch for those is in the mail). Rick will be able to confirm
that when he updates tomorrow if he is using the main site, if he
is using a mirror it might take some more.

Regards

Javier

PS: BTW, Rick is not reading me because Verizon is blocking my mail
server. 


signature.asc
Description: Digital signature


Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Mike Hokenson


On Sunday, August 21, 2005 at 03:20AM, Javier Fern?ndez-Sanguino Pe?a wrote:

On Sat, Aug 20, 2005 at 07:51:17PM -0500, Mike Hokenson wrote:
I'm not sure what your patch looks like, but just testing for a NULL 
u-scontext didn't work, I had to do this:


Aggg.. you are right, I don't think clearly this late, the problem is that
u-scontext is undefined, that's why free() segfaults.
How about this patch? It should also fix other segfaults which were fixed
on a Fedora patch.

Javier



diff -Nru cron-3.0pl1-88/do_command.c cron-3.0pl1-91/do_command.c
--- cron-3.0pl1-88/do_command.c 2005-08-21 03:17:04.0 +0200
+++ cron-3.0pl1-91/do_command.c 2005-08-21 03:13:58.0 +0200
@@ -331,7 +331,7 @@
fprintf(stdout,error);
#endif
#ifdef WITH_SELINUX
-   if (is_selinux_enabled()  0) {
+   if ((is_selinux_enabled()  0)  (u-scontext != 0L)) {
security_context_t scontext;
if (setexeccon(u-scontext)  0) {
if (security_getenforce()  0) {
diff -Nru cron-3.0pl1-88/user.c cron-3.0pl1-91/user.c
--- cron-3.0pl1-88/user.c   2005-08-21 03:17:04.0 +0200
+++ cron-3.0pl1-91/user.c   2005-08-21 03:15:37.0 +0200
@@ -36,7 +36,7 @@

static int get_security_context(char *name, int crontab_fd, security_context_t
*rcontext, char *tabname) {
-security_context_t scontext;
+security_context_t scontext=NULL;
security_context_t  file_context=NULL;
struct av_decision avd;
int retval=0;
@@ -50,6 +50,7 @@
log_it(name, getpid(),
   No security context but SELinux in permissive mode,
continuing, tabname);
+   return 0;
}
}

@@ -133,7 +134,8 @@
free_entry(e);
}
#ifdef WITH_SELINUX
-freecon(u-scontext);
+   if (u-scontext)
+   freecon(u-scontext);
#endif
free(u);
}
@@ -175,6 +177,7 @@
u-crontab = NULL;

#ifdef WITH_SELINUX
+   u-scontext = NULL;
if (is_selinux_enabled()  0) {
char *sname=uname;
if (pw==NULL) {


Yep, works good.

(sorry, forgot to cc everyone on the reply to your other message heh).


--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-20 Thread Rick Friedman
Unfortunately, Javier is correct. I have received no emails from him. For some 
reason, Verizon, in its infinite wisdom, is blocking email from that domain. 

Anyway, I will let you know what happens once I can update tomorrow.

Regards,

Rick


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]



Bug#324017: Cron daemon dies when a cronjob is about to start

2005-08-19 Thread Rick Friedman
Package: cron
Version: 3.0pl1-88
Severity: grave
Justification: renders package unusable


The cron daemon runs as normal until a cronjob starts up. Actually, I
don't even know if the cronjob actually starts. What I DO know is that
at the start time of any cronjob, the cron daemon process mysteriously
dies. No messages in any logs. Before a cronjob starts, the cron daemon
process is running. After the (supposed) start of a cronjob, the cron
daemon process is gone.

Downgrading to version 3.0pl1-87 resolves the problem.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.12-1-k7
Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1)

Versions of packages cron depends on:
ii  adduser   3.67   Add and remove users and groups
ii  debianutils   2.14.2 Miscellaneous utilities specific t
ii  libc6 2.3.5-3GNU C Library: Shared libraries an
ii  libpam0g  0.76-23Pluggable Authentication Modules l
ii  libselinux1   1.24-4 SELinux shared libraries

Versions of packages cron recommends:
ii  exim4 4.52-1 metapackage to ease exim MTA (v4) 
ii  exim4-daemon-light [mail-tran 4.52-1 lightweight exim MTA (v4) daemon

-- no debconf information


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]