From patchwork Thu May 26 16:07:35 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Whitcroft X-Patchwork-Id: 97592 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id A27FEB6F8D for ; Fri, 27 May 2011 02:07:47 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1QPd66-0001kR-Fi; Thu, 26 May 2011 16:07:42 +0000 Received: from adelie.canonical.com ([91.189.90.139]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1QPd62-0001je-I4 for kernel-team@lists.ubuntu.com; Thu, 26 May 2011 16:07:38 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by adelie.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1QPd62-0003W4-GO; Thu, 26 May 2011 16:07:38 +0000 Received: from 212-139-215-176.dynamic.dsl.as9105.com ([212.139.215.176] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1QPd62-0001VJ-Cu; Thu, 26 May 2011 16:07:38 +0000 From: Andy Whitcroft To: kernel-team@lists.ubuntu.com Subject: [maverick CVE 1/1] can: add missing socket check in can/raw release Date: Thu, 26 May 2011 17:07:35 +0100 Message-Id: <1306426055-31069-2-git-send-email-apw@canonical.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1306426055-31069-1-git-send-email-apw@canonical.com> References: <1306426055-31069-1-git-send-email-apw@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: kernel-team-bounces@lists.ubuntu.com Errors-To: kernel-team-bounces@lists.ubuntu.com From: Oliver Hartkopp v2: added space after 'if' according code style. We can get here with a NULL socket argument passed from userspace, so we need to handle it accordingly. Thanks to Dave Jones pointing at this issue in net/can/bcm.c Signed-off-by: Oliver Hartkopp Signed-off-by: David S. Miller CVE-2011-1748 BugLink: http://bugs.launchpad.net/bugs/788694 (cherry picked from commit 10022a6c66e199d8f61d9044543f38785713cbbd) Signed-off-by: Andy Whitcroft Acked-by: Tim Gardner Acked-by: Leann Ogasawara --- net/can/raw.c | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-) diff --git a/net/can/raw.c b/net/can/raw.c index 1650599..9ae3b9b 100644 --- a/net/can/raw.c +++ b/net/can/raw.c @@ -281,7 +281,12 @@ static int raw_init(struct sock *sk) static int raw_release(struct socket *sock) { struct sock *sk = sock->sk; - struct raw_sock *ro = raw_sk(sk); + struct raw_sock *ro; + + if (!sk) + return 0; + + ro = raw_sk(sk); unregister_netdevice_notifier(&ro->notifier);