bugThe GNU Hurd - Bugs: bug #48371, read(fd, NULL, 0) from /dev/klog...

 
 

bug #48371: read(fd, NULL, 0) from /dev/klog blocks until there is data

Submitted by:  Kalle Olavi Niemitalo <kon>
Submitted on:  Fri 01 Jul 2016 09:47:46 PM UTC  
 
Category: Hurd ServersSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Standard Compliance
Status: NonePrivacy: Public
Assigned to: NoneOriginator Name: 
Open/Closed: OpenReproducibility: None
Size (loc): NonePlanned Release: None
Effort: 0.00
Wiki-like text discussion box: 

For such a two-lines patch, the changes are not copyrightable, so there is no need for a copyright assignment.

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Thu 07 Jul 2016 08:05:51 PM UTC, comment #3:

I patched trans/streamio.c (trivfs_S_io_read) so that, if amount == 0, it returns success without blocking. I didn't change dev_read because it's called only from trivfs_S_io_read and I thought it'd be better to avoid locking global_lock in this case. After installing this change and rebooting, I then ran as root

and it didn't hang. I also ran "cat /dev/klog", which correctly output the "unexpected RESEND from keyboard" message from gnumach when I used a key combination to defocus the virtualbox window. I did not retest /dev/klog support in rsyslog.

As discussed on #hurd, I don't intend to post the patch itself.

Kalle Olavi Niemitalo <kon>
Mon 04 Jul 2016 08:47:49 PM UTC, comment #2:

I agree it should be done in dev_read. The RPC documentation doesn't
seem to say what should be done with 0-bytes requests, I'd tend to
think aligning with POSIX should be fine.

Could you test and propose a patch?

Samuel Thibault <sthibaul>
Project Member
Fri 01 Jul 2016 10:01:35 PM UTC, comment #1:

I wrote "storeio gets to the dev_read function" but I really meant streamio.

Kalle Olavi Niemitalo <kon>
Fri 01 Jul 2016 09:47:46 PM UTC, original submission:

I patched rsyslog 8.16.0 to make it use /dev/klog on the Hurd. (Set os_type="bsd" in configure.ac.) It opened /dev/klog all right but then hung waiting for input. rpctrace showed that it was calling read with size=0. This call is in plugins/imklog/bsd.c (klogWillRunPostPrivDrop). I removed the call and rsyslog then started quickly.

The translator of /dev/klog is "/hurd/streamio kmsg". I assume storeio gets to the dev_read function, which then waits for input from the kernel, without noticing that the requested size is 0.

According to antrik, POSIX specifies that read with nbyte==0 must immediately return 0 or return an error. This could be implemented in libc, libtrivfs, or streamio. It seems best to implement this in streamio so that translators can still return EBADF if the file was not opened for reading.

Kalle Olavi Niemitalo <kon>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

Attached Files
file #37764:  0001-streamio-read-fd-buf-0-must-not-block.patch added by kon (1KiB - text/x-patch - Includes the prominent notice as per GPLv2 subsection 2a.)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by sthibaul (Posted a comment)
  • -unavailable- added by kon (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 07 Jul 2016 10:14:11 PM UTCkonAttached File-=>Added 0001-streamio-read-fd-buf-0-must-not-block.patch, #37764
    Thu 07 Jul 2016 08:38:28 PM UTCsthibaulWiki-like text discussion box=>For such a two-lines patch, the changes are not copyrightable, so there is no need for a copyright assignment.

    Back to the top


    Powered by Savane 3.1-cleanup1