lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230105092019.4bc166b6@gandalf.local.home>
Date:   Thu, 5 Jan 2023 09:20:19 -0500
From:   Steven Rostedt <rostedt@...dmis.org>
To:     Clément Léger <clement.leger@...tlin.com>
Cc:     Yann Sionneau <ysionneau@...ray.eu>,
        Masami Hiramatsu <mhiramat@...nel.org>,
        Mark Rutland <mark.rutland@....com>,
        linux-kernel@...r.kernel.org,
        Guillaume Thouvenin <gthouvenin@...ray.eu>,
        Julian Vetter <jvetter@...ray.eu>,
        Marius Gligor <mgligor@...ray.eu>
Subject: Re: [RFC PATCH 21/25] kvx: Add support for ftrace

On Thu, 5 Jan 2023 13:55:26 +0100
Clément Léger <clement.leger@...tlin.com> wrote:

> > +/* The longest insns we check are for the far call: make + icall */
> > +#define MAX_SYLLABLES_TO_CHECK (KVX_INSN_MAKE_IMM64_SIZE + INSN_ICALL_SYLLABLE_SIZE)
> > +
> > +static int read_insns_and_check(u32 *insns, u8 insns_len, u32 *addr)
> > +{
> > +	u32 insns_read[MAX_SYLLABLES_TO_CHECK];
> > +	int syllables = insns_len / KVX_INSN_SYLLABLE_WIDTH;
> > +	int i;
> > +
> > +	if (syllables > MAX_SYLLABLES_TO_CHECK) {
> > +		pr_err("%s: shouldn't have more than %d syllables to check\n",
> > +		       __func__, MAX_SYLLABLES_TO_CHECK);
> > +		return -EINVAL;
> > +	}
> > +
> > +	if (kvx_insns_read(insns_read, insns_len, addr)) {
> > +		pr_err("%s: error when trying to read syllable\n", __func__);
> > +		return -EFAULT;
> > +	}
> > +
> > +	for (i = 0; i < syllables; i++) {
> > +		if (insns[i] != insns_read[i]) {
> > +			pr_err("%s: Instruction verification failed at PC 0x%lx\n",
> > +			       __func__,
> > +			       (unsigned long)addr + i * KVX_INSN_SYLLABLE_WIDTH);
> > +			pr_err("%s: \tExpect  0x%x\n", __func__, insns[i]);
> > +			pr_err("%s: \tRead    0x%x\n", __func__, insns_read[i]);
> > +			return -EFAULT;
> > +		}
> > +	}
> > +
> > +	return 0;
> > +}  
> 
> Hi Yann,
> 
> Is this still needed ? I'm guessing the instructions should always be
> correctly written no ? If not, something probably went horribly wrong ;)

I would definitely keep it. Code modifications can be quite fragile. Most
of the time things don't go wrong, but when they do, having these checks
makes it obvious to where the problem happened. Problems here is usually
some code mapping that got incorrectly flagged to be traced, when it
shouldn't be. Reporting these errors helps find what that was.

-- Steve


> 
> > +
> > +static int write_insns_and_check(u32 *insns, u8 insns_len, u32 *insn_addr)
> > +{
> > +	int ret;
> > +
> > +	ret = kvx_insns_write_nostop(insns, insns_len, insn_addr);
> > +	if (ret)
> > +		return ret;
> > +
> > +	/* Check that what have been written is correct. */
> > +	return read_insns_and_check(insns, insns_len, insn_addr);
> > +}
> > +

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ