Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1143707rdb; Wed, 20 Sep 2023 00:16:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEtDXRzKk6kqt5Z6wQQoSQJfnkTgc5LUdqIuj25EBTVtUnUmKn6j2cm8TT3LeSn24aSxG3I X-Received: by 2002:a17:902:cecd:b0:1c3:76c4:7242 with SMTP id d13-20020a170902cecd00b001c376c47242mr2505048plg.22.1695194219288; Wed, 20 Sep 2023 00:16:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695194219; cv=none; d=google.com; s=arc-20160816; b=J0I57GswG7T5kQF7QymLKP8CKBRu2W8vbVYMsPqxjcf4pdv7oPk7c0zXlw650jJjKw lpClk3/3Yf7RRhvetxy8R2Y5CXxgi0+fwvyTugxDyyzkLNL3xwovzMOoDTViehKManLG WeNRJjpbLu9Uggob/4fx8lCeMkgE6/i6mHVQ0uM1oCrc9NQctPFDEXAKBYHLgHW6JZTf e6U/S9c7h6pM18w+7QYcrWZv7rG5WOsgwT98tzdVQXpgqwFFlIVPQuOPLottWi2sUT/C mu8XJ4DvVaJuFf691/7K9yoY3mzH+bWlxJC+4vrj+dF5IbTIYg7cdAzCcHOLgYai7SB1 /mzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:content-transfer-encoding:mime-version :message-id:date:subject:from:dkim-signature; bh=YRuxyP2Lr18YkAtZqWqB+DRG/19pIAkB1hJ2ZB+N0/I=; fh=fKawFa2YyhiNtmBUWJyXPPFKAYTFYbgxUOXBfiSj/go=; b=RJNNgwgL6UuKs4WVM60lH2jGAlWwe2euzZBMIlUKkIrdNmQ8E/zCjLeAQAUfie0CMm eKrMM1AU36OzyvoMEeX+6Etkx9hLfIy8/0RI+YsS6i5XkpUFvlT8/nAiDu0NQkV/r7q9 xD5QsOq+nD7CCpkRUm7Mnym60JadYYyYZTOJRTskKMEg5xMvcDhzuuJNnnkvHL1k36MM dHC+5Xt5mDpHMO9ib64vzSBEWdwEPpRumSPGhojfXvjO9h+fdftdCDGytc+GUCzo3Cnc 0+PbXNl1srjJelvpoEmm99IA6ty+cHLqFLOuWPxr0OxCMBZl0bZIt739mtOK3qTR8TXg /vAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=FBEXyDGq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id t2-20020a170902e84200b001c5bb1f0cd1si1139450plg.253.2023.09.20.00.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 00:16:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@riseup.net header.s=squak header.b=FBEXyDGq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=riseup.net Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id D84398303B0A; Tue, 19 Sep 2023 23:12:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232999AbjITGMI (ORCPT + 99 others); Wed, 20 Sep 2023 02:12:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231455AbjITGMH (ORCPT ); Wed, 20 Sep 2023 02:12:07 -0400 Received: from mx1.riseup.net (mx1.riseup.net [198.252.153.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 392D08F for ; Tue, 19 Sep 2023 23:12:02 -0700 (PDT) Received: from fews01-sea.riseup.net (fews01-sea-pn.riseup.net [10.0.1.109]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx1.riseup.net (Postfix) with ESMTPS id 4Rr7Ts2vPTzDqfj; Wed, 20 Sep 2023 06:12:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=riseup.net; s=squak; t=1695190321; bh=sOqNuutYvTFy5bCHZpYC06+WkQct7O1GJJ6LUpEjpv4=; h=From:Subject:Date:To:Cc:From; b=FBEXyDGqg9CpP2lxNAyNPERXt3OCywVSaROB6twCglRK2Yw6DvC7Hfgm6blm9Mty6 BPO25NqIP8LQEy+V2jnQJwsM1uwfySu3w4c3SbiW/IXwZvrUkJE/zLWNkdpgYRLvyw J9o3ofk1qS9+v2O1EP8YaETpLIBf388xFzm3Sgf0= X-Riseup-User-ID: AA6E7953033817810A380B10C6E1134D69C821369C3632F1DA6F752157C0C3DD Received: from [127.0.0.1] (localhost [127.0.0.1]) by fews01-sea.riseup.net (Postfix) with ESMTPSA id 4Rr7TZ3qMKzJmsF; Wed, 20 Sep 2023 06:11:46 +0000 (UTC) From: Arthur Grillo Subject: [PATCH 0/3] Fix a couble of bugs in drm_kunit_helpers.c Date: Wed, 20 Sep 2023 03:11:35 -0300 Message-Id: <20230920-kunit-kasan-fixes-v1-0-1a0fc261832d@riseup.net> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-B4-Tracking: v=1; b=H4sIABeNCmUC/x3LwQpAQBCA4VfRnE2NddjhVeSwMZjU0g5S8u42x 6+//wGTpGLQFg8kudR0ixlVWcCwhDgL6pgNjlxNTcW4nlEPXIOFiJPeYsgs4pnIkWfI357kD3n r+vf9ANLoEQljAAAA To: David Airlie , Daniel Vetter , Maxime Ripard , Javier Martinez Canillas , Brendan Higgins , David Gow Cc: tales.aparecida@gmail.com, andrealmeid@riseup.net, mairacanal@riseup.net, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, kunit-dev@googlegroups.com, Arthur Grillo X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 19 Sep 2023 23:12:12 -0700 (PDT) This patchset started when I found a use-after-free error reported by KASAN while running some tests that did some mocking. When trying to fix the initial problem, I found another noon-related one. The second bug is just a wrong argument passed to a kunit_release_action call. Patch #1 solves that. Patches #2 and #3 solve the use-after-free bug. This error was a bit trickier to find. Basically, the usual order in which the kunit_actions run is the culprit, so #2 creates a helper function to reorder actions, and #3 uses that helper. Signed-off-by: Arthur Grillo --- Arthur Grillo (3): drm/tests: Fix kunit_release_action ctx argument kunit: Add kunit_move_action_to_top_or_reset() to reorder actions drm/tests: Fix a use-after-free bug in __drm_kunit_helper_alloc_drm_device() drivers/gpu/drm/tests/drm_kunit_helpers.c | 18 +++++++++++++++++- include/kunit/resource.h | 17 +++++++++++++++++ lib/kunit/resource.c | 19 +++++++++++++++++++ 3 files changed, 53 insertions(+), 1 deletion(-) --- base-commit: 37454bcbb68601c326b58ac45f508067047d791f change-id: 20230918-kunit-kasan-fixes-88ee78002078 Best regards, -- Arthur Grillo