Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2095237pxj; Sat, 19 Jun 2021 02:47:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRBr3VPlWifKXlBCdn47Gq/Uk8Vr+LYKr4YfvUjtlzs7mtLjVfoE0JhEEgJ/swk0vQDMXR X-Received: by 2002:a05:6402:2789:: with SMTP id b9mr9898532ede.142.1624096066568; Sat, 19 Jun 2021 02:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624096066; cv=none; d=google.com; s=arc-20160816; b=l4Femcxr/Z3jIMy4gbG/RdcSI4u6MtD3dBM0+dsw1dDYgeXaXkVM+rkZQQ2umC9L8e fJaF3LytMRrjUqTe/6E7cNPKwKLt9MO0s7qJsm8St7zoGAtlq/XOZR4ICYIh2WZbB8og oWJ3fxbQXfhvewQgWUFLHNAnQZFEsNwFOHtsl1AloNWLvrxq6c5eascpW1pH2t2QeEfX NoH5C8GyeAM+Uu1imwWcHdVKQRPbnJ+cC161QE7/q08CGvPLk7kiXfE1b2qXYLzvwrYT xXKiY6XQFmPWgrZCmranuMfMClpGTrCEKYnlmR9lD5S3uPePiaonhY4Rt5kM+AGF0EEa JQuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=7O6NiC7BTr3eVGuJkmQkcqtgkrwhWl7/Qlj0XvSRQpU=; b=AzrP1Et1u3ljQRkCu78OoxORJ2n+FWA+CykqQbXdkTdgZp43cM5BoMOXAMwm471QJH 3aI+KQ0w83BeA/Orin8Oh0rXWvMm60YFWdd3Jp/uJwVo82GLEX5aEY0OsIffxx+MBShc t8TgRf8ujqYGZdsW9BEkDASa9FKRLmkOd0iW5g2x++1B/BA4iFLUfVLjXV8Nnk7Ou+8F 5DV8Exn8rZr+2qAXNt+MIhxWl9kQT2sRSEeeMGkOs7psFHswo2spZu75Qj3igkx0LTwL Vy8ETOq1n0BxH/AbonuUkmHls3W1LKjd1EYHR2rx39Dmd2Zod55EYqKhBVtT+qFWYRTP HHNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="Tq/B3Mqq"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e25si7501599eds.427.2021.06.19.02.47.24; Sat, 19 Jun 2021 02:47:46 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b="Tq/B3Mqq"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233527AbhFSGmC (ORCPT + 99 others); Sat, 19 Jun 2021 02:42:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231637AbhFSGmC (ORCPT ); Sat, 19 Jun 2021 02:42:02 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9F25C061574 for ; Fri, 18 Jun 2021 23:39:51 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id 13-20020a17090a08cdb029016eed209ca4so7197383pjn.1 for ; Fri, 18 Jun 2021 23:39:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=7O6NiC7BTr3eVGuJkmQkcqtgkrwhWl7/Qlj0XvSRQpU=; b=Tq/B3MqqSOHiSwlMSBlAYi++SRSc0W8ikCH4QbmMFDYjnsnF22a3XeZ0jTtKi9GMwL dAOvvYOsSTxeljnKvWyRuOtiKvrOILA38Nzmja/VETR1+9l32dEWcfmzTa8tvq3+KAe2 DafAfJEyu1ZEbj7Vl6kbIORMFPKB/JhDDwAm5v7f2h+x7KFEzFK9WQsR2A54xoZS4ZUz zIYPkgP747yuEaCG6WxGqiAYqW6uQlg/MDPQkThdkibUlDkiRhPiEhZ+XxtTUtUWiQG8 CZIdc8EztIAJpu1pH4/WYBUPCMTa3CwEFD7rbw7S5UQkGlSNxJpMQxehLkcR3hFflZIL iS1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=7O6NiC7BTr3eVGuJkmQkcqtgkrwhWl7/Qlj0XvSRQpU=; b=tp52qHZz6djC+778k4Scw8Mr/NKmws9s02CYNTFmRCmNzcMISkr0hohJrH3bfYaU3U 9stos8n1GFiJzZbXRNoFGfhWvqErcdSqT8GUCEbFEL84uGrThGRsAlqKf4ls8hiqXFH3 kleLfr8yKgxyvXXoIcFN4mKvRu0FkHpFgCAgjGctlilb/cWX7y+LjozUFRRWiiuXEls4 jrb+MkV/PRQ0RwEvcm4cWXolnC9X6IbDHuEEVxOljGWbqTI0pet2Vo4YUNGJ/bFDwCkX KCnSWCEcT9+iJYfK7RqP9In4U8jmmFG7zK/wS0Mk+2nGUfSBD0CWQ+lhvaP70VfBL8bG sN+w== X-Gm-Message-State: AOAM530q7bGAejmd1GNWkvwSn5S3HrWuI5XAy3g1O1VGvZLXLKlL2DZJ EANPhG8LD3y9Nh1+1oIK5Ew= X-Received: by 2002:a17:902:9a8c:b029:113:d891:2eaf with SMTP id w12-20020a1709029a8cb0290113d8912eafmr8117146plp.61.1624084791379; Fri, 18 Jun 2021 23:39:51 -0700 (PDT) Received: from DESKTOP-PJLD54P.localdomain (122-116-74-98.HINET-IP.hinet.net. [122.116.74.98]) by smtp.gmail.com with ESMTPSA id t13sm3566599pfq.173.2021.06.18.23.39.49 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jun 2021 23:39:50 -0700 (PDT) Date: Sat, 19 Jun 2021 14:39:42 +0800 From: Kuan-Ying Lee To: Marco Elver Cc: Greg Kroah-Hartman , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Andrew Morton , kasan-dev , LKML , Linux Memory Management List Subject: Re: [PATCH v2 2/3] kasan: integrate the common part of two KASAN tag-based modes Message-ID: <20210619063942.GA67@DESKTOP-PJLD54P.localdomain> References: <20210612045156.44763-1-kylee0686026@gmail.com> <20210612045156.44763-3-kylee0686026@gmail.com> <20210612155108.GA68@DESKTOP-PJLD54P.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 14, 2021 at 10:48:27AM +0200, Marco Elver wrote: > On Sat, 12 Jun 2021 at 17:51, Kuan-Ying Lee wrote: > [...] > > > > diff --git a/mm/kasan/report_tags.h b/mm/kasan/report_tags.h > > > > new file mode 100644 > > > > index 000000000000..4f740d4d99ee > > > > --- /dev/null > > > > +++ b/mm/kasan/report_tags.h > > > > @@ -0,0 +1,56 @@ > > > > +/* SPDX-License-Identifier: GPL-2.0 */ > > > > +#ifndef __MM_KASAN_REPORT_TAGS_H > > > > +#define __MM_KASAN_REPORT_TAGS_H > > > > + > > > > +#include "kasan.h" > > > > +#include "../slab.h" > > > > + > > > > +#ifdef CONFIG_KASAN_TAGS_IDENTIFY > > > > +const char *kasan_get_bug_type(struct kasan_access_info *info) > > > > +{ > > > [...] > > > > + /* > > > > + * If access_size is a negative number, then it has reason to be > > > > + * defined as out-of-bounds bug type. > > > > + * > > > > + * Casting negative numbers to size_t would indeed turn up as > > > > + * a large size_t and its value will be larger than ULONG_MAX/2, > > > > + * so that this can qualify as out-of-bounds. > > > > + */ > > > > + if (info->access_addr + info->access_size < info->access_addr) > > > > + return "out-of-bounds"; > > > > > > This seems to change behaviour for SW_TAGS because it was there even > > > if !CONFIG_KASAN_TAGS_IDENTIFY. Does it still work as before? > > > > > > > You are right. It will change the behavior. > > However, I think that if !CONFIG_KASAN_TAG_IDENTIFY, it should be reported > > "invalid-access". > > There's no reason that if !CONFIG_KASAN_TAG_IDENTIFY it should be > reported as "invalid-acces" if we can do better without the additional > state that the config option introduces. > > It's trivial to give a slightly better report without additional > state, see the comment explaining why it's reasonable to infer > out-of-bounds here. > > > Or is it better to keep it in both conditions? > > We want to make this patch a non-functional change. > Got it. > [...] > > > > diff --git a/mm/kasan/tags.c b/mm/kasan/tags.c > > > > new file mode 100644 > > > > index 000000000000..9c33c0ebe1d1 > > > > --- /dev/null > > > > +++ b/mm/kasan/tags.c > > > > @@ -0,0 +1,58 @@ > > > > +// SPDX-License-Identifier: GPL-2.0 > > > > +/* > > > > + * This file contains common tag-based KASAN code. > > > > + * > > > > + * Author: Kuan-Ying Lee > > > > > > We appreciate your work on this, but this is misleading. Because you > > > merely copied/moved the code, have a look what sw_tags.c says -- that > > > should either be preserved, or we add nothing here. > > > > > > I prefer to add nothing or the bare minimum (e.g. if the company > > > requires a Copyright line) for non-substantial additions because this > > > stuff becomes out-of-date fast and just isn't useful at all. 'git log' > > > is the source of truth. > > > > This was my first time to upload a new file. > > Thanks for the suggestions. :) > > I will remove this author tag and wait for Greg's process advice. > > > > > > > > Cc'ing Greg for process advice. For moved code, does it have to > > > preserve the original Copyright line if there was one? > > Greg responded, see his emails. Please preserve the original header > from the file the code was moved from (hw_tags.c/sw_tags.c). Ok. I will do it in v3. Thanks. > > Thanks, > -- Marco