Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp19355lqb; Thu, 14 Mar 2024 04:27:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVP1Gl56ENTreY/5j9GpHHpeDu2je2UEFe9BcAccDeK29ZeIDeGX2ouuKRxgrSfZW5jxW1vs0NdMCwfXfVfk9a6ZmzSM3dwbbdlCehLHw== X-Google-Smtp-Source: AGHT+IG2b4+R6x3FBFIHK64JiuGp89nrOBHOesZlSVoLDeDyrCUQKuGu70G1AVt5rYy8o8tTmUts X-Received: by 2002:a05:6830:12c1:b0:6e4:efdb:bb4d with SMTP id a1-20020a05683012c100b006e4efdbbb4dmr321164otq.24.1710415632589; Thu, 14 Mar 2024 04:27:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710415632; cv=pass; d=google.com; s=arc-20160816; b=RDdNzv822MkkOseetBLzxV4aSAeai/KkBM+Na62lGuyuV6OIqmq2aaaCSQN7yUk/QD Q5WoH8bkPoYlIelUwpaIGco6TKwMN3P1bEfdjCrMMTP6iLPQc2EYMGPf7+YAfiVERMrs yvHWiwKHZsPDAi6+Q/MGbUPbiz2vJfZfAl6N4v8P2z6JeVaFHpvSF+ULyVndHMM4OP5/ yt/FAH6nVmSSpQj8L9IpCr8jVdZocDHtITXXLvae9Ltty2E4eVWzfKmZ7qPKi9gHUF5s ssGQH7hlmZ5NkVz4Q6SgEJW+Smm0PU4Cn/GdKkjUknxl7v7lihm48rWuC5o999BM49lX N0LQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=HcnGTxzwSyg9C56RLpB5Ch8/g/1o9jC21sSmcNAT61o=; fh=2kZG7ca5lykaV+0U9ERbUZAA9KMppqjkNyiM1MAmfRU=; b=AvXivFJzxJiUOjq3oCF1shwy10SNzZ5uizx7a0UFO5YFByWHqz+e3vYfP5STqZZawF GNBaVuEVJBF22zl1WDRIw+0eHqDxrtKMmsvp1hzVGJ+68pldvb9rbj/43Q6zWcMArGMl QqcaV4LUv/eY+NqXXIooWenGbAL7YkPRoSUI4KhPXrNM0tHYQ8qsUw5rhruC1yK3x+Qi b/1Md1NIAgFE21KHyegJRhx7R2JhnZxPKvWz6V8j3GIPAMob99AWKhgQTq+AoVoDhFBs 43n72yN+n+TStiKaj7QTiiLSOLfenNt0hSN7ve4T+0J8P02N+6eGXBzvmDXBKI+ctPtw dqpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=strlen.de); spf=pass (google.com: domain of linux-kernel+bounces-103172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103172-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l6-20020a635706000000b005dbec91be93si381107pgb.595.2024.03.14.04.27.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 04:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=strlen.de); spf=pass (google.com: domain of linux-kernel+bounces-103172-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103172-linux.lists.archive=gmail.com@vger.kernel.org" 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 1B8A7284043 for ; Thu, 14 Mar 2024 11:27:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C0A636EB6F; Thu, 14 Mar 2024 11:27:02 +0000 (UTC) Received: from Chamillionaire.breakpoint.cc (Chamillionaire.breakpoint.cc [91.216.245.30]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C1DA86CDD7; Thu, 14 Mar 2024 11:26:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.216.245.30 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710415622; cv=none; b=os1C0NkHzNlZD9wv8TGK4Eebzaq/5JEJVNk+h5pW5H/yp+K3bTOO/JPljDpGtN+jjOQArr9Hdligy6oI+kZHliaKTDPBfxQavb7Bfk8jowwLr9h/RgomdZFA+2RgQeLCjGdnOWtsogOBP6DxDcCzsxPib85J9yhpp5ACm5sRPbM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710415622; c=relaxed/simple; bh=Pfd2z0WcwpHP46x04wMSW5dBhXIY/2MfqS+g3TP/9Sc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=c0yTYRQjtnfHshBti3p29+hm67Q7rnfREn8V0Ng3wLYNOe0l5pTvTyKlFJdi8ZIBzpolVeKLwX1G8aRa0VRth8yUT3mmejFUug8GtoKq5TfmfSzwbAUGNqApoR4m5uU184SG18jOIprov+aQyyQbEdNhUWQg2qkttSdFhd/WpKI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de; spf=pass smtp.mailfrom=strlen.de; arc=none smtp.client-ip=91.216.245.30 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=strlen.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=strlen.de Received: from fw by Chamillionaire.breakpoint.cc with local (Exim 4.92) (envelope-from ) id 1rkjEZ-0006nC-0U; Thu, 14 Mar 2024 12:26:51 +0100 Date: Thu, 14 Mar 2024 12:26:50 +0100 From: Florian Westphal To: Eric Dumazet Cc: Florian Westphal , 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 Subject: Re: KASAN: slab-use-after-free Read in ip_finish_output Message-ID: <20240314112650.GE1038@breakpoint.cc> References: <20240306103632.GC4420@breakpoint.cc> <20240312132107.GA1529@breakpoint.cc> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Eric Dumazet wrote: > Thanks for taking a look Florian. > > Perhaps not messing with truesize at all would help ? > > Something based on this POC : > > spin_lock(&qp->q.lock); > + if (!qp->q.sk) { > + struct sock *sk = skb->sk; > > + if (sk && refcount_inc_not_zero(&sk->sk_refcnt)) > + qp->q.sk = sk; Unfortunetely I did not get this to work. sk_refcnt is 0. sk is kept alive by sock_wfree destructor. I don't know how to recover from this, refcnt cannot be "repaired" anymore. I could artificially inflate sk_wmem counter by 1, to prevent release, but that needs yet another sock_wfree-like destructor. I'm already not sure how this existing scheme works, there are multiple places that check for skb->destructor == sock_wfree, yet we have is_skb_wmem helper that checks __sock_wfree and tcp_wfree. Removing defrag from output seems like best option, but it will surely break some scenarios. Or, I could just fail reasm if sk refcount is already 0, that would likely work too?