Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp4728018pxt; Wed, 11 Aug 2021 12:38:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx7GrdxdTqs+4RPjlveoiyWEfWojsKk3E1FTiiZ+CBadjdi+n/zZob5yXTeqKSfYaNs0MtF X-Received: by 2002:a05:6402:3551:: with SMTP id f17mr618025edd.261.1628710685981; Wed, 11 Aug 2021 12:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628710685; cv=none; d=google.com; s=arc-20160816; b=ON8muyEIr6ctejwlXEK3+mRumPdx4/UUeaS0/50RrIODQBaSx6U7bJ6Y25IXeRXPFQ VILGPAxPbgAZyJToDtFvK/g6kfxYLIW4Pnx1VliIQdY60zg1jz1DFfmgDfL9mphpRuGT lT4sqIZx2KmZcXPmU3VcCDFbfpb2g/AZo5B+FeUo2E5DGMGEb/A6hl3bJyRg/tcOw11W YewY5MM0184L9n6VzONxAbw9PZyZ3Gm5BgtK3iO4T9ajKxuuJo+u/SiAgTQswLmMSdqU icl0zKswcBt58CRHYdkWo8XLMnYmMz5efyV0gyIxGIiynBaARjTv+Mp0aYOI0loMPTNI sw0Q== 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=0l1GpD/EBXEEFuxuZaZS0CGvNgrQFSex/pUPWvtHU3kXWAR76IKE6Db1CcqeqMRh5M 2DjpwSWGT8G9pK5T5G9SJUR43xTHprcbkVH6aqqiRHCndYt1YVvCFU2OzSLRu4bDthpm UqsLcHqd9y6AuJ9G+CBQZoic2yWO0ElVVVhEgx9edyijHwmv8EHtae6YYBGTrqmEes8V YUnXRdDLY3p1OoAacfcSh+A70rWKPnW8Lw8sRk6P6fjqzJCachiBVMMMXvxkGLBGfv+j U5QEQXVcG3M0JnaOl6hzhJ41tXAqIcDiRciu8JanLr278p7tpaHrnd3U79Ftl+aZm9Ic Zt7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=gLxXIwem; 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 v3si243458edq.144.2021.08.11.12.37.42; Wed, 11 Aug 2021 12:38:05 -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=gLxXIwem; 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 S231659AbhHKTe3 (ORCPT + 99 others); Wed, 11 Aug 2021 15:34:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230471AbhHKTe2 (ORCPT ); Wed, 11 Aug 2021 15:34:28 -0400 Received: from out1.migadu.com (out1.migadu.com [IPv6:2001:41d0:2:863f::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59755C061765 for ; Wed, 11 Aug 2021 12:34:04 -0700 (PDT) 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=1628710442; 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=gLxXIwemBjQyLG6H9gnaaiLf4noXa4CpUotGNEpTCNeDc+YIsb3ZUKCDdyrbZIwh+d17/k di/+fVQOTW/CUtH/7mP5M2cl879hHF9yRUx9absN4HBAz8+DQm5BPcIALMg4YU8IJEeUtD Q29ZB92XMCPsehZlG2fCGFYEv4PZ7FE= 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 8/8] kasan: test: avoid corrupting memory in kasan_rcu_uaf Date: Wed, 11 Aug 2021 21:34:00 +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