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=-4.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 6C705C433DB for ; Tue, 16 Mar 2021 11:35:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id D076364FF4 for ; Tue, 16 Mar 2021 11:35:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D076364FF4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 23EDD6B006E; Tue, 16 Mar 2021 07:35:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C62E6B0070; Tue, 16 Mar 2021 07:35:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F348C6B0071; Tue, 16 Mar 2021 07:35:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0245.hostedemail.com [216.40.44.245]) by kanga.kvack.org (Postfix) with ESMTP id D54E46B006E for ; Tue, 16 Mar 2021 07:35:00 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 99D198249980 for ; Tue, 16 Mar 2021 11:35:00 +0000 (UTC) X-FDA: 77925530760.17.A5CD432 Received: from mail-lf1-f44.google.com (mail-lf1-f44.google.com [209.85.167.44]) by imf21.hostedemail.com (Postfix) with ESMTP id 31F43E005F04 for ; Tue, 16 Mar 2021 11:35:00 +0000 (UTC) Received: by mail-lf1-f44.google.com with SMTP id t18so14112780lfl.3 for ; Tue, 16 Mar 2021 04:34:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=IKq4ek8vxtJozQIHUfJnIO9yQXnXv6nYePXQr5PXTrs=; b=V4ATfEzNMGqq47uJKyufRl7ICYR2UJ7rBgNH1p5kST43w8cwJ+040tD45YpPXyTx7d JXEUlfA9LXu05xR+F9b73OjxsGZLENz7+ycb9j6vosNd8I/9BuM4qe94+quenCm7LJ/O f2AI6IAtfpU6tgiwVjBhuEdOsY3s94O8q0sdj1MaBgdVoz5HTqK9u8RJN7nw8mFYEFiz RZOAnx/ajMy2d53sf9Bg0bnEYxFsvlPNABbUF3sPUDO5vKLsRqjfJuvzBPV3lZjWTEv7 PPSUFV0XvbH2iOBCE8Zq6rj5oT5tMrKESG1lxq+WhqG95qIuFt/ktI3ADrPkAuiLkcZp INcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=IKq4ek8vxtJozQIHUfJnIO9yQXnXv6nYePXQr5PXTrs=; b=Nv+WmCv5Vvg27AD8GEYl4d719OO2U/NmrQnsuVsZrgwJ2ewfHXmyb3BWdLF1QmKWQn HpxfpwLAq+hlw+Qktkjs1Awp3ErWxNhUgQD8AIJCHD9iPICUXf1QrPXhsRoMz50nHIol hUhHvvcmI+B1/IPyUyXJR/osuuwfgTF/iKWwLNUvsRb5dyDY7JxWRF7sKcmwLZG97N+k pNuGso1hUBejztGsETpYVgJ0iX40RC4ZVwB8gjMy0eWghgCUaJ4DyXsx2ja6TVccLpoz hfMaz/nkZZbzVwxIhUKE92Vpbd9WWnVArNOe4xb6q2TMrj/s5Eg5oi4N8mJIlZ5AjI7V 1LbQ== X-Gm-Message-State: AOAM5305U+T6AIlrSf7ux8/WuSoOUB2Ytziec3URIJdZwSBqOMPTIskR aCzgjB6LaAp9DrY6DgfB0OQ= X-Google-Smtp-Source: ABdhPJzeTEzowewtj7H/UZHzJr2g65mMPWNwh/mTrCpjuyWHHP8pMMIJwYiVk4gsOPUmOsa0tJ5DYA== X-Received: by 2002:a05:6512:21cb:: with SMTP id d11mr10527323lft.177.1615894498617; Tue, 16 Mar 2021 04:34:58 -0700 (PDT) Received: from pc636 (h5ef52e3d.seluork.dyn.perspektivbredband.net. [94.245.46.61]) by smtp.gmail.com with ESMTPSA id y11sm3200770ljc.18.2021.03.16.04.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 04:34:58 -0700 (PDT) From: Uladzislau Rezki X-Google-Original-From: Uladzislau Rezki Date: Tue, 16 Mar 2021 12:34:56 +0100 To: Topi Miettinen Cc: Uladzislau Rezki , Kees Cook , linux-hardening@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andy Lutomirski , Jann Horn , Linux API , Matthew Wilcox , Mike Rapoport Subject: Re: [PATCH v4] mm/vmalloc: randomize vmalloc() allocations Message-ID: <20210316113456.GA31764@pc636> References: <20210309135757.5406-1-toiwoton@gmail.com> <20210314172312.GA2085@pc638.lan> <20210315122410.GA26784@pc636> <202103150914.4172D96@keescook> <20210315174742.GA2038@pc638.lan> <85515ea8-744e-acec-76ba-034b38d0f9fa@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <85515ea8-744e-acec-76ba-034b38d0f9fa@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Stat-Signature: yh98spg4jmw4sjdwbp1jxh4w6yb47pn3 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 31F43E005F04 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=mail-lf1-f44.google.com; client-ip=209.85.167.44 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615894500-489478 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 Tue, Mar 16, 2021 at 10:01:46AM +0200, Topi Miettinen wrote: > On 15.3.2021 19.47, Uladzislau Rezki wrote: > > On Mon, Mar 15, 2021 at 09:16:26AM -0700, Kees Cook wrote: > > > On Mon, Mar 15, 2021 at 01:24:10PM +0100, Uladzislau Rezki wrote: > > > > On Mon, Mar 15, 2021 at 11:04:42AM +0200, Topi Miettinen wrote: > > > > > What's the problem with that? It seems to me that nothing relies on specific > > > > > addresses of the chunks, so it should be possible to randomize these too. > > > > > Also the alignment is honored. > > > > > > > > > My concern are: > > > > > > > > - it is not a vmalloc allocator; > > > > - per-cpu allocator allocates chunks, thus it might be it happens only once. It does not allocate it often; > > > > > > That's actually the reason to randomize it: if it always ends up in the > > > same place at every boot, it becomes a stable target for attackers. > > > > > Probably we can randomize a base address only once when pcpu-allocator > > allocates a fist chunk during the boot. > > > > > > - changing it will likely introduce issues you are not aware of; > > > > - it is not supposed to be interacting with vmalloc allocator. Read the > > > > comment under pcpu_get_vm_areas(); > > > > > > > > Therefore i propose just not touch it. > > > > > > How about splitting it from this patch instead? Then it can get separate > > > testing, etc. > > > > > It should be split as well as tested. > > Would you prefer another kernel option `randomize_percpu_allocator=1`, or > would it be OK to make it a flag in `randomize_vmalloc`, like > `randomize_vmalloc=3`? Maybe the latter would not be compatible with static > branches. > I think it is better to have a separate option, because there are two different allocators. -- Vlad Rezki