From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x227dTA3o4uQP0d2XNtRT1w+jr4IS0WQ3DD8EuciltJEl/k7PbWhb6q4K0qFqi/cuhDRXKkSC ARC-Seal: i=1; a=rsa-sha256; t=1516610494; cv=none; d=google.com; s=arc-20160816; b=EX51k3HS74Klg6i24rVSixZmd3w3L+etJe13qr1ZxLAhoBon0zs0D3yRTP/GduHRRz CHu87XN74kTexIG7mVHseN3jV9nGopLcRnC2CGtYcIIsfcu/jprZWMkuEhEqsSvIyqKX ur6gGx9XwWeCzpY4M6KkJob5XAScGnE4twuMS5/2yEQlHzdzxm4lHqjzHYBWyfuEMTI0 f2PluWGeAdi4q1nvu4X4E926MyUjDGieBNbciECK44J1kOMTpZbjC6AnpCeTbBn8B2ch NiBJtbMh5XI+eWJwVuGZE3TyuvdajDveSVeor2MP9bqhSuBOZLAphvmXP/olo2qRhBKZ p//g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=mL+MfGznVdWVlqq9To+9OzTMFm2vUHk8s5c6nHQ7In8=; b=PbYo4n4j0qqEad3hvzAXVzhGPKQO7GGb13PKJ5AMS7nyjIsXQonPQAJU3s/AV4QNXu 7O6VyWLVXgk+z/rHz0GvEB2JM2FNn2WMJvmj3kYWLAFyGaXUkvFV5lbiAmfG2ijswQPg Pf9Ns5dlmSUQivixWwk88k5fXa79NipaUqJRYS5vzxrTspIRWWjg+H19c+9kR1CBbLLC 3gQyWStYCSZWMgo2R+HVWMVAFE70B2fhkAHebyMHEa8PnGfRJx/WjZrien6ZemCJGwTs Ypg2VO3ZLJkYrbHmjOE3rVjsgkIl8ylieCH4olIL6XOzBdVW5AEL+xvrUB43e2c1V+im Ilnw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning gregkh@linuxfoundation.org does not designate 90.92.71.90 as permitted sender) smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Li Jinyue , Thomas Gleixner , peterz@infradead.org, dvhart@infradead.org Subject: [PATCH 4.4 22/53] futex: Prevent overflow by strengthen input validation Date: Mon, 22 Jan 2018 09:40:14 +0100 Message-Id: <20180122083911.235536031@linuxfoundation.org> X-Mailer: git-send-email 2.16.0 In-Reply-To: <20180122083910.299610926@linuxfoundation.org> References: <20180122083910.299610926@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-LABELS: =?utf-8?b?IlxcU2VudCI=?= X-GMAIL-THRID: =?utf-8?q?1590281365405131555?= X-GMAIL-MSGID: =?utf-8?q?1590281365405131555?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 4.4-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 @@ -1621,6 +1621,9 @@ static int futex_requeue(u32 __user *uad struct futex_q *this, *next; WAKE_Q(wake_q); + if (nr_wake < 0 || nr_requeue < 0) + return -EINVAL; + if (requeue_pi) { /* * Requeue PI only works on two distinct uaddrs. This