From patchwork Sun Apr 7 11:51:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Krause X-Patchwork-Id: 234485 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 828F32C00BB for ; Sun, 7 Apr 2013 21:52:45 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933520Ab3DGLwj (ORCPT ); Sun, 7 Apr 2013 07:52:39 -0400 Received: from mail-bk0-f43.google.com ([209.85.214.43]:40810 "EHLO mail-bk0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933373Ab3DGLwh (ORCPT ); Sun, 7 Apr 2013 07:52:37 -0400 Received: by mail-bk0-f43.google.com with SMTP id jm2so2647058bkc.16 for ; Sun, 07 Apr 2013 04:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=Nii1KBTf+qMMvQFkgPPIo/h106urAk1BPKk34rr1OPw=; b=qdTQ1UunUpAeJvZ2sqNdNcszu5hNGcmD0CLudP3coYSvqIEW1Z1RWlqGcsb5meoz2d CC18GnLjL0XreyiAgwQ+Qt21naMvDcgQYno80Zyv66w0TBau27LOXWbbLh6MNwYnG5pM d63ziMaGsvOCPFESbMIjvUS/QG9UAeToqd7GUSEGQGQfXYbbwevmowAgE/pa4HjlZK/G aLqykgDQpFBtXNLgw3Jzy5tY92Oc/2VMi0e4q4a6afL6wj0l9/lcYNy3c1fqrwmd3jFA LOBcdyW0JX0HwpZaQu1+2mQNAA1qN7l6TkWEwNlDQuCXm+kGKJAZ+2WQ29ITIdTqZxl0 SbDw== X-Received: by 10.204.224.75 with SMTP id in11mr9428045bkb.97.1365335556623; Sun, 07 Apr 2013 04:52:36 -0700 (PDT) Received: from jig.fritz.box (pD9EB4E1C.dip.t-dialin.net. [217.235.78.28]) by mx.google.com with ESMTPS id da16sm1974758bkb.2.2013.04.07.04.52.35 (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 07 Apr 2013 04:52:36 -0700 (PDT) From: Mathias Krause To: "David S. Miller" Cc: netdev@vger.kernel.org, Allan Stephens , Aloisio Almeida Jr , Andy King , Arnaldo Carvalho de Melo , Dmitry Torokhov , George Zhang , Gustavo Padovan , Johan Hedberg , Jon Maloy , Lauro Ramos Venancio , Marcel Holtmann , Ralf Baechle , Samuel Ortiz , Samuel Ortiz , Sjur Braendeland , Ursula Braun , Brad Spengler , Mathias Krause Subject: [PATCH 11/16] netrom: fix info leak via msg_name in nr_recvmsg() Date: Sun, 7 Apr 2013 13:51:57 +0200 Message-Id: <1365335522-29931-12-git-send-email-minipli@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1365335522-29931-1-git-send-email-minipli@googlemail.com> References: <1365335522-29931-1-git-send-email-minipli@googlemail.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org In case msg_name is set the sockaddr info gets filled out, as requested, but the code fails to initialize the padding bytes of struct sockaddr_ax25 inserted by the compiler for alignment. Also the sax25_ndigis member does not get assigned, leaking four more bytes. Both issues lead to the fact that the code will leak uninitialized kernel stack bytes in net/socket.c. Fix both issues by initializing the memory with memset(0). Cc: Ralf Baechle Signed-off-by: Mathias Krause --- net/netrom/af_netrom.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index d1fa1d9..7fcb307 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -1173,6 +1173,7 @@ static int nr_recvmsg(struct kiocb *iocb, struct socket *sock, } if (sax != NULL) { + memset(sax, 0, sizeof(sax)); sax->sax25_family = AF_NETROM; skb_copy_from_linear_data_offset(skb, 7, sax->sax25_call.ax25_call, AX25_ADDR_LEN);