Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp3569534pxp; Tue, 8 Mar 2022 17:42:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrxnziVIYSIwp7/zsVF/E+7Ozb73aXTcWef4ldP7SQ+YqprULZ+qGvt9aYMXfpbBEs/lWZ X-Received: by 2002:a17:902:e8c2:b0:151:cae6:46fa with SMTP id v2-20020a170902e8c200b00151cae646famr20444773plg.164.1646790166786; Tue, 08 Mar 2022 17:42:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646790166; cv=none; d=google.com; s=arc-20160816; b=hLRsBmRDZiUGf0eKcT57FN08ChoMA0slMebHIjs88E+e8LlE9M7jFdrNFvCvvgwx2W XS3xZfbyNssEgOMLGuKbFE4kzP2vReiF1t+InW6wxlMSpf9NDLUKUTMZi5EJtt2CZjop eoBqobpdN5OGe31aaxGPn3bGXr3lhxXCa39xi+SxWd2cYs22dzLT0rKJVrJXT/k0CJck 1IOav0ypUcorXCTLA677cxFSUsp7Mxgvzn+j5clFC3jUhPf2GmFz9dy+b7tLMW1BL/Pa AHvZkog7LtPMtI8gGp/S/FaD5i33f8VW8d3mIy64RPPFHIlM1pNVpZxoRm0uVOBQFa4f t4AQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=eqmkPSBm5WulTOgzZAJ0UbU+BwECVBvh4ECQqxckohA=; b=tO47KLwvDwsMjRtvmmDjubCzBadewTCMB+Bq5+YiRuEVzCtX+gF3+RrlKa7P5T0c11 OmX9i/P1PEMwmuXTOwlNX7QBrPVOtdJ/hZfzOvhZRy3uhKJAz/S7Yt9CVh2XFIO8t3x4 LnEFsJ/XDvpvUUs/A531mmncwW2kgI7+lfuRUrQKYjjSF8iqRJOu4T05v19/YoyuA2V6 4oycviYi25kwCfZZiV5w725jwDjP83LcxolhCD625Ivv9hf0CXqIW1thBoNbLmSLMdad Vzc82i5tribIr2G1ptWSBt1UpaYlMO5trYfivi+YDNNKFnoMPVMNQsRExt8n/dGL634I q4BQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hJpgRdv8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k70-20020a638449000000b0037c8b66e34bsi462748pgd.552.2022.03.08.17.42.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 17:42:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=hJpgRdv8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 31B8423F3E9; Tue, 8 Mar 2022 16:37:37 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343577AbiCHQzU (ORCPT + 99 others); Tue, 8 Mar 2022 11:55:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232531AbiCHQzS (ORCPT ); Tue, 8 Mar 2022 11:55:18 -0500 Received: from out2.migadu.com (out2.migadu.com [IPv6:2001:41d0:2:aacc::]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CEEB4EA31 for ; Tue, 8 Mar 2022 08:54:21 -0800 (PST) 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 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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()); -- 2.25.1