Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3861348ybc; Thu, 21 Nov 2019 15:09:43 -0800 (PST) X-Google-Smtp-Source: APXvYqz/2s7ysjcZ/jrgAryMeSA478iBsP0ld+xIQiLN4yaTUxLU99/EuCWriqF8gqrqPE3Ca73W X-Received: by 2002:a17:906:8591:: with SMTP id v17mr17412213ejx.185.1574377783213; Thu, 21 Nov 2019 15:09:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574377783; cv=none; d=google.com; s=arc-20160816; b=fYZThntCcQ9QV7IJbfPyMZVZpsWr5dAAoPNfFdXEZaQpI6aaz7lsl5fUsOUyC0RTVe DKsylgytSRJB4TgxXA2rQykP6CMfQPr+j/3iAvngy+1iyKfYGp+nj/rVRIR663zp5grB 81wFN9d3V/OT7DlqmZSuBFiW0lEEnLed3LmSCmXL1WHFrgyYO9uT4/rheZIyfVCUwplr e2VgPs4YCvJvnfEB2D43UD1tsx7asUFnCX86nJ6pRkEISIcIcCfutkV3DGD9btQyAY1p hKX89ZQozKd4i8WPSbTgAq6qPdumlhd2B3q4KT4PFNx0lLtH8S1J+VAUGPKj07NSO/Ua QaZw== 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:dkim-signature; bh=ujSnirx0MMYk1nWbIfrsLRgvcTHBcDKnqPSTu0uZhPM=; b=YFQtqo0F92JjMTSAso/rW1R/6RG0YnijWMWdai9Y669iuwaNjFGLmuOUXKLvgD7/MW QWMDfpd2cgJ9taudhj2utgyDS1iGQDe1rv35LI0IAqrLwBLIngLx78ShebHZuekU3rBr HE7t7aNqM1J3eY96UsGWRw0HLad+qC2b1+Cpx4zC7Ym/o2nIp+rtygUKKtXl+EVZZT7L xw3mD8krMT9IJZg7ycLTDSkXaCfOMQRC+aO5MvK+o2sPNErH+gfKLM4/LmqHoLsWZzfi f0DJcp4ubaIs4jPq5ZDrcOH1RAh3+J6SFIrkDm4s+lxkgdpfYY0gPCnZrvIk5tIcuOWx RqLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b="Nc6/mbo0"; 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 k4si2863524eji.269.2019.11.21.15.09.17; Thu, 21 Nov 2019 15:09:43 -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; dkim=pass header.i=@netronome-com.20150623.gappssmtp.com header.s=20150623 header.b="Nc6/mbo0"; 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 S1726725AbfKUXE4 (ORCPT + 99 others); Thu, 21 Nov 2019 18:04:56 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:45415 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726265AbfKUXEz (ORCPT ); Thu, 21 Nov 2019 18:04:55 -0500 Received: by mail-lj1-f193.google.com with SMTP id n21so5073499ljg.12 for ; Thu, 21 Nov 2019 15:04:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :organization:mime-version:content-transfer-encoding; bh=ujSnirx0MMYk1nWbIfrsLRgvcTHBcDKnqPSTu0uZhPM=; b=Nc6/mbo0NU7TqyfZ0KlcWiAFlSVLQv17ZroqrY0RRWkOLd+EX3M0YN/8CWH1eoWDxm 2XpNdcx5yss6p7g5w7yowMTkhd7PhLgYbpaqA/BdiMguJHL7uZ8TFq9ct50g3xAb9MKi uhYApgEyRVoNYA0UGHawQt2+EmxOwKrQGWpeHVB9t/hau3ZCsCa2P8QRC9000TmAfAaU 8WzEu4NDMYH1F3s30mvOmIRvbIfbo2uSIU29VSXlubGOa3SYWiqK5xXIvi3A7I0iz9Ix VUVSNyhYKiy8s/u9kOjcbbaUoswVrPIZdGtdLvMJVR6nLYyPFZUKK98OIX58Vf1LFTdr 8P8Q== 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:in-reply-to :references:organization:mime-version:content-transfer-encoding; bh=ujSnirx0MMYk1nWbIfrsLRgvcTHBcDKnqPSTu0uZhPM=; b=f/JRs6d0uIeNJJiAxu76S2S+Ujg9SANn/aqv5tj8d8sRU5uhazE0YdJ01jhioMBT+F Hqkw1NIPZ+Mq31y9iZ+vyINusgpMELcKgZP9r/i0yCfhX6X0Fl8pX5F7lfE4Ex3LUhoK w8eMJX8S6Ro2ho8vQ/bsudX/dNzxSq84BASFhRqAQ20s3hu9ox5u8nofcR/PodC/tfLA EkWn3kT5W+aYrA4rNggjNiSSON72vD+uAi+xlSodfJCbngZi/CngMYppcNcyYZ0VTwmx 3SMfmDLphYyDDdsNjZEUY6E97ZyAjeRuxG1mBquwalsVUOO2ilGvA241qhl7TL3BldeX IsIQ== X-Gm-Message-State: APjAAAVnhgb1b0yGIxtNlQQBVpJpimfZIyjl1sDh1zelSPWJKTnEBbKi JvBbwO5kCONrkCmOk4u9qmQgyg== X-Received: by 2002:a2e:8857:: with SMTP id z23mr10180706ljj.50.1574377493540; Thu, 21 Nov 2019 15:04:53 -0800 (PST) Received: from cakuba.netronome.com ([66.60.152.14]) by smtp.gmail.com with ESMTPSA id i6sm2129075lfo.12.2019.11.21.15.04.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Nov 2019 15:04:53 -0800 (PST) Date: Thu, 21 Nov 2019 15:04:45 -0800 From: Jakub Kicinski To: Haiyang Zhang Cc: sashal@kernel.org, linux-hyperv@vger.kernel.org, netdev@vger.kernel.org, kys@microsoft.com, sthemmin@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH net,v2 1/2] hv_netvsc: Fix offset usage in netvsc_send_table() Message-ID: <20191121150445.47fc3358@cakuba.netronome.com> In-Reply-To: <1574372021-29439-2-git-send-email-haiyangz@microsoft.com> References: <1574372021-29439-1-git-send-email-haiyangz@microsoft.com> <1574372021-29439-2-git-send-email-haiyangz@microsoft.com> Organization: Netronome Systems, Ltd. 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 On Thu, 21 Nov 2019 13:33:40 -0800, Haiyang Zhang wrote: > To reach the data region, the existing code adds offset in struct > nvsp_5_send_indirect_table on the beginning of this struct. But the > offset should be based on the beginning of its container, > struct nvsp_message. This bug causes the first table entry missing, > and adds an extra zero from the zero pad after the data region. > This can put extra burden on the channel 0. > > So, correct the offset usage. Also add a boundary check to ensure > not reading beyond data region. Please provide a change log at the end of the commit message when posting new version in the future. > Fixes: 5b54dac856cb ("hyperv: Add support for virtual Receive Side Scaling (vRSS)") > Signed-off-by: Haiyang Zhang > > - tab = (u32 *)((unsigned long)&nvmsg->msg.v5_msg.send_table + > - nvmsg->msg.v5_msg.send_table.offset); > + if (offset > msglen - count * sizeof(u32)) { Can't this underflow now? What if msglen is small? > + netdev_err(ndev, "Received send-table offset too big:%u\n", > + offset); > + return; > + } > + > + tab = (void *)nvmsg + offset; > > for (i = 0; i < count; i++) > net_device_ctx->tx_table[i] = tab[i];