Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3542025pxb; Mon, 24 Jan 2022 11:48:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJySmYjl5634P6sEAVBvCJHkStkT+mvu1am17LYdXw1eY2HIucNsimT2NXQfIz/JplJySooA X-Received: by 2002:a17:902:9001:b0:149:f2ae:6491 with SMTP id a1-20020a170902900100b00149f2ae6491mr15893761plp.39.1643053739481; Mon, 24 Jan 2022 11:48:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643053739; cv=none; d=google.com; s=arc-20160816; b=BYNSBTZrfXCa6YIrc8KNEv29BjYVwR3rJikSq/GnWgwqkl9tdBLSZwn7uyeECbq+uo PHupLLiKVjt2igUyxDxZ6eiIS6dPmSjZHzUGFrqx/vGp+EHRhI/Ne93+ggiKKdtr9o3O HKCx2SOerq5cGNPh/rSskD5vE9If6PDMBRnsXfBPvga4XNiA0cUNKB1NxtDGKa17EHqM Ta5aAOGu4SJnvvm1EXWB/9E6SPb5LxeP7lOUDLAUilDr9UOQJ5gSH0l32zytrdgOTBLu fMjEwacb4le1R2yZDkRzAUAiko5FgJ7ZCC9WjHhnu47MoYOuegVYdpBTTJUfSOxaJvdx M1Cw== 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=TniNgsonCV7N4x8CfBP962yTwJ3ZQbzv223ievd0EoQ=; b=I8y6aqQ++lCTVuDmpfCVWpgtTL1G6w7iglso2xbjLuXxqWMvtBO3n1vaXsUX+IB/TE eyTgLvqM5oFEZXTpl0xa+Sls5R4N6w+L23Gqqi0KAHCoDcBZp9PT1HYl66SZsAhKSdA3 sD3Y8M0HlESDPPjKDMgn4govmKyfCw5Vf24RAAcmoULLTssGznombNbLYkB3KvfEIaT7 qmdKP0KARXSKfRXBDoe9bEZfT0703nW6d72LMpJQRcOqrfeSQNF83idr/iJLEakbhHaz 8gfykjX6RI7mXYSBeYuFvueSySbJWJ8zDrjuB9VDgT34V3T1cCvAVNX76nQ1aF4ng1bx pX9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=brSquA7p; 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 v11si14099666plo.291.2022.01.24.11.48.47; Mon, 24 Jan 2022 11:48:59 -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=@linux.dev header.s=key1 header.b=brSquA7p; 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 S241752AbiAXSDo (ORCPT + 99 others); Mon, 24 Jan 2022 13:03:44 -0500 Received: from out2.migadu.com ([188.165.223.204]:12774 "EHLO out2.migadu.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244846AbiAXSDb (ORCPT ); Mon, 24 Jan 2022 13:03:31 -0500 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=1643047410; 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=TniNgsonCV7N4x8CfBP962yTwJ3ZQbzv223ievd0EoQ=; b=brSquA7pvtV2FBRNQzJOUCIAGYdb7D5HAXmOp14rYXj+sJbizo147V0zj2WxUBCsLFst66 IRxKue1OuhYIEazeVPz1+rhp2DQadk4N559XYjFZiot2lY/1AmGst60Pexq8x4IgbQl3mB VbFmCjsuR4cgIdjXQ5VGcGjjXWoJqrk= From: andrey.konovalov@linux.dev To: Andrew Morton Cc: Andrey Konovalov , Marco Elver , Alexander Potapenko , Dmitry Vyukov , Andrey Ryabinin , kasan-dev@googlegroups.com, linux-mm@kvack.org, Vincenzo Frascino , Catalin Marinas , Will Deacon , Mark Rutland , linux-arm-kernel@lists.infradead.org, Peter Collingbourne , Evgenii Stepanov , linux-kernel@vger.kernel.org, Andrey Konovalov Subject: [PATCH v6 08/39] kasan: only apply __GFP_ZEROTAGS when memory is zeroed Date: Mon, 24 Jan 2022 19:02:16 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: linux.dev Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrey Konovalov __GFP_ZEROTAGS should only be effective if memory is being zeroed. Currently, hardware tag-based KASAN violates this requirement. Fix by including an initialization check along with checking for __GFP_ZEROTAGS. Signed-off-by: Andrey Konovalov Reviewed-by: Alexander Potapenko --- mm/kasan/hw_tags.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/kasan/hw_tags.c b/mm/kasan/hw_tags.c index 0b8225add2e4..c643740b8599 100644 --- a/mm/kasan/hw_tags.c +++ b/mm/kasan/hw_tags.c @@ -199,11 +199,12 @@ void kasan_alloc_pages(struct page *page, unsigned int order, gfp_t flags) * page_alloc.c. */ bool init = !want_init_on_free() && want_init_on_alloc(flags); + bool init_tags = init && (flags & __GFP_ZEROTAGS); if (flags & __GFP_SKIP_KASAN_POISON) SetPageSkipKASanPoison(page); - if (flags & __GFP_ZEROTAGS) { + if (init_tags) { int i; for (i = 0; i != 1 << order; ++i) -- 2.25.1