Bug 731789 - Bug with snaplen in libpcap
Bug with snaplen in libpcap
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libpcap (Show other bugs)
6.1
Unspecified Unspecified
low Severity low
: rc
: ---
Assigned To: Michal Sekletar
qe-baseos-daemons
: Reopened
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-18 12:41 EDT by fabrizio.giordano
Modified: 2013-11-21 18:54 EST (History)
5 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Cause: libpcap is unable to open a capture device with small snaplen. Consequence: libpcap returns error when trying to open capture device with snaplen less than 13 and it causes tcpdump to exit prematurely. Fix: Calculation of frames for memory mapping packet capture mechanism was adjusted in a way that in doesn't truncate packets to smaller values than actual snaplen. Result: libpcap doesn't return error when trying to open capture device with small values of snaplen and applications using libpcap are processing packets normally instead of exiting with error.
Story Points: ---
Clone Of:
Environment:
Last Closed: 2013-11-21 18:54:54 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)
Test Application (4.15 KB, text/plain)
2011-08-18 12:41 EDT, fabrizio.giordano
no flags Details
libpcap-linux-snaplen-mmap.patch (3.43 KB, patch)
2011-08-24 12:59 EDT, fabrizio.giordano
no flags Details | Diff

  None (edit)
Description fabrizio.giordano 2011-08-18 12:41:12 EDT
Created attachment 518906 [details]
Test Application

Description of problem:

I have Scientific Linux 6.0 on my machine and apparently the version of libpcap that's distributed with it (libpcap-1.0.0-6.20091201git117cb5.el6.x86_64) has a bug when opening a device with a snaplen smaller than 13.
Besides, even if the snaplen is greater or equal to 13, the captured packet size won't match the selected snaplen.
 
The following message will be displayed when reading from a device that's been opened with a snaplen < 13:

"Error reading the packets: corrupted frame on kernel ring mac offset 70 +
caplen 0 > frame len 64"
 
Apparently these two bugs have already been fixed in the latest version of libpcap.
I attached a test application to show what I described.

Version-Release number of selected component (if applicable):
libpcap-1.0.0-6.20091201git117cb5.el6.x86_64

How reproducible:
Always

Steps to Reproduce:
1. FIRST_TEST: Open an interface with pcap_open_live setting a snaplen < 13, then read packets.
2. SECOND_TEST: Open an interface with pcap_open_live setting a snaplen >=13, read packets and check that the snaplen is the same as set in pcap_open_live
  
Actual results:
1. The message "Error reading the packets: corrupted frame on kernel ring mac offset 70 + caplen 0 > frame len 64" will appear
2. The length of the captured packets won't be the same as set in pcap_open_live

Expected results:
1. Read packets normally
2. The length of the packets should match the snaplen set in pcap_open_live
Comment 2 RHEL Product and Program Management 2011-08-18 13:08:53 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.
Comment 3 Michal Sekletar 2011-08-24 07:01:22 EDT
Hello Fabrizio, 

thank you for reporting this issue. I've confirmed that it is actual bug in libpcap but after some further investigation I've found out that there is no straightforward way to backport a patch which solves this issue. There has been just too much development and changes done since version 1.0.0. As you correctly pointed out this issue is now resolved in the latest development version of libpcap. I hope that this issue will be solved in some upcoming major release of Red Hat Enterprise Linux by upgrading to new version of libpcap.

Michal Sekletar
Comment 4 fabrizio.giordano 2011-08-24 12:59:30 EDT
Created attachment 519671 [details]
libpcap-linux-snaplen-mmap.patch

We actually managed to create a patch from the git repository that fixed this bug. This is the commit that fixed the bug:

https://github.com/mcr/libpcap/commit/9982024b5718fac524d8c637329206ea80d7b8ad
Comment 5 Michal Sekletar 2011-08-29 03:47:34 EDT
Hi,

thank you for your patch and please excuse my mistake.

Michal Sekletar
Comment 6 Guy Harris 2011-12-09 04:09:47 EST
This might be fixed in 1.2.0; if not, it's fixed in the top of the 1.2 branch and the trunk, so it'll be fixed in the next release.  (The Linux mmapping code gives me a pain where a pill can't reach it; as per my comment in another bug, maybe TPACKET_V3 will be less painful to work with.)
Comment 8 Suzanne Yeghiayan 2012-02-14 18:13:49 EST
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.
Comment 9 RHEL Product and Program Management 2012-09-07 01:09:06 EDT
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unable to address this
request at this time.

Red Hat invites you to ask your support representative to
propose this request, if appropriate, in the next release of
Red Hat Enterprise Linux.
Comment 11 Michal Sekletar 2013-08-28 11:00:03 EDT
This issue should be solved by rebase of libpcap in rhel-6.5.

http://bulk-mail.corp.redhat.com/archives/cvs-commits-list/2013-August/msg09611.html
Comment 14 errata-xmlrpc 2013-11-21 18:54:54 EST
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2013-1727.html

Note You need to log in before you can comment on or make changes to this bug.