Received: by 10.223.176.46 with SMTP id f43csp2148481wra; Thu, 25 Jan 2018 05:46:07 -0800 (PST) X-Google-Smtp-Source: AH8x224HzgSH7MkmR8CgUon11KhdR0NsOki9l/KfJOH2o99DjFbturQxQJQyawj/ctkZGKYu+cIH X-Received: by 10.99.142.76 with SMTP id k73mr13251136pge.89.1516887967708; Thu, 25 Jan 2018 05:46:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516887967; cv=none; d=google.com; s=arc-20160816; b=YT/v3CETPuvhWMiGcuNOlXh0wl3AZSX6gfc7sOEtlUWa9ilhm9Z2lyTyTci8OmXgDG T47+C6/prfXH2gwzp5juV+V60XKsZ/ygK/bYaqI1IQVcmRl366fBtbZ+LRuVNdbdzP7d ZJjBq+RFY2UzrqhJf/qOJq6ofGfw8VOw8nPwWXWR2jnk7o07VADYRPrGMAIgWB0TZ7jb xW66Gz6wcHyE6GexuGQprGJMlMCM4+VeuNCT93I5ipbzHWb2hrQhQaFX+UMNdbAe0KWO 2l1+dnOH9fplrR8HlpXWF53z1HkjTc7WPhl9JaPRKo9IYJ8fFyU6mddp+qym5LPldVes h9vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=N5IomhxYmKbZMxIxBhwFelsXIE7IofG2rGyQfJjEM/g=; b=Tu2D4/IXjMLojrQBOStJljbcqOiJdLehmg24aD8uhhFOQJU3XPKWIe8oYpAOosYnyq HVmIhhnqpeCd2T/uHjQbB4sKVYMz0UaJhfr83KB2E/htmiYmJ9doV3JBCmxIaJdfT/xd 3ElldvlpHuLvZ9EZBWRuLDPWqD5u6kujIa5kH4Xl3jz9j5Rpc1tqP/2x4hesvYQM2PKo nZVPxROf7OYYC3HbMbMc9jCZUf04pXPXsdrHvqZmF0FM2ijlYk3bCrbAJPbi2oKYDt3w J2wmJLaU1B5qyDImiiMHAya32RJRqPSdDIUmy1CZV1dDQoUFY7K4WPjinGMv3RNRnrbk RoNA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x70si1574340pgd.590.2018.01.25.05.45.53; Thu, 25 Jan 2018 05:46:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751296AbeAYNp1 (ORCPT + 99 others); Thu, 25 Jan 2018 08:45:27 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:45699 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751011AbeAYNpY (ORCPT ); Thu, 25 Jan 2018 08:45:24 -0500 Received: by mail-wr0-f193.google.com with SMTP id 16so7714587wry.12; Thu, 25 Jan 2018 05:45:24 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=N5IomhxYmKbZMxIxBhwFelsXIE7IofG2rGyQfJjEM/g=; b=R4qflxvP70EOuTSa11BtX4JZxZXxzXnVC2utnUO6nIGIw/UGP+6wxZqeWjErKyylvZ HazxRkHaDcLkx5jwwy340TkkuVgrg+lAl9VWfmckDG1Vbq5/+q2k6/p1Zt0ypgCM1zIF tAHk/QK1LAIuKd16I4lY6ZAT1JauZTUzzoRemARsXlGBcXTQADFyx+IpuRS+FSYVapEq 4V84OFhYZU2uo9sK1nzfNUDCN+oVrzNMME6gMkZlveM0RepOu2Lf+H8s5s+mpVJwWOon y2QwFKyAeZ/CGd3/QLlx0c9hcptGKOxeOS1N/xtojETYLHFajhDgPh3FAHY7tBGd6Udg mcMg== X-Gm-Message-State: AKwxytdUNGY7v1jSmyq6WPfMY8sPbHb/7at8Oxak98fCtlHjtyF8krYs D0V94gpzdsz2JqWMzgOrrnY= X-Received: by 10.223.156.131 with SMTP id d3mr2988608wre.184.1516887923571; Thu, 25 Jan 2018 05:45:23 -0800 (PST) Received: from ?IPv6:2a01:4240:2e27:ad85:aaaa::19f? (f.9.1.0.0.0.0.0.0.0.0.0.a.a.a.a.5.8.d.a.7.2.e.2.0.4.2.4.1.0.a.2.v6.cust.nbox.cz. [2a01:4240:2e27:ad85:aaaa::19f]) by smtp.gmail.com with ESMTPSA id f76sm1455708wme.2.2018.01.25.05.45.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jan 2018 05:45:22 -0800 (PST) Subject: Re: [PATCH 4.14 17/89] futex: Prevent overflow by strengthen input validation To: Greg Kroah-Hartman , linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org, Li Jinyue , Thomas Gleixner , peterz@infradead.org, dvhart@infradead.org References: <20180122083954.683903493@linuxfoundation.org> <20180122083956.427607580@linuxfoundation.org> From: Jiri Slaby Message-ID: <20567b49-e0a3-e9e0-d520-74bbfc20d414@suse.cz> Date: Thu, 25 Jan 2018 14:45:21 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <20180122083956.427607580@linuxfoundation.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/22/2018, 09:44 AM, Greg Kroah-Hartman wrote: > 4.14-stable review patch. If anyone has any objections, please let me know. > > ------------------ > > From: Li Jinyue > > commit fbe0e839d1e22d88810f3ee3e2f1479be4c0aa4a upstream. > > UBSAN reports signed integer overflow in kernel/futex.c: > > UBSAN: Undefined behaviour in kernel/futex.c:2041:18 > signed integer overflow: > 0 - -2147483648 cannot be represented in type 'int' > > Add a sanity check to catch negative values of nr_wake and nr_requeue. > > Signed-off-by: Li Jinyue > Signed-off-by: Thomas Gleixner > Cc: peterz@infradead.org > Cc: dvhart@infradead.org > Link: https://lkml.kernel.org/r/1513242294-31786-1-git-send-email-lijinyue@huawei.com > Signed-off-by: Greg Kroah-Hartman > > --- > kernel/futex.c | 3 +++ > 1 file changed, 3 insertions(+) > > --- a/kernel/futex.c > +++ b/kernel/futex.c > @@ -1878,6 +1878,9 @@ static int futex_requeue(u32 __user *uad > struct futex_q *this, *next; > DEFINE_WAKE_Q(wake_q); > > + if (nr_wake < 0 || nr_requeue < 0) > + return -EINVAL; This breaks strace's test suite on 4.14.15 (and is present in upstream obviously too): futex(0x7ff568b44ffc, 0x3, 0xfacefeed, 0xbadda7a0ca7b100d, 0x7ff568b44ffc, 0x9caffee1) = -1: Invalid argument strace uses weird values in the testkit to pass down to futex as can be seen. I think like in: commit e78c38f6bdd900b2ad9ac9df8eff58b745dc5b3c Author: Jiri Slaby Date: Mon Oct 23 13:41:51 2017 +0200 futex: futex_wake_op, do not fail on invalid op something similar should be done here too. Maybe: if (nr_wake < 0) nr_wake = 0; if (nr_requeue < 0) nr_requeue = 0; ? Maybe also with some pr_info_ratelimited like in the above commit? thanks, -- js suse labs