Received: by 2002:ac0:b08d:0:0:0:0:0 with SMTP id l13csp4457494imc; Mon, 25 Feb 2019 05:21:46 -0800 (PST) X-Google-Smtp-Source: AHgI3IYwkAnn+ELkNk0NZhkHLNa5I++8ha9U/Xrb3kzJ/YVJFrW9FERtYUJS8Cgzf3IdPZ+DxQFf X-Received: by 2002:a62:39c5:: with SMTP id u66mr20116653pfj.245.1551100906586; Mon, 25 Feb 2019 05:21:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551100906; cv=none; d=google.com; s=arc-20160816; b=bl97J+t5w4fxfyLryLemUC6naHLQAKcvIodeibXPGshK/bPczLeqXC11Co7gvC4voP t+PeVFL5D8I5QzbxWktoAFyRHWMo3Amy28UoQBdGsAcHMudugqUAoSGUgTTLpXoBNjQz lixdaeWMyUT9EAJSP5ZwzeumQYiRE6/PBCUOpWW7PrH6WUjAuLn2R5+1lU0m2dWNtQUC d/nSg/38OaKlf4gtzz0Dm5h+PyYxP8tZxuFcD7ZoyiM0Er1kB/CwQt9GcJf4GsB0Q1Og dC9CBz91Cm7S5VYQEnEgp7ePRTZcz6Xp2dnKvN3CJlZMXBdT2QKFXJJEQguBIu9H1x7T xNKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=42P7JrA69uwhHiTSP2vRzKfe5v7Rl8PfBK+++Ng0/k8=; b=yYQLYgATq6DrbAUuCvMk8rgRq2YJcnvyjFQk/Phgx+4PqyWz+LPpTTDMtKqRXp5tTE fz5224jCPmFa+2dcVE3uWihvat3zTpUETyWncHmHZx0SjofyitEHZQgqhHbmIAeaMgTm PPEVGdIGxeOeNtVgr2GPYLF+gff1S5Xyg+6gWQAzQP/qbwco0GXMK9mQUCFt587Rd7Mv Dj6sSJDgQ0xWgWxc4ohVx7mPja8UGub12ntAVHT7PtnK/29xxTEYi1qjvWM3kEdTY1MJ tB6G0xoE3YQ3nVsUO/Ez/rUkxJjMzQKcBKuLO4wFVq03d75XxuLdEFV/7FiDla9wyLZG P9qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Jd9GiRBk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z72si8934216pgd.296.2019.02.25.05.21.30; Mon, 25 Feb 2019 05:21:46 -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=@gmail.com header.s=20161025 header.b=Jd9GiRBk; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727213AbfBYNU5 (ORCPT + 99 others); Mon, 25 Feb 2019 08:20:57 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:46290 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726921AbfBYNU5 (ORCPT ); Mon, 25 Feb 2019 08:20:57 -0500 Received: by mail-wr1-f65.google.com with SMTP id i16so9869074wrs.13; Mon, 25 Feb 2019 05:20:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=42P7JrA69uwhHiTSP2vRzKfe5v7Rl8PfBK+++Ng0/k8=; b=Jd9GiRBkLpuE2hi9wUfER2lFlMEExd5wcUaNDLj3HhDEKOAlexvJqGBAmt37pHfogO TjaJtylP5czejxmbsQFnSXqapGwWI6QihVBSmBkAFFUc0l+p5Rj4cHyPYAX9h4QMOn6M cO090KStyXNZBGGp4P/9Hx+UXaLQi5eZzifKCSUuPmIzOc3LaovbNcQMfFOp/IlMNELC 7Sye7JQIqJRlHfZtNcV4bwsI6ad6ggIi+K90Y93yZVwMPUmXRZm2x7aqJ4gyO0ZT7syr i69kQ02JSt2dcyu3VOXY5nu/rXmCKCxrrxlz6foYHW7K3j5Jv7U/kCxG6KF2H2dGDAnw KeqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=42P7JrA69uwhHiTSP2vRzKfe5v7Rl8PfBK+++Ng0/k8=; b=hQM5b3LVNa+5U4IsoWwX6mv3Um5srEALBpHPginYSydA79li0x/t7eC8ZBe/un7TOX h7Bea1CM35Wuv4R7VF+f29yYIVKQ0OzD3LgoUHybSD1iThdoFCMuxnZHw6j8um7fFfjh mQ6qsyORWLCHKgKgHfveT5grT4mOA5px8F0NzBtAs0U65Jdl1zFWnlDZ7FbDB/+G2y74 WDEO3qENyOtLu5AdIIppovgiFDTrgF3zZ/BZdl7I96neSkHJXSZY6Frcr8HPx/qNEA59 JdS9MdSZ7o6jI+aN7pzjUXMOiArIT98Y50fVZo3MoKoX/EJ3lStaFyWdC1V8246GL27U Ktzw== X-Gm-Message-State: AHQUAuaE97OKLOIOOW/B45Njnfy893Sx1CVybh1lWcld7AaJ2606LWMQ pEofihiUZqU8SVJNzMg6Wuh02+Pzvo1ntFABxck= X-Received: by 2002:a5d:6288:: with SMTP id k8mr13408646wru.173.1551100855319; Mon, 25 Feb 2019 05:20:55 -0800 (PST) MIME-Version: 1.0 References: <2aee76766861ac9e46b7acf123d5d6e8f2adf8e0.1551093937.git.lucien.xin@gmail.com> <20190225124614.GB30699@hmswarspite.think-freely.org> In-Reply-To: <20190225124614.GB30699@hmswarspite.think-freely.org> From: Xin Long Date: Mon, 25 Feb 2019 21:20:44 +0800 Message-ID: Subject: Re: [PATCH net] sctp: get sctphdr by offset in sctp_compute_cksum To: Neil Horman Cc: LKML , network dev , linux-sctp@vger.kernel.org, davem , Marcelo Ricardo Leitner Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 25, 2019 at 8:47 PM Neil Horman wrote: > > On Mon, Feb 25, 2019 at 07:25:37PM +0800, Xin Long wrote: > > sctp_hdr(skb) only works when skb->transport_header is set properly. > > > > But in the path of nf_conntrack_in: sctp_packet() -> sctp_error() > > > > skb->transport_header is not guaranteed to be right value for sctp. > > It will cause to fail to check the checksum for sctp packets. > > > > So fix it by using offset, which is always right in all places. > > > > Fixes: e6d8b64b34aa ("net: sctp: fix and consolidate SCTP checksumming code") > > Reported-by: Li Shuang > > Signed-off-by: Xin Long > > --- > > include/net/sctp/checksum.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/include/net/sctp/checksum.h b/include/net/sctp/checksum.h > > index 32ee65a..1c6e6c0 100644 > > --- a/include/net/sctp/checksum.h > > +++ b/include/net/sctp/checksum.h > > @@ -61,7 +61,7 @@ static inline __wsum sctp_csum_combine(__wsum csum, __wsum csum2, > > static inline __le32 sctp_compute_cksum(const struct sk_buff *skb, > > unsigned int offset) > > { > > - struct sctphdr *sh = sctp_hdr(skb); > > + struct sctphdr *sh = (struct sctphdr *)(skb->data + offset); > > const struct skb_checksum_ops ops = { > > .update = sctp_csum_update, > > .combine = sctp_csum_combine, > > -- > > 2.1.0 > > > > > Shouldn't you use skb_set_transport_header and skb_transport_header here? you mean: skb_set_transport_header(skb, offset); sh = sctp_hdr(skb); ? There's no place counting on here to set transport_header. It will be a kinda redundant job, yet skb is 'const'.