Re: hwclock --compare segfaults when run as normal user

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Jul 26, 2014 at 06:05:09PM +0200, Benno Schulenberg wrote:
> 
> On Sat, Jul 26, 2014, at 16:48, Sami Kerola wrote:
> > On 26 July 2014 13:40, Benno Schulenberg <bensberg@xxxxxxxxxxxxx> wrote:
> > > On my system there is no /etc/adjtime file, and then:
> > >
> > > $ ./hwclock --compare
> > > Segmentation fault
> > 
> > I tried to reproduce the issue without success. If you have core file

because you have RTC and Benno has cmos I guess

> > could you try to gdb backtrace it?

> 
> (gdb) run --compare
> Starting program: /home/ben/util-linux-2.25/hwclock --compare
> 
> Program received signal SIGSEGV, Segmentation fault.
> 0x0804cf71 in outb () at /usr/include/sys/io.h:99
> 99	  __asm__ __volatile__ ("outb %b0,%w1": :"a" (__value), "Nd" (__port));
> 
> (gdb) bt
> #0  0x0804cf71 in outb () at /usr/include/sys/io.h:99
> #1  cmos_read () at sys-utils/hwclock-cmos.c:348
> #2  atomic () at sys-utils/hwclock-cmos.c:307
> #3  hclock_read () at sys-utils/hwclock-cmos.c:456

 I have no way how to to test it, but can you try the patch below?

  Karel


>From 8fe55779b04e961d9e99bba7e1df382b71b63095 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@xxxxxxxxxx>
Date: Mon, 28 Jul 2014 13:00:54 +0200
Subject: [PATCH] hwclock: check for permissions before use clock interface

Reported-by: Benno Schulenberg <bensberg@xxxxxxxxxxxxx>
Signed-off-by: Karel Zak <kzak@xxxxxxxxxx>
---
 sys-utils/hwclock.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sys-utils/hwclock.c b/sys-utils/hwclock.c
index a934ace..474e04f 100644
--- a/sys-utils/hwclock.c
+++ b/sys-utils/hwclock.c
@@ -1495,6 +1495,9 @@ static int compare_clock (const bool utc, const bool local_opt)
 	bool hclock_valid = FALSE, universal, first_pass = TRUE;
 	int rc;
 
+	if (ur->get_permissions())
+		return EX_NOPERM;
+
 	/* dummy call for increased precision */
 	gettimeofday(&tv, NULL);
 
@@ -1893,7 +1896,7 @@ int main(int argc, char **argv)
 	}
 
 	if (!(show | set | systohc | hctosys | systz | adjust | getepoch
-	      | setepoch | predict))
+	      | setepoch | predict | compare))
 		show = 1;	/* default to show */
 
 	if (getuid() == 0)
-- 
1.9.3
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux