From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.3 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47683C433E0 for ; Fri, 15 Jan 2021 14:04:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id EC0B3208E4 for ; Fri, 15 Jan 2021 14:04:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EC0B3208E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 2A4748D017C; Fri, 15 Jan 2021 09:04:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 252CF8D0162; Fri, 15 Jan 2021 09:04:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 143278D017C; Fri, 15 Jan 2021 09:04:38 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0060.hostedemail.com [216.40.44.60]) by kanga.kvack.org (Postfix) with ESMTP id F28AC8D0162 for ; Fri, 15 Jan 2021 09:04:37 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AF66B3642 for ; Fri, 15 Jan 2021 14:04:37 +0000 (UTC) X-FDA: 77708179794.20.spy66_20065012752f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin20.hostedemail.com (Postfix) with ESMTP id 8CD79180C07AB for ; Fri, 15 Jan 2021 14:04:37 +0000 (UTC) X-HE-Tag: spy66_20065012752f X-Filterd-Recvd-Size: 4836 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) by imf46.hostedemail.com (Postfix) with ESMTP for ; Fri, 15 Jan 2021 14:04:37 +0000 (UTC) Received: by mail-qk1-f181.google.com with SMTP id z11so11681399qkj.7 for ; Fri, 15 Jan 2021 06:04:36 -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=BvQ70dhce4kxItaPjGS90KL/Tl/xCqV5rnfXoeOdY6Q=; b=iNs2rix5PE/9M6DZaugvLM5dZTUu/qXgWiUJUEOp8LeJM7JHBO78YEaxojNu3nLj7w JBO4+iOHLKp6SJtHmhYK3TTKBjtg5HiyoNl6sjFxpcLYJQRvbfGbyjdXRk/o6CNbw/VW mtNOIlxRE9VmM3k7cFleLno1hAjUSBROFIQmASZtVV71vh7z24wSft7KKA261NNYZe0C NLmrs38ETte7qSTqfNtbH9YsMw77Kc+guNcJhHwsL6cEjVHt5x8q0n2lfPPUwZrS7xa9 G5UT8o6cI3gvO6lLmV0S9dW1nfsZqqYXqk57AtSB+ulPqzBhROp639pdFLUd6xOYPkmq 1XCg== 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=BvQ70dhce4kxItaPjGS90KL/Tl/xCqV5rnfXoeOdY6Q=; b=jLjzksTingv6AH4CMUGxOcAQC13bxBndQ4yx/Pzd0Gqo79GLHzHZ40ySM1YN3WpvqK cpa2wdCHUAM5l89AZqwptae+lE+IhWSFRdOnrydf001GsmNJnxMl1tKFF3rqrJj0AS4i kIWE2tvxqJpbJJVOvLrtJHiHTcQCnkpso/YaJ8Zj/15BOV1oIm9/1SmxNDJNCTuBvVRD P1AWtPQ2Hs1s2OfU9v1jUfjGlcNHTSVQmp2PV5Cuv1D3IMGDpgwoWxzbjH6ykqtmP2bn vp+gDxNkeiXRHKUQ5AmJ72Qk+yVIGUG8hmXSbPLM8de4SRxuUrNJVp6SLfU6mbwF4V47 o0hA== X-Gm-Message-State: AOAM533+8m/XDQrGUqggCsCVW4Yvx8txKHKk8/aF6+xucwY+f18oxNnF I13icqWnmkNWwt81RZLUSa4QabBKmtzfLH7JdXI6xQ== X-Google-Smtp-Source: ABdhPJwQ79B5nh5gIqlZExb3wTEaa+Cmjyd1+L5Dedt96V2N2te0IOtyWoccQ+lDgGQyhWrFTCgncPs3zs9Q8G8pRDQ= X-Received: by 2002:a37:70d:: with SMTP id 13mr12162251qkh.326.1610719476289; Fri, 15 Jan 2021 06:04:36 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Alexander Potapenko Date: Fri, 15 Jan 2021 15:04:24 +0100 Message-ID: Subject: Re: [PATCH v3 12/15] kasan: fix bug detection via ksize for HW_TAGS mode To: Marco Elver Cc: Andrey Konovalov , Andrew Morton , Catalin Marinas , Vincenzo Frascino , Dmitry Vyukov , Will Deacon , Andrey Ryabinin , Peter Collingbourne , Evgenii Stepanov , Branislav Rankov , Kevin Brodsky , kasan-dev , Linux ARM , Linux Memory Management List , LKML Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jan 15, 2021 at 2:18 PM Marco Elver wrote: > > On Thu, Jan 14, 2021 at 08:36PM +0100, Andrey Konovalov wrote: > > The currently existing kasan_check_read/write() annotations are intended > > to be used for kernel modules that have KASAN compiler instrumentation > > disabled. Thus, they are only relevant for the software KASAN modes that > > rely on compiler instrumentation. > > > > However there's another use case for these annotations: ksize() checks > > that the object passed to it is indeed accessible before unpoisoning the > > whole object. This is currently done via __kasan_check_read(), which is > > compiled away for the hardware tag-based mode that doesn't rely on > > compiler instrumentation. This leads to KASAN missing detecting some > > memory corruptions. > > > > Provide another annotation called kasan_check_byte() that is available > > for all KASAN modes. As the implementation rename and reuse > > kasan_check_invalid_free(). Use this new annotation in ksize(). > > To avoid having ksize() as the top frame in the reported stack trace > > pass _RET_IP_ to __kasan_check_byte(). > > > > Also add a new ksize_uaf() test that checks that a use-after-free is > > detected via ksize() itself, and via plain accesses that happen later. > > > > Link: https://linux-review.googlesource.com/id/Iaabf771881d0f9ce1b969f2a62938e99d3308ec5 > > Signed-off-by: Andrey Konovalov > > Reviewed-by: Marco Elver Reviewed-by: Alexander Potapenko