From patchwork Fri May 5 22:38:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9714453 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9F80B6034B for ; Fri, 5 May 2017 22:38:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9286428696 for ; Fri, 5 May 2017 22:38:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8738D28699; Fri, 5 May 2017 22:38:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4867B28696 for ; Fri, 5 May 2017 22:38:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751022AbdEEWip (ORCPT ); Fri, 5 May 2017 18:38:45 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:33863 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751264AbdEEWin (ORCPT ); Fri, 5 May 2017 18:38:43 -0400 Received: by mail-pf0-f170.google.com with SMTP id e64so8527265pfd.1 for ; Fri, 05 May 2017 15:38:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=hyfLTvNtqMt9r+E2io2qpyRPjdeuDK9aNhecU1D7Ylc=; b=dulYdz1CWZ6AaUtx14Oq6vCUm4q/JPdKxsaKmKAuOeH9+kAwd6doC/pNKSeCNanA4D 8gz+BZS5ZQ1X++xHDwpRRLNqPN5XEtKb2m2sj52eTexvWU4o0vPZgK5ZffSDjBX3xrpT zevfoIa+yB5qjcOQz3Rl5V1Rxsaf+xFgOI5uk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=hyfLTvNtqMt9r+E2io2qpyRPjdeuDK9aNhecU1D7Ylc=; b=YMA0xRIlqbkPMrFzrngOnkt9rCnAk+ri2/mSXtAtI5Qe1QnlpL89JcVs1nFM1mAbO1 rdKSFTe1gjh7Sx7aHic+jvpkvcVC47VErzcarhp6IrlyV5tGWKr3XU0Kwbwo/lxHE4eG x1++fHoZ7WMEiP3e5LgcTrHgUuD8OtZedQS0woNyXYcQFctnfKXNs6+0ukBb3j70aGxO qQrjRM6hSWXt/dACv+j1G5UDqgmqlFjGGajyhL5i2vG2NaoWbG9OiF38p0a3J3j9ccCH NxVnhkUUXTK5QHtrxKY2Rii5RpdUMZZONKEB2ZA+kyNKxFDPhp4ynSHvfaVQ6I9A3qLz 423Q== X-Gm-Message-State: AN3rC/6XhICywKCfV8MhmNoq2E9QuX7aa0IltCv2ZZSNdxn30IBO4cRV 2wcxTkIJvCxujixa X-Received: by 10.99.143.69 with SMTP id r5mr5959790pgn.77.1494023922908; Fri, 05 May 2017 15:38:42 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id s68sm9860998pfj.77.2017.05.05.15.38.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 May 2017 15:38:42 -0700 (PDT) Date: Fri, 5 May 2017 15:38:41 -0700 From: Kees Cook To: netdev@vger.kernel.org Cc: Kalle Valo , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Micay Subject: [PATCH] ray_cs: Avoid reading past end of buffer Message-ID: <20170505223841.GA20367@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using memcpy() from a buffer that is shorter than the length copied means the destination buffer is being filled with arbitrary data from the kernel rodata segment. In this case, the source was made longer, since it did not match the destination structure size. Additionally removes a needless cast. This was found with the future CONFIG_FORTIFY_SOURCE feature. Cc: Daniel Micay Signed-off-by: Kees Cook --- drivers/net/wireless/ray_cs.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index b94479441b0c..170cd504e8ff 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c @@ -247,7 +247,10 @@ static const UCHAR b4_default_startup_parms[] = { 0x04, 0x08, /* Noise gain, limit offset */ 0x28, 0x28, /* det rssi, med busy offsets */ 7, /* det sync thresh */ - 0, 2, 2 /* test mode, min, max */ + 0, 2, 2, /* test mode, min, max */ + 0, /* rx/tx delay */ + 0, 0, 0, 0, 0, 0, /* current BSS id */ + 0 /* hop set */ }; /*===========================================================================*/ @@ -597,7 +600,7 @@ static void init_startup_params(ray_dev_t *local) * a_beacon_period = hops a_beacon_period = KuS *//* 64ms = 010000 */ if (local->fw_ver == 0x55) { - memcpy((UCHAR *) &local->sparm.b4, b4_default_startup_parms, + memcpy(&local->sparm.b4, b4_default_startup_parms, sizeof(struct b4_startup_params)); /* Translate sane kus input values to old build 4/5 format */ /* i = hop time in uS truncated to 3 bytes */