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: <20200313010425.GA11360@linux.intel.com>
Date:   Fri, 13 Mar 2020 03:04:25 +0200
From:   Jarkko Sakkinen <jarkko.sakkinen@...ux.intel.com>
To:     Waiman Long <longman@...hat.com>
Cc:     David Howells <dhowells@...hat.com>,
        James Morris <jmorris@...ei.org>,
        "Serge E. Hallyn" <serge@...lyn.com>,
        Mimi Zohar <zohar@...ux.ibm.com>, keyrings@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        linux-security-module@...r.kernel.org,
        linux-integrity@...r.kernel.org,
        Sumit Garg <sumit.garg@...aro.org>,
        Jerry Snitselaar <jsnitsel@...hat.com>,
        Roberto Sassu <roberto.sassu@...wei.com>,
        Eric Biggers <ebiggers@...gle.com>,
        Chris von Recklinghausen <crecklin@...hat.com>
Subject: Re: [PATCH v2 1/2] KEYS: Don't write out to userspace while holding
 key semaphore

On Sun, Mar 08, 2020 at 01:04:09PM -0400, Waiman Long wrote:
> +		/*
> +		 * Read methods will just return the required length
> +		 * without any copying if the provided length isn't big
> +		 * enough.
> +		 */
> +		if ((ret > 0) && (ret <= buflen) && buffer &&
> +		    copy_to_user(buffer, tmpbuf, ret))
> +			ret = -EFAULT;

Please, reorg and remove redundant parentheses:

/*
 * Read methods will just return the required length
 * without any copying if the provided length isn't big
 * enough.
 */
if (ret > 0 && ret <= buflen) {
	if (buffer && copy_to_user(buffer, tmpbuf, ret))
		ret = -EFAULT;
}

Now the comment is attached to the exact right thing. The previous
organization is a pain to look at when backtracking commits for
whatever reason in the future.

I'm also wondering, would it be possible to rework the code in a way
that you don't have check whether buffer is valid on a constant basis?

/Jarkko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ