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: <YbdNyjqSugLqsEXN@casper.infradead.org>
Date:   Mon, 13 Dec 2021 13:42:34 +0000
From:   Matthew Wilcox <willy@...radead.org>
To:     Christoph Hellwig <hch@....de>
Cc:     Baoquan He <bhe@...hat.com>, Vivek Goyal <vgoyal@...hat.com>,
        Dave Young <dyoung@...hat.com>, kexec@...ts.infradead.org,
        Tiezhu Yang <yangtiezhu@...ngson.cn>,
        linux-kernel@...r.kernel.org,
        Amit Daniel Kachhap <amit.kachhap@....com>,
        linux-s390@...r.kernel.org, linux-fsdevel@...r.kernel.org
Subject: Re: [PATCH 3/3] vmcore: Convert read_from_oldmem() to take an
 iov_iter

On Mon, Dec 13, 2021 at 09:02:57AM +0100, Christoph Hellwig wrote:
> >  
> >  ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos)
> >  {
> > -	return read_from_oldmem(buf, count, ppos, 0,
> > +	struct kvec kvec = { .iov_base = buf, .iov_len = count };
> > +	struct iov_iter iter;
> > +
> > +	iov_iter_kvec(&iter, READ, &kvec, 1, count);
> > +
> > +	return read_from_oldmem(&iter, count, ppos,
> >  				cc_platform_has(CC_ATTR_GUEST_MEM_ENCRYPT));
> >  }
> 
> elfcorehdr_read should probably also take an iov_iter while we're at it.

I don't like how that looks.  For example:

@@ -1246,11 +1247,14 @@ static int __init parse_crash_elf64_headers(void)
        int rc=0;
        Elf64_Ehdr ehdr;
        u64 addr;
+       struct iov_iter iter;
+       struct kvec kvec = { .iov_base = &ehdr, .iov_len = sizeof(ehdr) };

        addr = elfcorehdr_addr;

        /* Read Elf header */
-       rc = elfcorehdr_read((char *)&ehdr, sizeof(Elf64_Ehdr), &addr);
+       iov_iter_kvec(&iter, READ, &kvec, 1, sizeof(ehdr));
+       rc = elfcorehdr_read(&iter, &addr);
        if (rc < 0)
                return rc;

@@ -1277,7 +1281,10 @@ static int __init parse_crash_elf64_headers(void)
        if (!elfcorebuf)
                return -ENOMEM;
        addr = elfcorehdr_addr;
-       rc = elfcorehdr_read(elfcorebuf, elfcorebuf_sz_orig, &addr);
+       kvec.iov_base = elfcorebuf;
+       kvec.iov_len = elfcorebuf_sz_orig;
+       iov_iter_kvec(&iter, READ, &kvec, 1, elfcorebuf_sz_orig);
+       rc = elfcorehdr_read(&iter, &addr);
        if (rc < 0)
                goto fail;


I don't think this makes the code clearer, and it's already pretty ugly
code.  I'd rather leave constructing the iov_iter to elfcorehdr_read().
(Same remarks apply to elfcorehdr_read_notes())

> I also don't quite understand why we even need the arch overrides for it,
> but that would require some digging into the history of this interface.

I decided I didn't want to know ;-)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ