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]
Date:   Tue, 30 Jun 2020 20:40:12 +0100
From:   Al Viro <viro@...iv.linux.org.uk>
To:     Linus Torvalds <torvalds@...ux-foundation.org>
Cc:     linux-arch <linux-arch@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        David Miller <davem@...emloft.net>,
        Tony Luck <tony.luck@...el.com>, Will Deacon <will@...nel.org>
Subject: Re: [PATCH 18/41] regset: new method and helpers for it

On Tue, Jun 30, 2020 at 09:53:12AM -0700, Linus Torvalds wrote:
> On Tue, Jun 30, 2020 at 6:25 AM Al Viro <viro@...iv.linux.org.uk> wrote:
> >
> > How about ->regset_get()?
> 
> Sounds good to me. And if you ever do something similar for 'set', you
> have a natural name to pick.

Umm...  Something similar for 'set' would, AFAICS, work reasonably well
with the following primitives.
membuf_read(&from, data, size) -- copy min(size, amount left)
membuf_fetch(&from, data) -- copy min(sizeof(data), amount left) into data
			(obviously a macro)
membuf_skip(&from, size) -- obvious
membuf_pick(&from, size), along the lines of
	if (unlikely(size > p->left)
		return ERR_PTR(-EINVAL);
	res = p->p;
	p->p += size;
	p->left -= size;
	return res;

So it would be something like

int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
                   struct membuf from)
{
        const struct user_desc *info;
	int n = from.left / sizeof(*info);
        int i;

	info = membuf_pick(&from, n * sizeof(*info)); // can't fail here
        for (i = 0; i < n; i++)
                if (!tls_desc_okay(info + i))
                        return -EINVAL;

        set_tls_desc(target, GDT_ENTRY_TLS_MIN, info, n);
        return 0;
}

and

static int genregs32_set(struct task_struct *target,
                         const struct user_regset *regset,
                         struct membuf from)
{
	int err;
	unsigned pos, v;

	for (pos = 0; from.left; pos += sizeof(u32)) {
		membuf_fetch(&from, v);
		err = putreg32(target, pos, v);
		if (err)
			return err;
	}
	return 0;
}

or

/*
 * Copy the supplied 64-bit NT_MIPS_DSP buffer to the DSP context.
 */
static int dsp64_set(struct task_struct *target,
                     const struct user_regset *regset,
                     struct membuf from)
{
        if (!cpu_has_dsp)
                return -EIO;

	membuf_read(&from, target->thread.dsp.dspr, NUM_DSP_REGS * sizeof(u64));
	return membuf_read(&from, target->thread.dsp.dspcontrol, sizeof(u64));
}

etc.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ