Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2802117pxb; Mon, 19 Apr 2021 14:30:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxVOVQdAhwz5/7OlfZikTTlOusw1qUMUgsFZA11GKQZpG4xCLEJOjcyy4LHnry5g8MXoA5u X-Received: by 2002:a63:3704:: with SMTP id e4mr13544215pga.125.1618867835657; Mon, 19 Apr 2021 14:30:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618867835; cv=none; d=google.com; s=arc-20160816; b=z71D6ZRdGXK/UThDo/xwusQh4omtgcM/Ebx2Zf+0wF14ADJQCUrGpJvUBcZL5iaHmC 4GVLZ1ll8upBylmcGf8Ax7uFm9IH9JOuWt3jgS2I3sXe5tc0rL3i06fHx6FO6UBhIeEc vFJQijRFWMLZR0y51LYE0xJE3p36b3Xzi+3e/6EbgiLSo419p/q06iq69SLa7Hd5Zm3i QAB4evIzzgMuzaO4OY02AuiW1BEPfYYtaygjRCsDa6I6xEBO6HU21y2VHm+IM10R1AOs mHAgw0xpEPkBbcRMYbJJnv8F32lefHW1J7cBD+sdMLJsgULHT1q8h/ikY9xw7ZpSD3I1 bweA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=9igbe0gRG1HZemKk/+x11TlURy+G6gDL7VBI3gQeua4=; b=xQaaPmRLrZJDFATdGEewtEmBjGZUfu3bDrOPa47MetsYOY23yi56Kq+O20w/pM0QeI Qh0aSA0dfm9YNkqkG+CZFkEOPCJ4iuD4CkPZ47sxpneEBvs8QtblaJW9kpJgO9QNMAW3 qm9eeGtB+4K4Eb6zy4XUnb0UjMTqsl5qIGsoQrs2pf6ogWr8bmnTBa53txn3iZ0Le6xi iJafjWC8t1KPEh9BbvhmxsonEbHy7qrR6EZ5f4LC/lUQZsJ8OoGH+Uj9IlwK3AJwyyl7 mbteLvNC0+8C59J8VyET1qD5OFNzZmGT+rixq1HOyaiqGZEB/b6m5yHOxcf1PSu820O2 vheA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si673530pjh.156.2021.04.19.14.30.22; Mon, 19 Apr 2021 14:30:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240387AbhDSVaD (ORCPT + 99 others); Mon, 19 Apr 2021 17:30:03 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:46346 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbhDSVaC (ORCPT ); Mon, 19 Apr 2021 17:30:02 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 4CE431C0B7A; Mon, 19 Apr 2021 23:29:31 +0200 (CEST) Date: Mon, 19 Apr 2021 23:29:30 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Aditya Pakki , Santosh Shilimkar , "David S. Miller" , Sasha Levin Subject: Re: [PATCH 5.10 042/103] net/rds: Avoid potential use after free in rds_send_remove_from_sock Message-ID: <20210419212930.GA6626@amd> References: <20210419130527.791982064@linuxfoundation.org> <20210419130529.251281725@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="ReaqsoxgOBHFXBhH" Content-Disposition: inline In-Reply-To: <20210419130529.251281725@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ReaqsoxgOBHFXBhH Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > [ Upstream commit 0c85a7e87465f2d4cbc768e245f4f45b2f299b05 ] >=20 > In case of rs failure in rds_send_remove_from_sock(), the 'rm' resource > is freed and later under spinlock, causing potential use-after-free. > Set the free pointer to NULL to avoid undefined behavior. This patch is crazy. Take a look at Message-ID: <20210419084953.GA28564@amd>. Or just look at the patch :-). Best regards, Pavel > +++ b/net/rds/message.c > @@ -180,6 +180,7 @@ void rds_message_put(struct rds_message *rm) > rds_message_purge(rm); > =20 > kfree(rm); > + rm =3D NULL; > } > } > EXPORT_SYMBOL_GPL(rds_message_put); > diff --git a/net/rds/send.c b/net/rds/send.c > index 985d0b7713ac..fe5264b9d4b3 100644 > --- a/net/rds/send.c > +++ b/net/rds/send.c > @@ -665,7 +665,7 @@ static void rds_send_remove_from_sock(struct list_hea= d *messages, int status) > unlock_and_drop: > spin_unlock_irqrestore(&rm->m_rs_lock, flags); > rds_message_put(rm); > - if (was_on_sock) > + if (was_on_sock && rm) > rds_message_put(rm); > } > =20 --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --ReaqsoxgOBHFXBhH Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAmB99joACgkQMOfwapXb+vIAGQCgnL84YaGH4RnXJ87ZuqGryccv qM0AoMJI8M8nrmObS7svKsM+A4zKVp2Q =Ms63 -----END PGP SIGNATURE----- --ReaqsoxgOBHFXBhH--