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] [day] [month] [year] [list]
Message-ID: <ead094dabae64e6c978e94b617c8d08c@AcuMS.aculab.com>
Date:   Mon, 16 Sep 2019 11:49:22 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-tip-commits@...r.kernel.org" 
        <linux-tip-commits@...r.kernel.org>
CC:     Miles Chen <miles.chen@...iatek.com>,
        "linux-mediatek@...ts.infradead.org" 
        <linux-mediatek@...ts.infradead.org>,
        "wsd_upstream@...iatek.com" <wsd_upstream@...iatek.com>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...nel.org>, Borislav Petkov <bp@...en8.de>
Subject: RE: [tip: sched/core] sched/psi: Correct overly pessimistic size
 calculation

From: Miles Chen
> Sent: 13 September 2019 23:43
> The following commit has been merged into the sched/core branch of tip:
> 
> Commit-ID:     4adcdcea717cb2d8436bef00dd689aa5bc76f11b
> Gitweb:        https://git.kernel.org/tip/4adcdcea717cb2d8436bef00dd689aa5bc76f11b
> Author:        Miles Chen <miles.chen@...iatek.com>
> AuthorDate:    Thu, 12 Sep 2019 18:34:52 +08:00
> Committer:     Ingo Molnar <mingo@...nel.org>
> CommitterDate: Fri, 13 Sep 2019 07:49:28 +02:00
> 
> sched/psi: Correct overly pessimistic size calculation
> 
> When passing a equal or more then 32 bytes long string to psi_write(),
> psi_write() copies 31 bytes to its buf and overwrites buf[30]
> with '\0'. Which makes the input string 1 byte shorter than
> it should be.
> 
> Fix it by copying sizeof(buf) bytes when nbytes >= sizeof(buf).
> 
> This does not cause problems in normal use case like:
> "some 500000 10000000" or "full 500000 10000000" because they
> are less than 32 bytes in length.
> 
> 	/* assuming nbytes == 35 */
> 	char buf[32];
> 
> 	buf_size = min(nbytes, (sizeof(buf) - 1)); /* buf_size = 31 */
> 	if (copy_from_user(buf, user_buf, buf_size))
> 		return -EFAULT;
> 
> 	buf[buf_size - 1] = '\0'; /* buf[30] = '\0' */

Wouldn't it be better to also allow the user to pass
an unterminated string?
So leave the '-1' on the assignment to buf_size, but remove
it from the last line.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ