Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp7415785yba; Thu, 2 May 2019 09:26:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqyF47L9wUgxdH4ke5qEw/dlWkgHacRrhXq39HbZeavxc+PLmxBOftax/QOTRD4WKKKFLDMC X-Received: by 2002:a63:d713:: with SMTP id d19mr4944029pgg.145.1556814385914; Thu, 02 May 2019 09:26:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556814385; cv=none; d=google.com; s=arc-20160816; b=vnh9ZwJvNzX0paaGFxcyRQLZVkgvyhPVOklYpGiHtI7t2ic7yoZXaZoVz9kCs+7YaF CUWtz83x5txMxmq+5+2BVLCVQZulM3wLz5yFQl2DeJTG9W66+s9EbO2NmViVufnv3YvX kopttHMpUtAPHyvCs49LaaYkKeUrcpkYUGm8UPo9t9Pa3dw6526V0baO7mQXL3CXOjaI yNgRYlYgcPBcuF5B1g7n7DLokg/iG5e5w0alM4sig7OUcjt0RWbAwxcc+QiRCIRMu8ca OunOOpdaKUZXB+XIJQvRGlE7+MmveDsICQO+qdPqJXKmQXe6PvR5wfMUC/1do0LvDY9N cBUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rEKMwcrb+5WeSacp64Kz5FEoKnzrouBIBJCgUjJL8pw=; b=U8lJUxiE93ENebMkGpwSkgF505WV4/4/8sdEApVF8zmlwjToiAMoO0k/3xRSqCGD7B O6bHNfANdlsKt8qSPdhdw+EP6cDDp1WrJugaqOQ9HsGA4wT82gZ5xe4UkncC2FQYCNzU UgdVHWdm6up5prTtCMfMaDm311GWOPCFYvWG5dR7KgSg05qel/755fkHTcizTd8W+wVs eIGWIwz+tWxva1+ALqUDzUUBrm7BLU0t0X0tIRFMyXq4OyPaWzCjwx7shrpYTSAhvazf DL//bwsV+ACcod1kq2eP6Y/zqSmycFmFS/GPE6Y4bO3PDJxD/OICEk46xC2b0xG6wfYU 7kvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LjkcsxEi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q127si32694344pgq.91.2019.05.02.09.26.09; Thu, 02 May 2019 09:26:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=LjkcsxEi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726466AbfEBQY7 (ORCPT + 99 others); Thu, 2 May 2019 12:24:59 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44369 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726381AbfEBQY7 (ORCPT ); Thu, 2 May 2019 12:24:59 -0400 Received: by mail-pl1-f194.google.com with SMTP id l2so1254075plt.11 for ; Thu, 02 May 2019 09:24:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rEKMwcrb+5WeSacp64Kz5FEoKnzrouBIBJCgUjJL8pw=; b=LjkcsxEigQRyF9OlwvXAi/j2a8iR0fHL5qiD6sBguYmhHkAwawMycCLskwUcIIVTez CARFExgvCLEQQCTf2E6r+e/meuaODxpr49RcPwVp/36qPFt1+sx/X1LnGMKdEJqDhoTt Fu6/5vIrBNQOofwhZEXvdJ14D4CTnasVx2JM5ifN5CyQsm31ZeWd696LBSmDM9RzQGQJ guhg0kow6boUf322o8sKzF7b0iL4J5xuKIjbTMQ54M1M+7mQ226GtBNEuJFBXykGgk9O dDy2mzG25rY1ChIRqqe+crGrlLlOel5BrkV7w9iYOIwiX+ULaQY5Q/sieG6s2iPjtIPT WKdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rEKMwcrb+5WeSacp64Kz5FEoKnzrouBIBJCgUjJL8pw=; b=LqhmwLcwD2GFvXvWVXvT57MSSelPEpHpLMKRW17jEpJlVFDHrUw7l8MrUkZRwqYKON /aC9j9LSUyLCLBDfH+HNp1Y8cNHuDUzgWIuMhGmRW7LBe6uhF2pP3GcMpWTgaWXf6oyr mx+/tUUZZG5HN4H0zn46v6NoUANu9RdxEG/kIQI0sOx5UIsOysdwIFgZqimCd7NgfsRH +QCtlOE/T2NccjiWjA8bvoDlxlqlokfNiCfDkc+pNCgigaawr3AoKarckHGIYMsyXxB+ NPRDhUgznbke5gtcxlcN4ijJQ2fIlknfPpI33VdZEKS0HW0ejl++L/ydDWnvxqtvYL+y xXNA== X-Gm-Message-State: APjAAAVudX3xH37xsBdsT341tASw/zrCBKaC+ZIBY2NiK8xHz7p2OzXe DMHAhLJoTwiA++XqZXrxJ0KGS6jhFgCpbNQJ5uYv0g== X-Received: by 2002:a17:902:56d:: with SMTP id 100mr1090671plf.246.1556814298380; Thu, 02 May 2019 09:24:58 -0700 (PDT) MIME-Version: 1.0 References: <20190502153538.2326-1-natechancellor@gmail.com> In-Reply-To: <20190502153538.2326-1-natechancellor@gmail.com> From: Andrey Konovalov Date: Thu, 2 May 2019 18:24:47 +0200 Message-ID: Subject: Re: [PATCH] kasan: Zero initialize tag in __kasan_kmalloc To: Nathan Chancellor Cc: Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , kasan-dev , Linux Memory Management List , LKML , Nick Desaulniers , clang-built-linux@googlegroups.com Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 2, 2019 at 5:36 PM Nathan Chancellor wrote: > > When building with -Wuninitialized and CONFIG_KASAN_SW_TAGS unset, Clang > warns: > > mm/kasan/common.c:484:40: warning: variable 'tag' is uninitialized when > used here [-Wuninitialized] > kasan_unpoison_shadow(set_tag(object, tag), size); > ^~~ > > set_tag ignores tag in this configuration but clang doesn't realize it > at this point in its pipeline, as it points to arch_kasan_set_tag as > being the point where it is used, which will later be expanded to > (void *)(object) without a use of tag. Just zero initialize tag, as it > removes this warning and doesn't change the meaning of the code. > > Link: https://github.com/ClangBuiltLinux/linux/issues/465 > Signed-off-by: Nathan Chancellor > --- > mm/kasan/common.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/kasan/common.c b/mm/kasan/common.c > index 36afcf64e016..4c5af68f2a8b 100644 > --- a/mm/kasan/common.c > +++ b/mm/kasan/common.c > @@ -464,7 +464,7 @@ static void *__kasan_kmalloc(struct kmem_cache *cache, const void *object, > { > unsigned long redzone_start; > unsigned long redzone_end; > - u8 tag; > + u8 tag = 0; Hi Nathan, Could you change this value to 0xff? This doesn't make any difference, since set_tag() ignores the tag anyway, but is less confusing, as all the non-tagged kernel pointers have 0xff in the top byte. Thanks! > > if (gfpflags_allow_blocking(flags)) > quarantine_reduce(); > -- > 2.21.0 > > -- > You received this message because you are subscribed to the Google Groups "kasan-dev" group. > To unsubscribe from this group and stop receiving emails from it, send an email to kasan-dev+unsubscribe@googlegroups.com. > To post to this group, send email to kasan-dev@googlegroups.com. > To view this discussion on the web visit https://groups.google.com/d/msgid/kasan-dev/20190502153538.2326-1-natechancellor%40gmail.com. > For more options, visit https://groups.google.com/d/optout.