mirror of
https://github.com/lgcosta/pf-linux-port.git
synced 2026-11-15 13:54:45 -03:00
divert: fix NULL-deref on empty listener list (wedged pf0 in gate 11); gate 11 pdivert path; runner accepts gate filter arg
This commit is contained in:
1 parent
fd0be917fe
commit
da1f678125
3 files changed
+17
-7
No files matched your search
@@ -95,6 +95,18 @@ pfk_divert_pkt_free(struct pfk_divert_pkt *dp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* PF engine entry points (called from the ported pf.c) */
|
/* PF engine entry points (called from the ported pf.c) */
|
||||||
|
static struct pfk_divert_sock *
|
||||||
|
pfk_divert_lookup(u_int16_t port)
|
||||||
|
{
|
||||||
|
struct pfk_divert_sock *ds;
|
||||||
|
|
||||||
|
list_for_each_entry(ds, &pfk_divert_list, link) {
|
||||||
|
if (ds->port == port)
|
||||||
|
return ds;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
pfk_divert_queue(struct sk_buff *skb, int dir, int type, u16 port)
|
pfk_divert_queue(struct sk_buff *skb, int dir, int type, u16 port)
|
||||||
{
|
{
|
||||||
@@ -114,12 +126,8 @@ pfk_divert_queue(struct sk_buff *skb, int dir, int type, u16 port)
|
|||||||
dp->ifindex = skb->dev ? skb->dev->ifindex : 0;
|
dp->ifindex = skb->dev ? skb->dev->ifindex : 0;
|
||||||
|
|
||||||
spin_lock_irqsave(&pfk_divert_lock, flags);
|
spin_lock_irqsave(&pfk_divert_lock, flags);
|
||||||
ds = NULL;
|
ds = pfk_divert_lookup(port);
|
||||||
list_for_each_entry(ds, &pfk_divert_list, link) {
|
if (ds == NULL) {
|
||||||
if (ds->port == port)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (&ds->link == &pfk_divert_list) {
|
|
||||||
pfk_divert_global.divs_noport++;
|
pfk_divert_global.divs_noport++;
|
||||||
spin_unlock_irqrestore(&pfk_divert_lock, flags);
|
spin_unlock_irqrestore(&pfk_divert_lock, flags);
|
||||||
pr_info_ratelimited("pfk: divert port %u: no socket bound\n",
|
pr_info_ratelimited("pfk: divert port %u: no socket bound\n",
|
||||||
|
|||||||
@@ -42,7 +42,9 @@ pf_disable_pf0() {
|
|||||||
>/dev/null 2>&1 || true
|
>/dev/null 2>&1 || true
|
||||||
}
|
}
|
||||||
trap pf_disable_pf0 EXIT INT TERM
|
trap pf_disable_pf0 EXIT INT TERM
|
||||||
|
ONLY="${1:-}"
|
||||||
for t in "$REPO"/tests/vm/[0-9]*.sh; do
|
for t in "$REPO"/tests/vm/[0-9]*.sh; do
|
||||||
|
[ -n "$ONLY" ] && case "$t" in *"$ONLY"*) ;; *) continue ;; esac
|
||||||
[ -e "$t" ] || continue
|
[ -e "$t" ] || continue
|
||||||
name="$(basename "$t")"
|
name="$(basename "$t")"
|
||||||
echo "=== $name ==="
|
echo "=== $name ==="
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ FAILED=0
|
|||||||
|
|
||||||
pf0 "insmod /tmp/pf.ko 2>/dev/null || insmod /opt/pf/pf.ko; true"
|
pf0 "insmod /tmp/pf.ko 2>/dev/null || insmod /opt/pf/pf.ko; true"
|
||||||
pf0 '/opt/pf/pfctl -e; /opt/pf/pfctl -f /dev/null' >/dev/null
|
pf0 '/opt/pf/pfctl -e; /opt/pf/pfctl -f /dev/null' >/dev/null
|
||||||
pfput tools/out/pdivert /opt/pf/pdivert || bad "pdivert deploy"
|
pfput ../../tools/out/pdivert /opt/pf/pdivert || bad "pdivert deploy"
|
||||||
pf0 'chmod +x /opt/pf/pdivert' >/dev/null
|
pf0 'chmod +x /opt/pf/pdivert' >/dev/null
|
||||||
|
|
||||||
cat > /tmp/g11.conf <<C
|
cat > /tmp/g11.conf <<C
|
||||||
|
|||||||
Reference in new issue
Block a user