Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp8704580imu; Tue, 4 Dec 2018 12:47:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/X9gHNV9LbwRXUKJUWAraUfUpkOJNyas4XItu2QxiBhAwwfYQOESI15gA9nd7Z+oVHlJr3a X-Received: by 2002:a62:f5da:: with SMTP id b87mr21941750pfm.253.1543956423913; Tue, 04 Dec 2018 12:47:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543956423; cv=none; d=google.com; s=arc-20160816; b=HL6PNRMdNPmHs1Zjw8QpOAr07aDzpIF6I1MprFaCEk9lrLgfVAU/fSNuEolDLB3yfe 9+Qz7ZavlV8h4IL7vV3YsWEMy7iAy7Dw+ZA0Lrnof1fagTZWm89jP86GD0I1uumMPQNk mfZfgVOo1O+HoKsLujMq0/pdvZTLQZ+IQuOLooyrZCXx+6/oMU1xG6uKt2QcrGDAdPGM Tc5zj43TR211JQvuw7adNa+qC4KL2GwCfCFHLAPou76rsFR5qxwIP0T0/oYFGO3XT6mn UmFReFMT5lwFutVykzRS7/Boh3nCteIqLDQcO6LG+sq+4EyNNjbdJOTmTclMdIfMl/4o tgfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=B6LjIAQyrSZRT/YyT/z3DmVMULJl2fR/ba1140QZlUY=; b=i+InU+yZrv3pbwrIxd8udvL3dCg7x1ZF0jDFEbDPtdSahv2wHX2rInFxP/SD4aATmb A/kiaXoEsFsUuDw5f+DRFlcHn9PdOap39+7Bul0lECQDZSzKWgR3N+v+ZK2dnluIp6i9 p7N832u5wVQB3w8MZ70rV/hnHXrwGhEveNLTBXm2RD9He5+Bv2JWY6Dr2F5qyg2HwdUb 0ZczP1l9/WX1OInM0twfGCVewpha+KEV/worOEV6d2Net8vGWVq4aE+A+kjzAfciUdWu 1y0FirAwIhiLGUk+FRjJgNmJbgWgojqCOgJ/Xr1Nr5flp8B/iTS0TV47dqOes1CVbvIC W/eQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k62si18715923pfc.208.2018.12.04.12.46.48; Tue, 04 Dec 2018 12:47:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726454AbeLDUpq (ORCPT + 99 others); Tue, 4 Dec 2018 15:45:46 -0500 Received: from www.llwyncelyn.cymru ([82.70.14.225]:38422 "EHLO fuzix.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbeLDUpq (ORCPT ); Tue, 4 Dec 2018 15:45:46 -0500 Received: from alans-desktop (82-70-14-226.dsl.in-addr.zen.co.uk [82.70.14.226]) by fuzix.org (8.15.2/8.15.2) with ESMTP id wB4Kj9MP024700; Tue, 4 Dec 2018 20:45:10 GMT Date: Tue, 4 Dec 2018 20:45:08 +0000 From: Alan Cox To: Jian-Hong Pan Cc: Andreas =?UTF-8?B?RsOkcmJlcg==?= , "David S . Miller" , netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Marcel Holtmann , Dollar Chen , Ken Yu , linux-wpan@vger.kernel.org, Stefan Schmidt Subject: Re: [PATCH V4 5/6] net: maclorawan: Implement maclorawan class module Message-ID: <20181204204508.3ebead06@alans-desktop> In-Reply-To: <20181204141341.4353-6-starnight@g.ncu.edu.tw> References: <20181204141341.4353-6-starnight@g.ncu.edu.tw> Organization: Intel Corporation X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-redhat-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +void > +lrw_parse_frame(struct lrw_session *ss, struct sk_buff *skb) > +{ > + struct lrw_fhdr *fhdr = &ss->rx_fhdr; > + __le16 *p_fcnt; > + > + pr_debug("%s: %s\n", LORAWAN_MODULE_NAME, __func__); > + > + /* Get message type */ > + fhdr->mtype = skb->data[0]; > + skb_pull(skb, LRW_MHDR_LEN); This does not seem robust. There is no point at which you actually check the message size is valid etc > + fhdr->fopts_len = fhdr->fctrl & 0xF; > + if (fhdr->fopts_len > 0) { > + memcpy(fhdr->fopts, skb->data, fhdr->fopts_len); > + skb_pull(skb, fhdr->fopts_len); > + } In fact you appear to copy random kernel memory into a buffer > + > + /* TODO: Parse frame options */ > + > + /* Remove message integrity code */ > + skb_trim(skb, skb->len - LRW_MIC_LEN); and then try and trim the buffer to a negative size ? Alan