From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Jakub Zawadzki <darkjames-ws@darkjames.pl>,
Daniel Borkmann <dborkman@redhat.com>,
"David S. Miller" <davem@davemloft.net>
Subject: [ 32/50] packet: tpacket_v3: do not trigger bug() on wrong header status
Date: Fri, 17 May 2013 14:47:07 -0700 [thread overview]
Message-ID: <20130517213846.063776576@linuxfoundation.org> (raw)
In-Reply-To: <20130517213842.447809965@linuxfoundation.org>
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <dborkman@redhat.com>
[ Upstream commit 8da3056c04bfc5f69f840ab038a38389e2de8189 ]
Jakub reported that it is fairly easy to trigger the BUG() macro
from user space with TPACKET_V3's RX_RING by just giving a wrong
header status flag. We already had a similar situation in commit
7f5c3e3a80e6654 (``af_packet: remove BUG statement in
tpacket_destruct_skb'') where this was the case in the TX_RING
side that could be triggered from user space. So really, don't use
BUG() or BUG_ON() unless there's really no way out, and i.e.
don't use it for consistency checking when there's user space
involved, no excuses, especially not if you're slapping the user
with WARN + dump_stack + BUG all at once. The two functions are
of concern:
prb_retire_current_block() [when block status != TP_STATUS_KERNEL]
prb_open_block() [when block_status != TP_STATUS_KERNEL]
Calls to prb_open_block() are guarded by ealier checks if block_status
is really TP_STATUS_KERNEL (racy!), but the first one BUG() is easily
triggable from user space. System behaves still stable after they are
removed. Also remove that yoda condition entirely, since it's already
guarded.
Reported-by: Jakub Zawadzki <darkjames-ws@darkjames.pl>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
net/packet/af_packet.c | 54 ++++++++++++++++++-------------------------------
1 file changed, 20 insertions(+), 34 deletions(-)
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -812,37 +812,27 @@ static void prb_open_block(struct tpacke
smp_rmb();
- if (likely(TP_STATUS_KERNEL == BLOCK_STATUS(pbd1))) {
-
- /* We could have just memset this but we will lose the
- * flexibility of making the priv area sticky
- */
- BLOCK_SNUM(pbd1) = pkc1->knxt_seq_num++;
- BLOCK_NUM_PKTS(pbd1) = 0;
- BLOCK_LEN(pbd1) = BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
- getnstimeofday(&ts);
- h1->ts_first_pkt.ts_sec = ts.tv_sec;
- h1->ts_first_pkt.ts_nsec = ts.tv_nsec;
- pkc1->pkblk_start = (char *)pbd1;
- pkc1->nxt_offset = (char *)(pkc1->pkblk_start +
- BLK_PLUS_PRIV(pkc1->blk_sizeof_priv));
- BLOCK_O2FP(pbd1) = (__u32)BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
- BLOCK_O2PRIV(pbd1) = BLK_HDR_LEN;
- pbd1->version = pkc1->version;
- pkc1->prev = pkc1->nxt_offset;
- pkc1->pkblk_end = pkc1->pkblk_start + pkc1->kblk_size;
- prb_thaw_queue(pkc1);
- _prb_refresh_rx_retire_blk_timer(pkc1);
-
- smp_wmb();
-
- return;
- }
+ /* We could have just memset this but we will lose the
+ * flexibility of making the priv area sticky
+ */
+ BLOCK_SNUM(pbd1) = pkc1->knxt_seq_num++;
+ BLOCK_NUM_PKTS(pbd1) = 0;
+ BLOCK_LEN(pbd1) = BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
+ getnstimeofday(&ts);
+ h1->ts_first_pkt.ts_sec = ts.tv_sec;
+ h1->ts_first_pkt.ts_nsec = ts.tv_nsec;
+ pkc1->pkblk_start = (char *)pbd1;
+ pkc1->nxt_offset = (char *)(pkc1->pkblk_start +
+ BLK_PLUS_PRIV(pkc1->blk_sizeof_priv));
+ BLOCK_O2FP(pbd1) = (__u32)BLK_PLUS_PRIV(pkc1->blk_sizeof_priv);
+ BLOCK_O2PRIV(pbd1) = BLK_HDR_LEN;
+ pbd1->version = pkc1->version;
+ pkc1->prev = pkc1->nxt_offset;
+ pkc1->pkblk_end = pkc1->pkblk_start + pkc1->kblk_size;
+ prb_thaw_queue(pkc1);
+ _prb_refresh_rx_retire_blk_timer(pkc1);
- WARN(1, "ERROR block:%p is NOT FREE status:%d kactive_blk_num:%d\n",
- pbd1, BLOCK_STATUS(pbd1), pkc1->kactive_blk_num);
- dump_stack();
- BUG();
+ smp_wmb();
}
/*
@@ -933,10 +923,6 @@ static void prb_retire_current_block(str
prb_close_block(pkc, pbd, po, status);
return;
}
-
- WARN(1, "ERROR-pbd[%d]:%p\n", pkc->kactive_blk_num, pbd);
- dump_stack();
- BUG();
}
static int prb_curr_blk_in_use(struct tpacket_kbdq_core *pkc,
next prev parent reply other threads:[~2013-05-17 21:47 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-17 21:46 [ 00/50] 3.4.46-stable review Greg Kroah-Hartman
2013-05-17 21:46 ` [ 01/50] KVM: VMX: fix halt emulation while emulating invalid guest sate Greg Kroah-Hartman
2013-05-17 21:46 ` [ 02/50] ARM: OMAP: RX-51: change probe order of touchscreen and panel SPI devices Greg Kroah-Hartman
2013-05-17 21:46 ` [ 03/50] ASoC: wm8994: missing break in wm8994_aif3_hw_params() Greg Kroah-Hartman
2013-05-17 21:46 ` [ 04/50] ACPICA: Fix possible buffer overflow during a field unit read operation Greg Kroah-Hartman
2013-05-17 21:46 ` [ 05/50] ALSA: HDA: Fix Oops caused by dereference NULL pointer Greg Kroah-Hartman
2013-05-17 21:46 ` [ 06/50] dm snapshot: fix error return code in snapshot_ctr Greg Kroah-Hartman
2013-05-17 21:46 ` [ 07/50] nfsd4: dont allow owner override on 4.1 CLAIM_FH opens Greg Kroah-Hartman
2013-05-17 21:46 ` [ 08/50] hp_accel: Ignore the error from lis3lv02d_poweron() at resume Greg Kroah-Hartman
2013-05-17 21:46 ` [ 09/50] xen/vcpu/pvhvm: Fix vcpu hotplugging hanging Greg Kroah-Hartman
2013-05-17 21:46 ` [ 10/50] SCSI: sd: fix array cache flushing bug causing performance problems Greg Kroah-Hartman
2013-05-17 21:46 ` [ 11/50] audit: Syscall rules are not applied to existing processes on non-x86 Greg Kroah-Hartman
2013-05-17 21:46 ` [ 12/50] timer: Dont reinitialize the cpu base lock during CPU_UP_PREPARE Greg Kroah-Hartman
2013-05-17 21:46 ` [ 13/50] tick: Cleanup NOHZ per cpu data on cpu down Greg Kroah-Hartman
2013-05-17 21:46 ` [ 14/50] tracing: Fix leaks of filter preds Greg Kroah-Hartman
2013-05-17 21:46 ` [ 15/50] ext4: limit group search loop for non-extent files Greg Kroah-Hartman
2013-05-17 21:46 ` [ 16/50] powerpc: Bring all threads online prior to migration/hibernation Greg Kroah-Hartman
2013-05-17 21:46 ` [ 17/50] ath9k: fix key allocation error handling for powersave keys Greg Kroah-Hartman
2013-05-17 21:46 ` [ 18/50] mwifiex: clear is_suspended flag when interrupt is received early Greg Kroah-Hartman
2013-05-17 21:46 ` [ 19/50] mwifiex: fix setting of multicast filter Greg Kroah-Hartman
2013-05-17 21:46 ` [ 20/50] B43: Handle DMA RX descriptor underrun Greg Kroah-Hartman
2013-05-17 21:46 ` [ 21/50] drm/mm: fix dump table BUG Greg Kroah-Hartman
2013-05-17 21:46 ` [ 22/50] net: qmi_wwan: fixup missing ethernet header (firmware bug workaround) Greg Kroah-Hartman
2013-05-17 21:46 ` [ 23/50] net: qmi_wwan: fixup destination address " Greg Kroah-Hartman
2013-05-17 21:46 ` [ 24/50] net: qmi_wwan: prevent duplicate mac address on link " Greg Kroah-Hartman
2013-05-17 21:47 ` [ 25/50] tcp: force a dst refcount when prequeue packet Greg Kroah-Hartman
2013-05-17 21:47 ` [ 26/50] sfc: Fix naming of MTD partitions for FPGA bitfiles Greg Kroah-Hartman
2013-05-17 21:47 ` [ 27/50] 3c509.c: call SET_NETDEV_DEV for all device types (ISA/ISAPnP/EISA) Greg Kroah-Hartman
2013-05-17 21:47 ` [ 28/50] net_sched: act_ipt forward compat with xtables Greg Kroah-Hartman
2013-05-17 21:47 ` [ 29/50] net: use netdev_features_t in skb_needs_linearize() Greg Kroah-Hartman
2013-05-17 21:47 ` [ 30/50] net: vlan,ethtool: netdev_features_t is more than 32 bit Greg Kroah-Hartman
2013-05-17 21:47 ` [ 31/50] bridge: fix race with topology change timer Greg Kroah-Hartman
2013-05-17 21:47 ` Greg Kroah-Hartman [this message]
2013-05-17 21:47 ` [ 33/50] 3c59x: fix freeing nonexistent resource on driver unload Greg Kroah-Hartman
2013-05-17 21:47 ` [ 34/50] 3c59x: fix PCI resource management Greg Kroah-Hartman
2013-05-17 21:47 ` [ 35/50] if_cablemodem.h: Add parenthesis around ioctl macros Greg Kroah-Hartman
2013-05-17 21:47 ` [ 36/50] macvlan: fix passthru mode race between dev removal and rx path Greg Kroah-Hartman
2013-05-17 21:47 ` [ 37/50] ipv6: do not clear pinet6 field Greg Kroah-Hartman
2013-05-17 21:47 ` [ 38/50] xfrm6: release dev before returning error Greg Kroah-Hartman
2013-05-17 21:47 ` [ 39/50] dm thin: do not set discard_zeroes_data Greg Kroah-Hartman
2013-05-17 21:47 ` [ 40/50] pch_dma: Use GFP_ATOMIC because called from interrupt context Greg Kroah-Hartman
2013-05-17 21:47 ` [ 41/50] hugetlbfs: fix mmap failure in unaligned size request Greg Kroah-Hartman
2013-05-17 21:47 ` [ 42/50] r8169: fix vlan tag read ordering Greg Kroah-Hartman
2013-05-17 21:47 ` [ 43/50] drbd: fix for deadlock when using automatic split-brain-recovery Greg Kroah-Hartman
2013-05-17 21:47 ` [ 44/50] drivers/rtc/rtc-pcf2123.c: fix error return code in pcf2123_probe() Greg Kroah-Hartman
2013-05-17 21:47 ` [ 45/50] iscsi-target: Fix processing of OOO commands Greg Kroah-Hartman
2013-05-17 21:47 ` [ 46/50] ACPI / EC: Restart transaction even when the IBF flag set Greg Kroah-Hartman
2013-05-17 21:47 ` [ 47/50] drivers/char/ipmi: memcpy, need additional 2 bytes to avoid memory overflow Greg Kroah-Hartman
2013-05-17 21:47 ` [ 48/50] ipmi: ipmi_devintf: compat_ioctl method fails to take ipmi_mutex Greg Kroah-Hartman
2013-05-17 21:47 ` [ 49/50] drm/radeon: check incoming cliprects pointer Greg Kroah-Hartman
2013-05-17 21:47 ` [ 50/50] usermodehelper: check subprocess_info->path != NULL Greg Kroah-Hartman
2013-05-19 11:16 ` [ 00/50] 3.4.46-stable review Satoru Takeuchi
2013-05-19 18:05 ` Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130517213846.063776576@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=darkjames-ws@darkjames.pl \
--cc=davem@davemloft.net \
--cc=dborkman@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).