All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jessica Yu <jeyu@kernel.org>
To: Andrii Nakryiko <andrii@kernel.org>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, ast@fb.com,
	daniel@iogearbox.net, kernel-team@fb.com,
	Bruce Allan <bruce.w.allan@intel.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Jakub Kicinski <kuba@kernel.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: Re: [PATCH bpf-next 2/2] bpf: sanitize BTF data pointer after module is loaded
Date: Fri, 20 Nov 2020 13:58:30 +0100	[thread overview]
Message-ID: <20201120125829.GA7989@linux-8ccs> (raw)
In-Reply-To: <20201119182600.1496862-2-andrii@kernel.org>

+++ Andrii Nakryiko [19/11/20 10:26 -0800]:
>Given .BTF section is not allocatable, it will get trimmed after module is
>loaded. BPF system handles that properly by creating an independent copy of
>data. But prevent any accidental misused by resetting the pointer to BTF data.
>
>Suggested-by: Jessica Yu <jeyu@kernel.org>
>Fixes: 36e68442d1af ("bpf: Load and verify kernel module BTFs")
>Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Thanks, Andrii!

Acked-by: Jessica Yu <jeyu@kernel.org>

>---
> kernel/module.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
>diff --git a/kernel/module.c b/kernel/module.c
>index f2996b02ab2e..18f259d61d14 100644
>--- a/kernel/module.c
>+++ b/kernel/module.c
>@@ -3709,6 +3709,11 @@ static noinline int do_init_module(struct module *mod)
> 	mod->init_layout.ro_size = 0;
> 	mod->init_layout.ro_after_init_size = 0;
> 	mod->init_layout.text_size = 0;
>+#ifdef CONFIG_DEBUG_INFO_BTF_MODULES
>+	/* .BTF is not SHF_ALLOC and will get removed, so sanitize pointer */
>+	mod->btf_data = NULL;
>+	mod->btf_data_size = 0;
>+#endif
> 	/*
> 	 * We want to free module_init, but be aware that kallsyms may be
> 	 * walking this with preempt disabled.  In all the failure paths, we
>-- 
>2.24.1
>

           reply	other threads:[~2020-11-20 12:58 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <20201119182600.1496862-2-andrii@kernel.org>]

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=20201120125829.GA7989@linux-8ccs \
    --to=jeyu@kernel.org \
    --cc=acme@redhat.com \
    --cc=andrii@kernel.org \
    --cc=ast@fb.com \
    --cc=bpf@vger.kernel.org \
    --cc=bruce.w.allan@intel.com \
    --cc=daniel@iogearbox.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-team@fb.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=yamada.masahiro@socionext.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.