From patchwork Tue Mar 8 16:54:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: andrey.konovalov@linux.dev X-Patchwork-Id: 12774055 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2F5DC433F5 for ; Tue, 8 Mar 2022 16:54:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C05EB8D0002; Tue, 8 Mar 2022 11:54:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BB4118D0001; Tue, 8 Mar 2022 11:54:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AA25D8D0002; Tue, 8 Mar 2022 11:54:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0232.hostedemail.com [216.40.44.232]) by kanga.kvack.org (Postfix) with ESMTP id 984618D0001 for ; Tue, 8 Mar 2022 11:54:22 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4DC598248076 for ; Tue, 8 Mar 2022 16:54:22 +0000 (UTC) X-FDA: 79221817164.19.9B9CAC1 Received: from out2.migadu.com (out2.migadu.com [188.165.223.204]) by imf17.hostedemail.com (Postfix) with ESMTP id A6C744000B for ; Tue, 8 Mar 2022 16:54:21 +0000 (UTC) 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=1646758459; 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; bh=eqmkPSBm5WulTOgzZAJ0UbU+BwECVBvh4ECQqxckohA=; b=hJpgRdv8RgK9TlJiH3MjGiK4Cru06lqcFR6RrRaYZt1MQUfUFyKgz4IdNr171CRW6piMNv zwkyhl317eMF0enuZ+CJEViDwRjhzahLVbSPbQ6nfMBLo8PQxTxX2vk+cYrIH09lrNsGNC jrTIV4Dcy0XINDnxRqu7SeS+GKs2khU= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, Vasily Gorbik , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH mm] fix for "kasan, vmalloc: only tag normal vmalloc allocations" Date: Tue, 8 Mar 2022 17:54:17 +0100 Message-Id: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A6C744000B X-Stat-Signature: dhodjygd3j1fzbgwuu5aqiud1mxzj6h6 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=linux.dev header.s=key1 header.b=hJpgRdv8; spf=pass (imf17.hostedemail.com: domain of andrey.konovalov@linux.dev designates 188.165.223.204 as permitted sender) smtp.mailfrom=andrey.konovalov@linux.dev; dmarc=pass (policy=none) header.from=linux.dev X-HE-Tag: 1646758461-761024 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Andrey Konovalov "kasan, vmalloc: only tag normal vmalloc allocations" unintentionally disabled poisoning of executable memory for the Generic mode. Fix it. Reported-by: Vasily Gorbik Signed-off-by: Andrey Konovalov --- mm/kasan/shadow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/kasan/shadow.c b/mm/kasan/shadow.c index 7272e248db87..a4f07de21771 100644 --- a/mm/kasan/shadow.c +++ b/mm/kasan/shadow.c @@ -489,10 +489,11 @@ void *__kasan_unpoison_vmalloc(const void *start, unsigned long size, return (void *)start; /* - * Don't tag executable memory. + * Don't tag executable memory with the tag-based mode. * The kernel doesn't tolerate having the PC register tagged. */ - if (!(flags & KASAN_VMALLOC_PROT_NORMAL)) + if (IS_ENABLED(CONFIG_KASAN_SW_TAGS) && + !(flags & KASAN_VMALLOC_PROT_NORMAL)) return (void *)start; start = set_tag(start, kasan_random_tag());