Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2572243pxj; Mon, 14 Jun 2021 01:50:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHEjy64mKlF+AW56GXX7EBN2ea1FhY5cNYBE04PgeQ3AKbOO2gEcbH9JNyCPRNP7KBJKn1 X-Received: by 2002:a17:906:25db:: with SMTP id n27mr13959128ejb.170.1623660659143; Mon, 14 Jun 2021 01:50:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623660659; cv=none; d=google.com; s=arc-20160816; b=yK21S48m18S2ayjDWKqIDdNdVbqhUAqeOSeynXZYnHzTTsHTSRRGgjlblCtiylCgrl GzSFRBKsDMszMcmJiTq5oveuJ9kFGC0U0MNDn1b4oVubpszy2b+opNYA9K1s5KUk7wPZ cFcNdoZLUqedxX6E1jn00iwfPhwU7GJFoHNehsb1xn/o5Qa/Na6Ll63HxAa+OGxbet3m 4jkj2Eu0jWsxKe9HqZQKrG21B+AgI9R+IfvP0zsoef3W+SpjB8EopxjAbNg8B73FzfDc ZK5rDA/1R5IIOjt873mCXdDyQ35EUOCWhrLO3vq7hrvjJeQsulwaws1pCtafbDOxZiGr 04uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=g5pXCAj2QuRES1o2pFYr1kobiKA7QQMUK/Q0IqCq9h8=; b=zrbjL9QcIYMOatx4pcDfhuUbTRMdCxnPpMiNOVmW/iKETpxT6sluobMgQA/eGCRfds nCpAxLw9yjbmeauZ9wBLzCQnxLQL80O5X2gj8O2yx1xOiyGzlVV+fyyFs/1qUON40LIR LKtbZJEz/C2r8XqtonZGMpEfJ3BoXuG6Spjq8Rza+/Zvwxqk6gox3bRPaNE2Lp9xllUG TB/i7mEdkE4Nh1Tm4aja3bGcOHoQy4h6dc4dw9xE1ZkDrqawJ1XoOPjBVK/deEmfNML0 8YyiZ7VXMzQ5ubiHYu09DHyj1eRIb3ycAKfsmS/m1ODHZWu2Yxwk41rpXeWllW0Plfdb V3cA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=VWEYtLKR; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s17si11575999ejm.137.2021.06.14.01.50.36; Mon, 14 Jun 2021 01:50:59 -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=@google.com header.s=20161025 header.b=VWEYtLKR; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232648AbhFNIu7 (ORCPT + 99 others); Mon, 14 Jun 2021 04:50:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232632AbhFNIu6 (ORCPT ); Mon, 14 Jun 2021 04:50:58 -0400 Received: from mail-oi1-x236.google.com (mail-oi1-x236.google.com [IPv6:2607:f8b0:4864:20::236]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CFE5C061574 for ; Mon, 14 Jun 2021 01:48:40 -0700 (PDT) Received: by mail-oi1-x236.google.com with SMTP id l12so5922884oig.2 for ; Mon, 14 Jun 2021 01:48:40 -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=g5pXCAj2QuRES1o2pFYr1kobiKA7QQMUK/Q0IqCq9h8=; b=VWEYtLKRoyzykCKCWKAnyyeFrhGqGLwAOXy2u3vartWNSYoGumsrbuXEw3exPA57bA S5OQDe8cZc6Mmh2yHw/F3JzUdhVWvLB+6MNC3tQZ2Yxls847Ssku94TD0W0mWL8kDITn CMQUqIG/gyOF8G+UA5KZE5oeGGcu9+kgbqY8O4ICYygUfnxb2S0Y2wNlWg6fRyqj3tPg JZS+ZsUUEJR65v1WYyKCEuPQitf1oAilKEVRt3DPfTOBv9J9GPzt+uRK2cHF0tR/1F2N ndXXMhMJx2wCiryXN7Y3zvVr/hblikY3DQS/7Bn6G3redPtk55bc6+YxS4m8iiyxcUdn vKbA== 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=g5pXCAj2QuRES1o2pFYr1kobiKA7QQMUK/Q0IqCq9h8=; b=TWVzpqg2MGcNF9NZrrH9YL05mP7SUxabJ7jtuQ0CgC4pPyQVdC8yU85u0J3v5I+vSm JyJ7TyLR6qFssxrKxxhSqX2VwIJMyH5fLxmUd8evjTRVsHgES3rgOis1DyELOe5+gBXK J+0SUx/bzFwhTlAHmqqo4SeQw61z7AlawIrv92RE99XVGoVA80pyo4H6nF4tA2NdUPCh i71ODKDl2U4l3Ffa02gfaC309wrEleMGtVAMwGzGgBT7qeYfPn3FrpkQKFOmSwbxA1QY 5jVOXpVXbVykB0VsM2MQjraw7flEg5OinFeNruE+abZDOHFfr5CI/4XLG46Y6BF4rHa2 vv6g== X-Gm-Message-State: AOAM530hWwbJmzxSgd8vlxV6QFAviUwEB0L8YKF+frS5jq/D1eHrgz+3 TmhaHmpVSv2tGBc/SAAfF4xjKeLdGflJTvjStx34hg== X-Received: by 2002:aca:120f:: with SMTP id 15mr3849142ois.172.1623660519486; Mon, 14 Jun 2021 01:48:39 -0700 (PDT) MIME-Version: 1.0 References: <20210612045156.44763-1-kylee0686026@gmail.com> <20210612045156.44763-3-kylee0686026@gmail.com> <20210612155108.GA68@DESKTOP-PJLD54P.localdomain> In-Reply-To: <20210612155108.GA68@DESKTOP-PJLD54P.localdomain> From: Marco Elver Date: Mon, 14 Jun 2021 10:48:27 +0200 Message-ID: Subject: Re: [PATCH v2 2/3] kasan: integrate the common part of two KASAN tag-based modes To: Kuan-Ying Lee Cc: Greg Kroah-Hartman , Andrey Ryabinin , Alexander Potapenko , Andrey Konovalov , Dmitry Vyukov , Andrew Morton , kasan-dev , LKML , Linux Memory Management List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. [...] > > > 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). Thanks, -- Marco