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: <YtVkpRJ7jvLFuKs4@casper.infradead.org>
Date:   Mon, 18 Jul 2022 14:48:21 +0100
From:   Matthew Wilcox <willy@...radead.org>
To:     Alexander Gordeev <agordeev@...ux.ibm.com>
Cc:     Alexander Egorenkov <egorenar@...ux.ibm.com>,
        Heiko Carstens <hca@...ux.ibm.com>,
        Baoquan He <bhe@...hat.com>, Christoph Hellwig <hch@....de>,
        Vasily Gorbik <gor@...ux.ibm.com>,
        Al Viro <viro@...iv.linux.org.uk>,
        linux-kernel@...r.kernel.org, linux-s390@...r.kernel.org
Subject: Re: [PATCH v3 2/3] s390/crash: use static swap buffer for
 copy_to_user_real()

On Mon, Jul 18, 2022 at 03:32:40PM +0200, Alexander Gordeev wrote:
> +++ b/arch/s390/kernel/crash_dump.c
> @@ -53,6 +53,7 @@ struct save_area {
>  };
>  
>  static LIST_HEAD(dump_save_areas);

I'd suggest you need a mutex here so that simultaneous calls to
copy_to_user_real() don't corrupt each others data.

> +static char memcpy_real_buf[PAGE_SIZE];
>  
>  /*
>   * Allocate a save area
> @@ -179,23 +180,18 @@ int copy_oldmem_kernel(void *dst, unsigned long src, size_t count)
>  static int copy_to_user_real(void __user *dest, unsigned long src, unsigned long count)
>  {
>  	int offs = 0, size, rc;
> -	char *buf;
>  
> -	buf = (char *)__get_free_page(GFP_KERNEL);
> -	if (!buf)
> -		return -ENOMEM;
>  	rc = -EFAULT;
>  	while (offs < count) {
>  		size = min(PAGE_SIZE, count - offs);
> -		if (memcpy_real(buf, src + offs, size))
> +		if (memcpy_real(memcpy_real_buf, src + offs, size))
>  			goto out;
> -		if (copy_to_user(dest + offs, buf, size))
> +		if (copy_to_user(dest + offs, memcpy_real_buf, size))
>  			goto out;
>  		offs += size;
>  	}
>  	rc = 0;
>  out:
> -	free_page((unsigned long)buf);
>  	return rc;
>  }
>  
> -- 
> 2.34.1
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ