Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9109329pxu; Mon, 28 Dec 2020 06:53:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJwmO16A/C5xCmWr7ZPcxxQHKZBaojpAgUyrV79iqh4JICJmEdYE+u98+dBhGdrLDiocfSSW X-Received: by 2002:a17:906:4e53:: with SMTP id g19mr41286050ejw.454.1609167195321; Mon, 28 Dec 2020 06:53:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167195; cv=none; d=google.com; s=arc-20160816; b=jq4a/06xt+9JnBVsWaMrtlZqohDudhiTTwXYCWHENGTtD0qaz3hneKH8k9Uw1CO8gn 9IcrOFSiqTQ5TRjmBx5c/9hcOkaqesgbBeKNKR4T22Np14E6vkebRD6caZ7Jl51jlwsE pOK4MQ2l4Rwt6qvNytNtZKW3Sckjo7Sgqlad6TRfZd1gKquzvKLvKvstaJYQKXrkOz8I kSbUg4aFyzM7DaDMTvMdkoWNzaqrfnbiAirOKw2hWoTJKPOlKwkReISHLYJ6z1T8hOkT psO2RPzm1QceqFEpROMNXckg+P3MjKZXun0zGQjqaUi37nzzL9xhMbLS77RO5lY4Jdm/ uDVA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nElJhXaUncv5vTwphU9KIagcFXk3oi89+D1qDQ2RVRQ=; b=hAgjnO/XqxpkXZhAz1Augqq8iiTayGHjBkmT13nUli8khzuSIuUKWl6pHTaRyPTiMB THjSj2vPQc4/A/T/nFMkeYz5MyFIHxeJsRsJkipEitpDAHoJyovst6tfs3h2vMkGq0ac X765THn5j5ELPFPtmXcrtfC+zcfG98wjQMy4SlTEjqPGRNl8AmZeWbP/cQvlBUyP4rlj I4A8xDOg1TtJ7v+QURQgGnhBcxufpL6FySE79MencjBHpPnxWVESD4t4eWNHAt/KsL6S aTS8lozlFHMIk+vHFW8kxyeUxJ0ipYjNr+DU77rrP33bb+H7AXUks1c3s/vGrE48nqN1 h4Ww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MKJaFvAi; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p20si20231804eds.141.2020.12.28.06.52.52; Mon, 28 Dec 2020 06:53:15 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=MKJaFvAi; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437906AbgL1OVZ (ORCPT + 99 others); Mon, 28 Dec 2020 09:21:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:56442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2502207AbgL1OVC (ORCPT ); Mon, 28 Dec 2020 09:21:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9C59E20791; Mon, 28 Dec 2020 14:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165216; bh=mPmKAdohop4jaoZA/YxlgERgOmGMVxNu2YzXJicrU9U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MKJaFvAiZCpjO/22ru63iHm3attIV4/wb6zZ8C0HLVzIJnYUqMBOH21zoIglKQJKV X3MCa85klVNkj+1ef+cyYmvu5PkmGtwpkYbQqt+byO7R3yiwq1+ipPlZNMx0vdnYtZ fS61OmjnT3LhrM5WTtMbYLPHsiuN3wd5tFq6nSfo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vincenzo Frascino , Andrey Konovalov , Dmitry Vyukov , Andrey Ryabinin , Alexander Potapenko , Marco Elver , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.10 454/717] mm/vmalloc.c: fix kasan shadow poisoning size Date: Mon, 28 Dec 2020 13:47:32 +0100 Message-Id: <20201228125042.721318825@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vincenzo Frascino [ Upstream commit c041098c690fe53cea5d20c62f128a4f7a5c19fe ] The size of vm area can be affected by the presence or not of the guard page. In particular when VM_NO_GUARD is present, the actual accessible size has to be considered like the real size minus the guard page. Currently kasan does not keep into account this information during the poison operation and in particular tries to poison the guard page as well. This approach, even if incorrect, does not cause an issue because the tags for the guard page are written in the shadow memory. With the future introduction of the Tag-Based KASAN, being the guard page inaccessible by nature, the write tag operation on this page triggers a fault. Fix kasan shadow poisoning size invoking get_vm_area_size() instead of accessing directly the field in the data structure to detect the correct value. Link: https://lkml.kernel.org/r/20201027160213.32904-1-vincenzo.frascino@arm.com Fixes: d98c9e83b5e7c ("kasan: fix crashes on access to memory mapped by vm_map_ram()") Signed-off-by: Vincenzo Frascino Cc: Andrey Konovalov Cc: Dmitry Vyukov Cc: Andrey Ryabinin Cc: Alexander Potapenko Cc: Marco Elver Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- mm/vmalloc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index 75913f685c71e..279dc0c96568c 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -2256,7 +2256,7 @@ static void __vunmap(const void *addr, int deallocate_pages) debug_check_no_locks_freed(area->addr, get_vm_area_size(area)); debug_check_no_obj_freed(area->addr, get_vm_area_size(area)); - kasan_poison_vmalloc(area->addr, area->size); + kasan_poison_vmalloc(area->addr, get_vm_area_size(area)); vm_remove_mappings(area, deallocate_pages); -- 2.27.0