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=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no 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 2FDA0C433DF for ; Mon, 17 Aug 2020 11:54:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E4AB720674 for ; Mon, 17 Aug 2020 11:54:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="cUo2YqnI" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4AB720674 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 62BFF6B0005; Mon, 17 Aug 2020 07:54:04 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5DCF46B0006; Mon, 17 Aug 2020 07:54:04 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4CC4F8D0002; Mon, 17 Aug 2020 07:54:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0246.hostedemail.com [216.40.44.246]) by kanga.kvack.org (Postfix) with ESMTP id 36BD86B0005 for ; Mon, 17 Aug 2020 07:54:04 -0400 (EDT) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id EFF2C181AEF3C for ; Mon, 17 Aug 2020 11:54:03 +0000 (UTC) X-FDA: 77159901966.18.sun64_17060e127016 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin18.hostedemail.com (Postfix) with ESMTP id B7368100EC665 for ; Mon, 17 Aug 2020 11:54:03 +0000 (UTC) X-HE-Tag: sun64_17060e127016 X-Filterd-Recvd-Size: 5140 Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by imf47.hostedemail.com (Postfix) with ESMTP for ; Mon, 17 Aug 2020 11:54:03 +0000 (UTC) Received: by mail-pf1-f196.google.com with SMTP id a79so8111327pfa.8 for ; Mon, 17 Aug 2020 04:54:03 -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=CPagJq8bfLV5JHleSz/YdyHxTxcPKxeM2AT318YsVDU=; b=cUo2YqnIduCfkp3HRFHUsby0zIh4dQYG3sMlKf28FS6lSwIo6RgJH+LytxK18B2Xwv CKGCwVlOVoB0vdx09P+hquL2g0fnLEFIl6278frwEGWyWh0wgn/FvpnULmcjwCMz4P1m QvOeSCUuHTNcDLC2nwxNGjoTp1xDchiJDXN4AKsy9QdAk3z3fxrZukSimZOz1mSFoEIM oenaufwaX+LZD3rAy7UYelrnzOy5gZWXAtEiJJlBEQfRb+iUgUW/mdb4BbuOnqpNqx/A l6MKMdZZ/IeSpillNWWS64wACRvp7VRH+Zs+o5syOFhQFzaMuHD9BMXIMcqXebI9ga5j Xmkg== 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=CPagJq8bfLV5JHleSz/YdyHxTxcPKxeM2AT318YsVDU=; b=D6Yg/STDpsukw/OFmnKXMh0zjkgi83+5PXrbUoutVO8WyYucMr24JIFBDTgXsyJj4B bws4OYbiyetiWeEet0TO1eztX5k8VUApkjSEBNEviW06ScmEtImc4GwlGA+1WgU/CaVm WqqLifW1xs2jnjyou4uB7W9EuBm82T3V8x4w6vavuCMOOC077qh22B8bwYOYoFQMEBfd 83Deaj3v7SDDhcep4UbOdhr9HLCWxD3zYxeSgejsasTiqF4uXLXwBiNYXoSPEm7haoKj iSggq9Y6Ig42mqMKw3D5PXsG/tWXGCx73zB4fHlH1W0l+J1/7aJ8XUrLpyDthWLKs4tH 4vkw== X-Gm-Message-State: AOAM531gh8TsSpVLXENnmkYupLHgVfKAv2UxbmfMSa8i12NR7MwAIg3q itV366bPHLUnxr3kFkDVaBGluJB8cWB5hlX6HggUtw== X-Google-Smtp-Source: ABdhPJxQsY+haVSQeWnKsAs3ixBm6FjQ0//5YkN0AYGeNZHDelu/iOrnxxlOSVO5MvjaUD8VZOIX74GJgLknb82gmsU= X-Received: by 2002:a65:680b:: with SMTP id l11mr3369972pgt.440.1597665241999; Mon, 17 Aug 2020 04:54:01 -0700 (PDT) MIME-Version: 1.0 References: <20200813151922.1093791-1-alex.popov@linux.com> <20200813151922.1093791-2-alex.popov@linux.com> <202008150939.A994680@keescook> In-Reply-To: <202008150939.A994680@keescook> From: Andrey Konovalov Date: Mon, 17 Aug 2020 13:53:51 +0200 Message-ID: Subject: Re: [PATCH RFC 1/2] mm: Extract SLAB_QUARANTINE from KASAN To: Kees Cook , Alexander Popov Cc: Jann Horn , Will Deacon , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Christoph Lameter , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Masahiro Yamada , Masami Hiramatsu , Steven Rostedt , Peter Zijlstra , Krzysztof Kozlowski , Patrick Bellasi , David Howells , Eric Biederman , Johannes Weiner , Laura Abbott , Arnd Bergmann , Greg Kroah-Hartman , kasan-dev , Linux Memory Management List , kernel-hardening@lists.openwall.com, LKML , notify@kernel.org Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: B7368100EC665 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 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 Sat, Aug 15, 2020 at 6:52 PM Kees Cook wrote: > > On Thu, Aug 13, 2020 at 06:19:21PM +0300, Alexander Popov wrote: > > Heap spraying is an exploitation technique that aims to put controlled > > bytes at a predetermined memory location on the heap. Heap spraying for > > exploiting use-after-free in the Linux kernel relies on the fact that on > > kmalloc(), the slab allocator returns the address of the memory that was > > recently freed. Allocating a kernel object with the same size and > > controlled contents allows overwriting the vulnerable freed object. > > > > Let's extract slab freelist quarantine from KASAN functionality and > > call it CONFIG_SLAB_QUARANTINE. This feature breaks widespread heap > > spraying technique used for exploiting use-after-free vulnerabilities > > in the kernel code. > > > > If this feature is enabled, freed allocations are stored in the quarantine > > and can't be instantly reallocated and overwritten by the exploit > > performing heap spraying. [...] > In doing this extraction, I wonder if function naming should be changed? > If it's going to live a new life outside of KASAN proper, maybe call > these functions quarantine_cache_*()? But perhaps that's too much > churn... If quarantine is to be used without the rest of KASAN, I'd prefer for it to be separated from KASAN completely: move to e.g. mm/quarantine.c and don't mention KASAN in function/config names.