Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp40005pxb; Tue, 12 Jan 2021 19:23:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcZjhxaqmXw8/1SauFOVHk/4yrqKoXsLnPD6tcjUD2KfM2OkFuRi2IKkk6izJAs31BouCi X-Received: by 2002:a17:906:3712:: with SMTP id d18mr71559ejc.178.1610508193016; Tue, 12 Jan 2021 19:23:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610508193; cv=none; d=google.com; s=arc-20160816; b=SAf7+kcTtGTqhnpz8HTDgUCN9aSuDjUUkhuzX2XZ+Zc31Y2ubUYet8UmmCQKqJZtEn 6KfQ8zZ5Nnwg8WLemiM+PQC62WPfaFy1/kE0ZZPT3y1+obSJtUQH5LEoBQlAmxEqgE9x qbFYMIBF0VrwnRA89m3+qmyajJqDek5x/Mi0fEzVovgE6kgPgTs22PURU9hB4JUG7vuc MbF/eMcTxqLEmC9zdI8haMRa/PeSrdpt64aygPMbwT2tn6wQo8s8P6OSgNl7vg335VOl pIOzPnB1R39M4MvRPevo+hhXzH7wFiTD2OR2nnpOgY3304IOLPpSj9rLMecA9jMRrjYB GNAg== 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=/vYKtRUvIW2ynJjXb8EKOHINwCaI0vhIQWTSSZNFGWc=; b=DqFhj4HILSqvdA39LtrdffHNMu+CBJtaFIjaqBeXTY6t+ZY0jXXgCdMTHiPghcarxG ukJmP2Te+93Rn2CC+q80nresChfJ/koWNNRJUP3KxQtuHUVLYvH82wVxrtZ810663Y2S VYiQo2n4KrkmzXGdVm3BjbFtKleL5rUDH7aDNr5JtQ7fPtG9IeXmDH2+vuEu/HPaLbAF wOKlJ8/IKPotz6RXaXPyAxSRN0hhl/jYKCHIgzcAYcZHjt/Q7taoOx75Ymu7LtRfZgKw JsR6sIrMMnSc9Dn3wUYq4OHSdhWFcigXT+1Li9ULYFLSt6E6nIJdzsgsxpxsDCkgau4i wfXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=Ww3KXfMq; 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 a15si312871edm.287.2021.01.12.19.22.49; Tue, 12 Jan 2021 19:23:13 -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=@google.com header.s=20161025 header.b=Ww3KXfMq; 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 S2394892AbhALWzg (ORCPT + 99 others); Tue, 12 Jan 2021 17:55:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394889AbhALWzg (ORCPT ); Tue, 12 Jan 2021 17:55:36 -0500 Received: from mail-ot1-x333.google.com (mail-ot1-x333.google.com [IPv6:2607:f8b0:4864:20::333]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82067C061575 for ; Tue, 12 Jan 2021 14:54:55 -0800 (PST) Received: by mail-ot1-x333.google.com with SMTP id o11so105526ote.4 for ; Tue, 12 Jan 2021 14:54:55 -0800 (PST) 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=/vYKtRUvIW2ynJjXb8EKOHINwCaI0vhIQWTSSZNFGWc=; b=Ww3KXfMqu1sID+h6joR8rNOtxPU4PNA7tn8XQ8NBQKSBnKwNcJ6+X9lq3PpgN+hH5C eAVVZ27v93yjtmKeKXFIUb5YpFgwY2sQVx6nMZ/K/nz+d7jZgnft0bnPIKAo07hmdX7J qbHJVc9RSX4qi+51lMX4wjcktwZk7Yk/hAGcsbs/yRKDvMJfFPaI4/DqV2cu84/SRYFA shVTnQRqHvqvXPEQuPPvZNWU8mD2p+mplAQHF/36TQLzIcLVCbvzbD2rhirHROBQ9T/l kGt5XvlCgeXjbrLIOMyKiG9+XIqT8r+iT+JwiyfHZq12hQBLJTa/QDWoUy8F1abiwCD4 hZAQ== 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=/vYKtRUvIW2ynJjXb8EKOHINwCaI0vhIQWTSSZNFGWc=; b=Umpv6A0HVxt4vavOZanjeRmIojCvg6PYBteZDWQd+72IbSx9g9c+Ws+/pfgsj0mPQc xoV0Yekh2Zi0XvZvJNZrld7/y93JCki7qGyggkvJYFneP/To/8rtNNTNzR137NFZ9SAj f1GC/ztPTORlB8RrBd5+kdYchoKhNZQuGagYttptInaBQJqJ1t9jWG81+DunNJ6WztEf hIfp0uZGQTqCgLNi6GZBr99clMTW+sCQ8siSvuqKwP40VHgfFqHSH4jGPcYKq1I6VcOV ap1uyOn7UnV8tBI35MoqS61EouO7EPIoDYV2YcQapBjpDcQMk5DIYIpQUfHOAMGAFnuc N2Ig== X-Gm-Message-State: AOAM533bKedNXWbbHVVv1MtStT73xXLNsG7gkAtM1BYcfc83vZd1vdXA /ujyv43zaKevnMdOW21NMxdyE/ul8E+W9WKCvXu8Rw== X-Received: by 2002:a05:6830:19ca:: with SMTP id p10mr1108587otp.233.1610492094692; Tue, 12 Jan 2021 14:54:54 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Marco Elver Date: Tue, 12 Jan 2021 23:54:43 +0100 Message-ID: Subject: Re: [PATCH 10/11] kasan: fix bug detection via ksize for HW_TAGS mode To: Andrey Konovalov Cc: Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Alexander Potapenko , Andrew Morton , Will Deacon , Andrey Ryabinin , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev , Linux ARM , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 12 Jan 2021 at 22:16, Andrey Konovalov wrote: > > On Tue, Jan 12, 2021 at 3:32 PM Marco Elver wrote: > > > > > +/* > > > + * Unlike kasan_check_read/write(), kasan_check_byte() is performed even for > > > + * the hardware tag-based mode that doesn't rely on compiler instrumentation. > > > + */ > > > > We have too many check-functions, and the name needs to be more precise. > > Intuitively, I would have thought this should have access-type, i.e. > > read or write, effectively mirroring a normal access. > > > > Would kasan_check_byte_read() be better (and just not have a 'write' > > variant because we do not need it)? This would restore ksize() closest > > to what it was before (assuming reporting behaviour is fixed, too). > > > > void kasan_poison(const void *address, size_t size, u8 value); > > > void kasan_unpoison(const void *address, size_t size); > > > -bool kasan_check_invalid_free(void *addr); > > > +bool kasan_check(const void *addr); > > > > Definitely prefer shorted names, but we're in the unfortunate situation > > of having numerous kasan_check-functions, so we probably need to be more > > precise. > > > > kasan_check() makes me think this also does reporting, but it does not > > (it seems to only check the metadata for validity). > > > > The internal function could therefore be kasan_check_allocated() (it's > > now the inverse of kasan_check_invalid_free()). > > Re: kasan_check_byte(): > > I think the _read suffix is only making the name longer. ksize() isn't > checking that the memory is readable (or writable), it's checking that > it's addressable. At least that's the intention of the annotation, so > it makes sense to name it correspondingly despite the implementation. > > Having all kasan_check_*() functions both checking and reporting makes > sense, so let's keep the kasan_check_ prefix. > > What isn't obvious from the name is that this function is present for > every kasan mode. Maybe kasan_check_byte_always()? Although it also > seems too long. > > But I'm OK with keeping kasan_check_byte(). This is fine. > Re kasan_check(): > > Here we can use Andrew's suggestion about the name being related to > what the function returns. And also drop the kasan_check_ prefix as > this function only does the checking. > > Let's use kasan_byte_accessible() instead of kasan_check(). Sounds reasonable to me. Thanks, -- Marco