From patchwork Wed Nov 23 01:55:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xi Wang X-Patchwork-Id: 127202 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id B065FB6F71 for ; Wed, 23 Nov 2011 12:55:56 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759352Ab1KWBzf (ORCPT ); Tue, 22 Nov 2011 20:55:35 -0500 Received: from mail-iy0-f174.google.com ([209.85.210.174]:59350 "EHLO mail-iy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755659Ab1KWBze convert rfc822-to-8bit (ORCPT ); Tue, 22 Nov 2011 20:55:34 -0500 Received: by iage36 with SMTP id e36so945329iag.19 for ; Tue, 22 Nov 2011 17:55:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :cc:to:mime-version:x-mailer; bh=8K4xt8o66KS/I8FzrIeeUbty8TwW6Uj6b+AEPwuhczA=; b=REPpicGtIRaC180zfpNZkuEI58ecOvMTP+I3kA9owyeXIlQyHhFSjJprSkRk8DVXjC LKSspiqKu7FG5D/qw7sRyp2PwI055a3hSQU7bmb0Ks+futjxX+HE8gxUuRHj2mhvU+PU +bLWpCs881qQwciokAv5WLdcQQayFYEH8h8Ds= Received: by 10.231.8.226 with SMTP id i34mr5972848ibi.38.1322013333732; Tue, 22 Nov 2011 17:55:33 -0800 (PST) Received: from vpn-18-101-16-236.mit.edu (VPN-18-101-16-236.MIT.EDU. [18.101.16.236]) by mx.google.com with ESMTPS id z10sm66757408ibv.9.2011.11.22.17.55.31 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 22 Nov 2011 17:55:32 -0800 (PST) From: Xi Wang Subject: [PATCH] sctp: integer overflow in sctp_auth_create_key() Date: Tue, 22 Nov 2011 20:55:30 -0500 Message-Id: <028246D6-9024-4E43-93A1-25A87878CBBC@gmail.com> Cc: Vlad Yasevich , Sridhar Samudrala , "David S. Miller" , linux-sctp@vger.kernel.org, netdev@vger.kernel.org, security@kernel.org To: linux-kernel@vger.kernel.org Mime-Version: 1.0 (Apple Message framework v1084) X-Mailer: Apple Mail (2.1084) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The previous commit 30c2235c is incomplete and cannot prevent integer overflows. For example, when key_len is 0x80000000 (INT_MAX + 1), the left-hand side of the check, (INT_MAX - key_len), which is unsigned, becomes 0xffffffff (UINT_MAX) and bypasses the check. Signed-off-by: Xi Wang --- net/sctp/auth.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/net/sctp/auth.c b/net/sctp/auth.c index 865e68f..989e0fd 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c @@ -82,7 +82,7 @@ static struct sctp_auth_bytes *sctp_auth_create_key(__u32 key_len, gfp_t gfp) struct sctp_auth_bytes *key; /* Verify that we are not going to overflow INT_MAX */ - if ((INT_MAX - key_len) < sizeof(struct sctp_auth_bytes)) + if (key_len > INT_MAX - sizeof(struct sctp_auth_bytes)) return NULL; /* Allocate the shared key */