All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	syzbot+1938db17e275e85dc328@syzkaller.appspotmail.com,
	Daniel Borkmann <daniel@iogearbox.net>,
	"David S. Miller" <davem@davemloft.net>
Subject: [PATCH 4.9 49/90] ipv6: restrict IPV6_ADDRFORM operation
Date: Thu, 19 Mar 2020 14:00:11 +0100	[thread overview]
Message-ID: <20200319123943.639252707@linuxfoundation.org> (raw)
In-Reply-To: <20200319123928.635114118@linuxfoundation.org>

From: Eric Dumazet <edumazet@google.com>

commit b6f6118901d1e867ac9177bbff3b00b185bd4fdc upstream.

IPV6_ADDRFORM is able to transform IPv6 socket to IPv4 one.
While this operation sounds illogical, we have to support it.

One of the things it does for TCP socket is to switch sk->sk_prot
to tcp_prot.

We now have other layers playing with sk->sk_prot, so we should make
sure to not interfere with them.

This patch makes sure sk_prot is the default pointer for TCP IPv6 socket.

syzbot reported :
BUG: kernel NULL pointer dereference, address: 0000000000000000
PGD a0113067 P4D a0113067 PUD a8771067 PMD 0
Oops: 0010 [#1] PREEMPT SMP KASAN
CPU: 0 PID: 10686 Comm: syz-executor.0 Not tainted 5.6.0-rc2-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
RIP: 0010:0x0
Code: Bad RIP value.
RSP: 0018:ffffc9000281fce0 EFLAGS: 00010246
RAX: 1ffffffff15f48ac RBX: ffffffff8afa4560 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8880a69a8f40
RBP: ffffc9000281fd10 R08: ffffffff86ed9b0c R09: ffffed1014d351f5
R10: ffffed1014d351f5 R11: 0000000000000000 R12: ffff8880920d3098
R13: 1ffff1101241a613 R14: ffff8880a69a8f40 R15: 0000000000000000
FS:  00007f2ae75db700(0000) GS:ffff8880aea00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000000a3b85000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 inet_release+0x165/0x1c0 net/ipv4/af_inet.c:427
 __sock_release net/socket.c:605 [inline]
 sock_close+0xe1/0x260 net/socket.c:1283
 __fput+0x2e4/0x740 fs/file_table.c:280
 ____fput+0x15/0x20 fs/file_table.c:313
 task_work_run+0x176/0x1b0 kernel/task_work.c:113
 tracehook_notify_resume include/linux/tracehook.h:188 [inline]
 exit_to_usermode_loop arch/x86/entry/common.c:164 [inline]
 prepare_exit_to_usermode+0x480/0x5b0 arch/x86/entry/common.c:195
 syscall_return_slowpath+0x113/0x4a0 arch/x86/entry/common.c:278
 do_syscall_64+0x11f/0x1c0 arch/x86/entry/common.c:304
 entry_SYSCALL_64_after_hwframe+0x49/0xbe
RIP: 0033:0x45c429
Code: ad b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00 00 66 90 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 7b b6 fb ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007f2ae75dac78 EFLAGS: 00000246 ORIG_RAX: 0000000000000036
RAX: 0000000000000000 RBX: 00007f2ae75db6d4 RCX: 000000000045c429
RDX: 0000000000000001 RSI: 000000000000011a RDI: 0000000000000004
RBP: 000000000076bf20 R08: 0000000000000038 R09: 0000000000000000
R10: 0000000020000180 R11: 0000000000000246 R12: 00000000ffffffff
R13: 0000000000000a9d R14: 00000000004ccfb4 R15: 000000000076bf2c
Modules linked in:
CR2: 0000000000000000
---[ end trace 82567b5207e87bae ]---
RIP: 0010:0x0
Code: Bad RIP value.
RSP: 0018:ffffc9000281fce0 EFLAGS: 00010246
RAX: 1ffffffff15f48ac RBX: ffffffff8afa4560 RCX: dffffc0000000000
RDX: 0000000000000000 RSI: 0000000000000000 RDI: ffff8880a69a8f40
RBP: ffffc9000281fd10 R08: ffffffff86ed9b0c R09: ffffed1014d351f5
R10: ffffed1014d351f5 R11: 0000000000000000 R12: ffff8880920d3098
R13: 1ffff1101241a613 R14: ffff8880a69a8f40 R15: 0000000000000000
FS:  00007f2ae75db700(0000) GS:ffff8880aea00000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: ffffffffffffffd6 CR3: 00000000a3b85000 CR4: 00000000001406f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

Fixes: 604326b41a6f ("bpf, sockmap: convert to generic sk_msg interface")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Reported-by: syzbot+1938db17e275e85dc328@syzkaller.appspotmail.com
Cc: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 net/ipv6/ipv6_sockglue.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

--- a/net/ipv6/ipv6_sockglue.c
+++ b/net/ipv6/ipv6_sockglue.c
@@ -184,9 +184,15 @@ static int do_ipv6_setsockopt(struct soc
 					retv = -EBUSY;
 					break;
 				}
-			} else if (sk->sk_protocol != IPPROTO_TCP)
+			} else if (sk->sk_protocol == IPPROTO_TCP) {
+				if (sk->sk_prot != &tcpv6_prot) {
+					retv = -EBUSY;
+					break;
+				}
+				break;
+			} else {
 				break;
-
+			}
 			if (sk->sk_state != TCP_ESTABLISHED) {
 				retv = -ENOTCONN;
 				break;



  parent reply	other threads:[~2020-03-19 13:11 UTC|newest]

Thread overview: 94+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-19 12:59 [PATCH 4.9 00/90] 4.9.217-rc1 review Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 01/90] NFS: Remove superfluous kmap in nfs_readdir_xdr_to_array Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 02/90] phy: Revert toggling reset changes Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 03/90] net: phy: Avoid multiple suspends Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 04/90] cgroup, netclassid: periodically release file_lock on classid updating Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 05/90] gre: fix uninit-value in __iptunnel_pull_header Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 06/90] ipv6/addrconf: call ipv6_mc_up() for non-Ethernet interface Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 07/90] net: macsec: update SCI upon MAC address change Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 08/90] net: nfc: fix bounds checking bugs on "pipe" Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 09/90] r8152: check disconnect status after long sleep Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 10/90] bnxt_en: reinitialize IRQs when MTU is modified Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 11/90] fib: add missing attribute validation for tun_id Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 12/90] nl802154: add missing attribute validation Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 13/90] nl802154: add missing attribute validation for dev_type Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 14/90] macsec: add missing attribute validation for port Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 15/90] net: fq: add missing attribute validation for orphan mask Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 16/90] team: add missing attribute validation for port ifindex Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 17/90] team: add missing attribute validation for array index Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 18/90] nfc: add missing attribute validation for SE API Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 19/90] nfc: add missing attribute validation for vendor subcommand Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 20/90] ipvlan: add cond_resched_rcu() while processing muticast backlog Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 21/90] ipvlan: do not add hardware address of master to its unicast filter list Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 22/90] ipvlan: egress mcast packets are not exceptional Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 23/90] ipvlan: do not use cond_resched_rcu() in ipvlan_process_multicast() Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 24/90] ipvlan: dont deref eth hdr before checking its set Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 25/90] macvlan: add cond_resched() during multicast processing Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 26/90] net: fec: validate the new settings in fec_enet_set_coalesce() Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 27/90] slip: make slhc_compress() more robust against malicious packets Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 28/90] bonding/alb: make sure arp header is pulled before accessing it Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 29/90] cgroup: memcg: net: do not associate sock with unrelated cgroup Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 30/90] net: phy: fix MDIO bus PM PHY resuming Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 31/90] virtio-blk: fix hw_queue stopped on arbitrary error Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 32/90] iommu/vt-d: quirk_ioat_snb_local_iommu: replace WARN_TAINT with pr_warn + add_taint Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 33/90] workqueue: dont use wq_select_unbound_cpu() for bound works Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 34/90] drm/amd/display: remove duplicated assignment to grph_obj_type Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 35/90] cifs_atomic_open(): fix double-put on late allocation failure Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 36/90] gfs2_atomic_open(): fix O_EXCL|O_CREAT handling on cold dcache Greg Kroah-Hartman
2020-03-19 12:59 ` [PATCH 4.9 37/90] KVM: x86: clear stale x86_emulate_ctxt->intercept value Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 38/90] ARC: define __ALIGN_STR and __ALIGN symbols for ARC Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 39/90] efi: Fix a race and a buffer overflow while reading efivars via sysfs Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 40/90] iommu/vt-d: dmar: replace WARN_TAINT with pr_warn + add_taint Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 41/90] iommu/vt-d: Fix a bug in intel_iommu_iova_to_phys() for huge page Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 42/90] nl80211: add missing attribute validation for critical protocol indication Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 43/90] nl80211: add missing attribute validation for beacon report scanning Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 44/90] nl80211: add missing attribute validation for channel switch Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 45/90] netfilter: cthelper: add missing attribute validation for cthelper Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 46/90] mwifiex: Fix heap overflow in mmwifiex_process_tdls_action_frame() Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 47/90] iommu/vt-d: Fix the wrong printing in RHSA parsing Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 48/90] iommu/vt-d: Ignore devices with out-of-spec domain number Greg Kroah-Hartman
2020-03-19 13:00 ` Greg Kroah-Hartman [this message]
2020-03-19 13:00 ` [PATCH 4.9 50/90] efi: Add a sanity check to efivar_store_raw() Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 51/90] batman-adv: Fix double free during fragment merge error Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 52/90] batman-adv: Fix transmission of final, 16th fragment Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 53/90] batman-adv: Initialize gw sel_class via batadv_algo Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 54/90] batman-adv: Fix rx packet/bytes stats on local ARP reply Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 55/90] batman-adv: Use default throughput value on cfg80211 error Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 56/90] batman-adv: Accept only filled wifi station info Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 57/90] batman-adv: fix TT sync flag inconsistencies Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 58/90] batman-adv: Avoid spurious warnings from bat_v neigh_cmp implementation Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 59/90] batman-adv: Always initialize fragment header priority Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 60/90] batman-adv: Fix check of retrieved orig_gw in batadv_v_gw_is_eligible Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 61/90] batman-adv: Fix lock for ogm cnt access in batadv_iv_ogm_calc_tq Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 62/90] batman-adv: Fix internal interface indices types Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 63/90] batman-adv: Avoid race in TT TVLV allocator helper Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 64/90] batman-adv: Fix TT sync flags for intermediate TT responses Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 65/90] batman-adv: prevent TT request storms by not sending inconsistent TT TLVLs Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 66/90] batman-adv: Fix debugfs path for renamed hardif Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 67/90] batman-adv: Fix debugfs path for renamed softif Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 68/90] batman-adv: Avoid storing non-TT-sync flags on singular entries too Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 69/90] batman-adv: Fix multicast TT issues with bogus ROAM flags Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 70/90] batman-adv: Prevent duplicated gateway_node entry Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 71/90] batman-adv: Fix duplicated OGMs on NETDEV_UP Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 72/90] batman-adv: Avoid free/alloc race when handling OGM2 buffer Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 73/90] batman-adv: Avoid free/alloc race when handling OGM buffer Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 74/90] batman-adv: Dont schedule OGM for disabled interface Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 75/90] batman-adv: update data pointers after skb_cow() Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 76/90] batman-adv: Avoid probe ELP information leak Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 77/90] batman-adv: Use explicit tvlv padding for ELP packets Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 78/90] perf/amd/uncore: Replace manual sampling check with CAP_NO_INTERRUPT flag Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 79/90] ACPI: watchdog: Allow disabling WDAT at boot Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 80/90] HID: apple: Add support for recent firmware on Magic Keyboards Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 81/90] HID: i2c-hid: add Trekstor Surfbook E11B to descriptor override Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 82/90] cfg80211: check reg_rule for NULL in handle_channel_custom() Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 83/90] net: ks8851-ml: Fix IRQ handling and locking Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 84/90] mac80211: rx: avoid RCU list traversal under mutex Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 85/90] signal: avoid double atomic counter increments for user accounting Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 86/90] jbd2: fix data races at struct journal_head Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 87/90] ARM: 8957/1: VDSO: Match ARMv8 timer in cntvct_functional() Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 88/90] ARM: 8958/1: rename missed uaccess .fixup section Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 89/90] mm: slub: add missing TID bump in kmem_cache_alloc_bulk() Greg Kroah-Hartman
2020-03-19 13:00 ` [PATCH 4.9 90/90] ipv4: ensure rcu_read_lock() in cipso_v4_error() Greg Kroah-Hartman
2020-03-19 18:01 ` [PATCH 4.9 00/90] 4.9.217-rc1 review Naresh Kamboju
2020-03-19 23:35 ` Guenter Roeck
2020-03-21  0:48 ` shuah

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=20200319123943.639252707@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=syzbot+1938db17e275e85dc328@syzkaller.appspotmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.