Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp994079lqs; Wed, 6 Mar 2024 03:13:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX56iQemcDT7pYDCQLzupl+/pD+n1eV9yWFjHAhIUy95tpRAzJdkAMXBaIChgA6Nq3tNj4dq3mKSe/pwxmc2olQBcJGa/hxS0TvKyQcgg== X-Google-Smtp-Source: AGHT+IGJwTtlPp0rGEMff+iDlUCVOMiwCATw6q1zN0668m1M8KXzSNhb5bYcDfs6SY1342+vUExq X-Received: by 2002:a05:6a20:4a18:b0:1a1:1eb7:83e1 with SMTP id fr24-20020a056a204a1800b001a11eb783e1mr3699428pzb.46.1709723616540; Wed, 06 Mar 2024 03:13:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709723616; cv=pass; d=google.com; s=arc-20160816; b=qt8mFPIX7kuM+TKtgjSb+KDq66LSC/S+/vHOFePzqJARyw4S8VXUDAJkxpuEG0YLdp K8wznSLgWJYcMW0LRmX8uEbxYmGZli1gZWGyAyfaYp7IkgLMk545cO68HheNd7Ky976y wIcQv1i4J9UrldVQ52CdW2zo5MO8xFnnwVGYlEV4pNWueweUgpis2+IsHi+CIWVu6p4O zke0I/P3CbfJ1bqNyoLY/GRsV5m+WATK+/SiPx56b7dkGZl8sjH7Q7TOhN3V7v59OV9a /LVzrS7JkLr2gTBH3SGu1HUo/WKUeQuNzf+p4ZU3dheYZdxh3j11NQE5fh6LGIbmZBPb dJoA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=Ac6YIjBtpRzsjYOfKs4hkAM2nX9AEZlTxzGX/yk4mrs=; fh=YSdIjj5gfqg9E0iC8Vboy6DOzzbcfmG+T+ejMM4M8WU=; b=0OJqjc/f733Y+dh53h9YN5w0X9q0n7Wf5MGJk1ulsH2EerycScKPAB610xxrN0+LhV LbBgAK9L8xDIk2X0fjiKVvK+8VHYL1DwYPCMz99MzOWeqIr53jA+9x69Lp+DsLrIg2YO aOtCbLrIFkOf6tlV8EDZhox2ZuaOlU/siy1iEIkab98yckPZvcrN5pgNkPtCTss3m89Y OPmNfs47ASMVkFB2y+vt3MnDahR6TEtql7RObKVAWSQ88jzY+VtrJceRR9oRaANIa3hv lrFgt9MBs/Pe/p5T2e/XYc2h9hHoQmbDrAaYlyGeuWvlTvWoSMEhzPdryH8fZpRpmr+1 JlGw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Lihvn/1/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-93784-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id pc18-20020a17090b3b9200b0029b793cc36esi837837pjb.19.2024.03.06.03.13.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 03:13:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-93784-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="Lihvn/1/"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-93784-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-93784-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 05EA9B2A3D6 for ; Wed, 6 Mar 2024 10:42:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 01B3C605BF; Wed, 6 Mar 2024 10:41:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Lihvn/1/" Received: from mail-ed1-f50.google.com (mail-ed1-f50.google.com [209.85.208.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88E735FDA3 for ; Wed, 6 Mar 2024 10:41:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721714; cv=none; b=mOoMq/xDR3VXYzoGEK4CvNYkFuK3urERsCf7IaK06RfSE/zRMOsGPeKckqEWbwYNTPba0Zc5E2Vk5bdQmaqoWkibDAFWZBwnn6FHT/K7dTahLFGIU037SQN/nd8YaE2RUriDmo3dqeUvxsqVPPXefFIKjKFC0MY+fW921PJ9ryU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709721714; c=relaxed/simple; bh=kCwidvlR/A9CZ3q+xHAYLCMO3jQlBiTdIei1p1YIerU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=Ps0WWJx9xOHXCWUl32gsi6rQgF8xw4lC4Z2zmIZojgYCkEy8uLcHH4f/A9/vTEExnyfZMzrs2wUDW4Zccx232x9Lfakcv02Ua2UqsQ403F2+/rfKHK8RZe7i8ublXDMWg0yqv31/CUwTFrQt3Gjj5++nMjVDj1s8hJFSjqy5P0g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=Lihvn/1/; arc=none smtp.client-ip=209.85.208.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f50.google.com with SMTP id 4fb4d7f45d1cf-56693f0d235so10013a12.0 for ; Wed, 06 Mar 2024 02:41:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1709721711; x=1710326511; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Ac6YIjBtpRzsjYOfKs4hkAM2nX9AEZlTxzGX/yk4mrs=; b=Lihvn/1/JEvvXKojUB0fIfZDbzvjdKfl837FTVMgGH5vFRFC31/LlEM04hBfxrH/7C qlMNi6EnTx/JNJAnmW58f8RoGGHHALz9aVd8hn3w0FShlSj5UpkW6prA8qJXX8YizH+Z NGS9vOBsCNVOUSYU3R0lsfeWf65lR9RiCugzT6xK6swXlct6ws/6ZQVKOypMrZA02hbO B63hIEJIaeHpx9YaqH6eidnQg/SX7w94Qr4MwGJUb2XyVm3Hbcyjq26PS57jDnHxge9m UEE/Hqw8mlo5WuX6ZnakaF0guGWCZqAayoJvhSQfivH0rqhFsOI9FvGLI8yywr7imh+x KkKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709721711; x=1710326511; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ac6YIjBtpRzsjYOfKs4hkAM2nX9AEZlTxzGX/yk4mrs=; b=v4EfIs7EHUc91YETqOruwXd2PYSZ3IIcI20RMtIPheSZuD4J/20J0abL3mbztsDG5T XTqmk6asEiEpTKPu7RoDgwfL+PB44LZqeWbEfQP2RxMZVm/ZSWjSuHSfkZuJEakLe62H wuHlx2NNRHhJtuNqVhURDXF1/PRMnwnyxePNVqMuk7eQh1vnYywBB1Gb9ljeP1ird3J1 eVytVGOhMcxqHxVN9O7qcP0OZwzl1QmdNXZcpsPMMhdaDhIx67Hz3HQPbyemgig+OrM9 lqftfhxApkiHMfAoobXmu4vWgnugvDj4+Uwro/9ZB9eeCVzK4yssSUvwf3UaGLgE4IBA rFzg== X-Forwarded-Encrypted: i=1; AJvYcCV4zpqW6htPo4pZJ76wf+WzHSZuJh2sNO0OMS0Q+Xekc/LrQU/ILxNHtE6WWDLMnD4QnPygAiasaZ7P7LYJp2gFXGwWaTr9UnHHHtFW X-Gm-Message-State: AOJu0YzRV9V6yBcAWXarDSFzl+e1v/gWUtd8vtSxpLbM1T6a3t8SumtZ iteY3S3eAI02h0wejv3MP6tCrObVNFll/QXDwc84hRE0jKwC6LswTC91wXyOSbbIdOAr0c7nR+s NAV+zyeOH1Mb/bi6SipDvmzvii1BK8MCVq8dC X-Received: by 2002:a50:ef03:0:b0:566:b5f5:48cc with SMTP id m3-20020a50ef03000000b00566b5f548ccmr351403eds.5.1709721710584; Wed, 06 Mar 2024 02:41:50 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240306103632.GC4420@breakpoint.cc> In-Reply-To: <20240306103632.GC4420@breakpoint.cc> From: Eric Dumazet Date: Wed, 6 Mar 2024 11:41:39 +0100 Message-ID: Subject: Re: KASAN: slab-use-after-free Read in ip_finish_output To: Florian Westphal Cc: xingwei lee , pabeni@redhat.com, davem@davemloft.net, kuba@kernel.org, linux-hams@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, ralf@linux-mips.org, syzkaller-bugs@googlegroups.com, samsun1006219@gmail.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Mar 6, 2024 at 11:36=E2=80=AFAM Florian Westphal wro= te: > > Eric Dumazet wrote: > > On Wed, Mar 6, 2024 at 11:00=E2=80=AFAM xingwei lee wrote: > > > > > > Hello, I found a new bug titled "KASAN: slab-use-after-free Read in > > > ip_finish_output=E2=80=9D or =E2=80=9CKASAN: slab-use-after-free in s= k_to_full_sk" and > > > confirmed it in the latest net and net-next branch. After my simple > > > analysis, it may be related to the net/rose or AF_PACKET/PF_PACKET > > > socket. > > > > I already had a syzbot report for this issue, thanks. > > > > Adding Florian to the discussion. > > The issue is cause by ip defrag layer, which calls skb_orphan() > > These were my notes, I had little time to work on it so far. > > > Calling ip_defrag() in output path is also implying skb_orphan(), > > which is buggy because output path relies on sk not disappearing. > > Ugh. Thanks for your annotations and notes, this is very helpful. > > ipvlan (and two spots in ip_output.c do): > > err =3D ip_local_out(net, skb->sk, skb); > > so skb->sk gets propagated down to __ip_finish_output(), long > after connrack defrag has called skb_orphan(). > > No idea yet how to fix it, My plan was to refine "inet: frag: Always orphan skbs inside ip_defrag()" and only do the skb_orphan() for skb added to a frag_list. The head skb would keep a reference to the socket.