Received: by 2002:a05:6a10:8a4d:0:0:0:0 with SMTP id dn13csp70946pxb; Thu, 12 Aug 2021 11:01:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkhtnTWgrej9PPQZ5vK7h3kSZaWRT4pSxu6M39j+1sDoRfQM/+ZfqPjMYRHHifgY0cFQTP X-Received: by 2002:a17:907:76a1:: with SMTP id jw1mr4861187ejc.238.1628791261563; Thu, 12 Aug 2021 11:01:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628791261; cv=none; d=google.com; s=arc-20160816; b=QPFjfYkjJGnb9HzhkbItdlxSe8z9GGmotQtpLRZQ++UXDQfdLBLOTGJU8uY8Ys1bjH CLt/vwkX1i4afqGmBA5xXyCZTUJgLwIlw4zph8TZUuKucumZb4uo/0mZeTnKMsaC6FTT JN7fiF7rD+L4FJYxcQ8T0bB2KntqAcjBQC0XeOoDU0DpAhfUcqj7xynyVZkTDSM2FHXG 0u+gyQ+1wye4gkdrimnV2qX9Z64MD+2V/W5HCu6Sq2P52WwvlCpJil45wo7fzisUkUdN KHKsW0ov4+kz+j3mmSqyEXiDeuE8KCNo2Pk7a61mAtfFu9FOZwchc1aYhW0ZxbnGiFhM GclQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ikZnRm2MVtJHm0Ia+fXtL9BHvKn2N23olNLH7huqioo=; b=QYSsp64LDPOHkrStMc1UX+0prc6Oa4hvXP7m2c7I3HKeelAgXdz7DSzV4oxuRK1F7h 7jbBt35cnVhaxieBATInKtbU2J/Qwl3KB0K5hWnbUGgDmL9bl9vse2NnnM6mCd9hDb9C FdQk8bsDotnOTCcwHVXJInZds89QxxtZW2hemKgCNHnNxf11KGSFVlk82/qvkBSEkr0q GP4FYEVGLjprtXZMx4Ep15YMEZTiWczDbX+3vP3t/Bcdd6GMcJ+pwzL0VaI8Yg6o2THd JWWCTT3ap7DeTZW1i0ee8yfrCGkPOIQCa9dDDTKzwj1TlYg5y+Wjx1uSk31PdBeja631 c6yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b="QSI/+PvP"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pj24si3290429ejb.143.2021.08.12.11.00.11; Thu, 12 Aug 2021 11:01:01 -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; dkim=pass header.i=@linux.dev header.s=key1 header.b="QSI/+PvP"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238308AbhHLPGO (ORCPT + 99 others); Thu, 12 Aug 2021 11:06:14 -0400 Received: from out1.migadu.com ([91.121.223.63]:30844 "EHLO out1.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234850AbhHLPGO (ORCPT ); Thu, 12 Aug 2021 11:06:14 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1628780748; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ikZnRm2MVtJHm0Ia+fXtL9BHvKn2N23olNLH7huqioo=; b=QSI/+PvPlE003ZXaIEqU/DOlYJI1rrLbLbUubnyaViGSpo+8aAep5PhhqhhoBSDWxq8+b3 vbAI5SHLL5NIic42TlY3BI2I1Wm0p6LKwx869q3DoOGai632ePiZX6cfuaRjXRpU6WDRah TSFmj37nTZtZ21WJ1XFqjFhjkjgWlk0= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Andrey Ryabinin , Marco Elver , Dmitry Vyukov , Alexander Potapenko , kasan-dev@googlegroups.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 8/8] kasan: test: avoid corrupting memory in kasan_rcu_uaf Date: Thu, 12 Aug 2021 17:05:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: andrey.konovalov@linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov kasan_rcu_uaf() writes to freed memory via kasan_rcu_reclaim(), which is only safe with the GENERIC mode (as it uses quarantine). For other modes, this test corrupts kernel memory, which might result in a crash. Turn the write into a read. Signed-off-by: Andrey Konovalov --- lib/test_kasan_module.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_kasan_module.c b/lib/test_kasan_module.c index fa73b9df0be4..7ebf433edef3 100644 --- a/lib/test_kasan_module.c +++ b/lib/test_kasan_module.c @@ -71,7 +71,7 @@ static noinline void __init kasan_rcu_reclaim(struct rcu_head *rp) struct kasan_rcu_info, rcu); kfree(fp); - fp->i = 1; + ((volatile struct kasan_rcu_info *)fp)->i; } static noinline void __init kasan_rcu_uaf(void) -- 2.25.1