linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Hyeonggon Yoo <42.hyeyoo@gmail.com>
To: Gong Ruiqi <gongruiqi1@huawei.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	 linux-hardening@vger.kernel.org,
	 Alexander Lobakin <aleksander.lobakin@intel.com>,
	kasan-dev@googlegroups.com,
	 Wang Weiyang <wangweiyang2@huawei.com>,
	Xiu Jianfeng <xiujianfeng@huawei.com>,
	 Vlastimil Babka <vbabka@suse.cz>,
	Christoph Lameter <cl@linux.com>,
	David Rientjes <rientjes@google.com>,
	 Roman Gushchin <roman.gushchin@linux.dev>,
	Joonsoo Kim <iamjoonsoo.kim@lge.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Pekka Enberg <penberg@kernel.org>,
	 Kees Cook <keescook@chromium.org>,
	Paul Moore <paul@paul-moore.com>,
	 James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	 "Gustavo A. R. Silva" <gustavoars@kernel.org>
Subject: Re: [PATCH RFC v2] Randomized slab caches for kmalloc()
Date: Wed, 17 May 2023 07:35:57 +0900	[thread overview]
Message-ID: <CAB=+i9R0GZiau7PKDSGdCOijPH1TVqA3rJ5tQLejJpoR55h6dg@mail.gmail.com> (raw)
In-Reply-To: <5f5a858a-7017-5424-0fa0-db3b79e5d95e@huawei.com>

[Resending this email after noticing I did not reply-to-all]

On Fri, May 12, 2023 at 7:11 PM Gong Ruiqi <gongruiqi1@huawei.com> wrote:
>
>
>
> On 2023/05/11 2:43, Hyeonggon Yoo wrote:
> > I dont think adding a hardening feature by sacrificing one digit
> > percent performance
> > (and additional complexity) is worth. Heap spraying can only occur
> > when the kernel contains
> > security vulnerabilities, and if there is no known ways of performing
> > such an attack,
> > then we would simply be paying a consistent cost.
> >
> > Any opinions from hardening folks?
>
> I did a more throughout performance test on the same machine in the same
> way, and here are the results:
>
>               sched/  sched/  syscall/       mem/         mem/
>            messaging    pipe     basic     memcpy       memset
> control1       0.019   5.459     0.733  15.258789    51.398026
> control2       0.019   5.439     0.730  16.009221    48.828125
> control3       0.019   5.282     0.735  16.009221    48.828125
> control_avg    0.019   5.393     0.733  15.759077    49.684759
>
> exp1           0.019   5.374     0.741  15.500992    46.502976
> exp2           0.019   5.440     0.746  16.276042    51.398026
> exp3           0.019   5.242     0.752  15.258789    51.398026
> exp_avg        0.019   5.352     0.746  15.678608    49.766343
>
> I believe the results show only minor differences and normal
> fluctuation, and no substantial performance degradation.
>
> As Pedro points out in his reply, unfortunately there are always
> security vulnerabilities in the kernel, which is a fact that we have to
> admit. Having a useful mitigation mechanism at the expense of a little
> performance loss would be, in my opinion, quite a good deal in many
> circumstances. And people can still choose not to have it by setting the
> config to n.

Okay, now I don't think I need to tackle it from a performance
perspective anymore, at least it looks like a good tradeoff.

I had few design level concerns (i.e. in ARM64 instructions are 4-byte
aligned) before switching to hash_64(^ random sequence), but looks
good to me now.

> >> +#ifdef CONFIG_RANDOM_KMALLOC_CACHES
> >> +# define SLAB_RANDOMSLAB       ((slab_flags_t __force)0x01000000U)
> >> +#else
> >> +# define SLAB_RANDOMSLAB       0
> >> +#endif

There is already the SLAB_KMALLOC flag that indicates if a cache is a
kmalloc cache. I think that would be enough for preventing merging
kmalloc caches?


  parent reply	other threads:[~2023-05-16 22:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-08  7:55 GONG, Ruiqi
2023-05-10 18:43 ` Hyeonggon Yoo
2023-05-10 19:32   ` Pedro Falcato
2023-05-12 10:11   ` Gong Ruiqi
2023-05-14  9:30     ` Vlastimil Babka
2023-05-15  8:20       ` Gong Ruiqi
2023-05-16 22:35     ` Hyeonggon Yoo [this message]
2023-05-22  7:35       ` Gong Ruiqi
2023-05-22  8:03         ` Hyeonggon Yoo
2023-05-22  8:58           ` GONG, Ruiqi
2023-05-24  5:54             ` Hyeonggon Yoo
2023-05-31  3:47               ` GONG, Ruiqi
2023-05-11 12:30 ` xiujianfeng
2023-05-11 14:54 ` Alexander Lobakin
2023-05-15  6:26   ` Gong Ruiqi
2023-05-16 12:43     ` Alexander Lobakin
2023-05-16 19:34 ` Kees Cook
2023-05-31  7:59   ` Gong Ruiqi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAB=+i9R0GZiau7PKDSGdCOijPH1TVqA3rJ5tQLejJpoR55h6dg@mail.gmail.com' \
    --to=42.hyeyoo@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aleksander.lobakin@intel.com \
    --cc=cl@linux.com \
    --cc=gongruiqi1@huawei.com \
    --cc=gustavoars@kernel.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=jmorris@namei.org \
    --cc=kasan-dev@googlegroups.com \
    --cc=keescook@chromium.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=paul@paul-moore.com \
    --cc=penberg@kernel.org \
    --cc=rientjes@google.com \
    --cc=roman.gushchin@linux.dev \
    --cc=serge@hallyn.com \
    --cc=vbabka@suse.cz \
    --cc=wangweiyang2@huawei.com \
    --cc=xiujianfeng@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox