From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0565AC4332F for ; Mon, 21 Nov 2022 11:53:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229878AbiKULxD (ORCPT ); Mon, 21 Nov 2022 06:53:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230283AbiKULxC (ORCPT ); Mon, 21 Nov 2022 06:53:02 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 043A6B1E7 for ; Mon, 21 Nov 2022 03:53:01 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B2E3EB80ED0 for ; Mon, 21 Nov 2022 11:52:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF753C433C1; Mon, 21 Nov 2022 11:52:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1669031578; bh=PRlyXJX/EoB22B1YvfHeY9Up/3/06WuMbFuAmE4CWX0=; h=Subject:To:Cc:From:Date:From; b=2SZPjz90Y+Gqu3yyMDi+uX7ewY7oz22+uWPBSbm5/OM6ogIJcY1Kb4ioo+hWt0XN0 +OOo4k9tFr3xn9DRZaCZ/e+RcEfOoOObGQk2tNrPuIgXOx3Epi4o1qGB9IbsMnt5RR ojyAMoHwbAulM/mGltt0wuR2NWMVRmCdpHI8OBCU= Subject: FAILED: patch "[PATCH] ceph: avoid putting the realm twice when decoding snaps fails" failed to apply to 5.4-stable tree To: xiubli@redhat.com, idryomov@gmail.com Cc: From: Date: Mon, 21 Nov 2022 12:52:39 +0100 Message-ID: <16690315599541@kroah.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch below does not apply to the 5.4-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . Possible dependencies: 51884d153f7e ("ceph: avoid putting the realm twice when decoding snaps fails") 2e586641c950 ("ceph: do not update snapshot context when there is no new snapshot") thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 51884d153f7ec85e18d607b2467820a90e0f4359 Mon Sep 17 00:00:00 2001 From: Xiubo Li Date: Wed, 9 Nov 2022 11:00:39 +0800 Subject: [PATCH] ceph: avoid putting the realm twice when decoding snaps fails When decoding the snaps fails it maybe leaving the 'first_realm' and 'realm' pointing to the same snaprealm memory. And then it'll put it twice and could cause random use-after-free, BUG_ON, etc issues. Cc: stable@vger.kernel.org Link: https://tracker.ceph.com/issues/57686 Signed-off-by: Xiubo Li Reviewed-by: Ilya Dryomov Signed-off-by: Ilya Dryomov diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c index 864cdaa0d2bd..e4151852184e 100644 --- a/fs/ceph/snap.c +++ b/fs/ceph/snap.c @@ -763,7 +763,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc, struct ceph_mds_snap_realm *ri; /* encoded */ __le64 *snaps; /* encoded */ __le64 *prior_parent_snaps; /* encoded */ - struct ceph_snap_realm *realm = NULL; + struct ceph_snap_realm *realm; struct ceph_snap_realm *first_realm = NULL; struct ceph_snap_realm *realm_to_rebuild = NULL; int rebuild_snapcs; @@ -774,6 +774,7 @@ int ceph_update_snap_trace(struct ceph_mds_client *mdsc, dout("%s deletion=%d\n", __func__, deletion); more: + realm = NULL; rebuild_snapcs = 0; ceph_decode_need(&p, e, sizeof(*ri), bad); ri = p;