From patchwork Mon May 9 16:57:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 12843871 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17B84C433EF for ; Mon, 9 May 2022 16:57:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239330AbiEIRBR (ORCPT ); Mon, 9 May 2022 13:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239444AbiEIRBP (ORCPT ); Mon, 9 May 2022 13:01:15 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F29211E010E for ; Mon, 9 May 2022 09:57:19 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id fv2so13690675pjb.4 for ; Mon, 09 May 2022 09:57:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gECE3xEP7jHNIcR16cw0a4r66b5ac6b60792aY0sxeo=; b=LIocaOLsDg8cf6KQOUKXKo2u+3ht2F4SNMSsvjtwcw2xG2rNqoRwLzj9W3mY0U4Zob UD95+RMOHEGnYWfUpzqpqkjH2sm1bPWv/n3nnbjwtKfn/bVXIhYvWGEHZnQFO7NYPbnz BysdTFozAKV8/7QdXNTh/TISCfCd1kYWeg/Dkduutta98cU0/Fi1SYJyJu9Kpp7zJAcE F045Zb1ooakQD1yu7hb1FOZldAi+nl13fNxiGDPsxpKSN7DJPCdsfucV8ck2czzSlZ9M KIgFrciw0ryYlYkWkplBaTm9eBB/+vEsDyAPhjk438ly/AHfrCTxpt1FSPc14ubbMiDE Hb5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=gECE3xEP7jHNIcR16cw0a4r66b5ac6b60792aY0sxeo=; b=Ej0JF5uuTTMhWFo5Vjp0WDugLEh7nR68YSJzw+DdxZDjNm3ErhgOxiBnFs53SHWl5S iuvdmHIcCcRyOUdhAO9Emispud/xD3yXMmhwjVowrA0NJkl3yeuwAbKYGaVIpHnjf5/2 C2qMGdptwwvGk6bWQpGhKreyv2/rg/39vKWFbDpKKrrbm59Y9KITVAzgxwEpPvGEVJ1/ h9nefRxTAUGuyhYDBQPy1kuh6rvlgbkv8iQp+hBeevx+TYoNA0pVFCVeVv/dR8uwE2nd LG4LE3dQ3ouPj4CcvQSnZlys9xvJ8gUYV+PODQkUnJhi62a3TVGNWWvwOeet0tyro1sw MiEQ== X-Gm-Message-State: AOAM532TNNjF6+WUtUVUlMdNsRcBoUy7L7IBZ/4RhTvBvMM1LBOf6oY9 B02EOfm1ubwlztywpPSncP4= X-Google-Smtp-Source: ABdhPJwjc3f1C5LqpaDUycPvX5lg9DEc4zSJybBLcPDlF/7rB9II+8cVBXq6uN8kwyPd66bRoQ6NZw== X-Received: by 2002:a17:90a:8b91:b0:1be:db25:eecd with SMTP id z17-20020a17090a8b9100b001bedb25eecdmr18922699pjn.10.1652115439513; Mon, 09 May 2022 09:57:19 -0700 (PDT) Received: from edumazet1.svl.corp.google.com ([2620:15c:2c4:201:5d30:4e79:203f:a909]) by smtp.gmail.com with ESMTPSA id c4-20020a624e04000000b0050dc76281c0sm8894176pfb.154.2022.05.09.09.57.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 May 2022 09:57:19 -0700 (PDT) From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev , Eric Dumazet , Eric Dumazet Subject: [PATCH net-next] net: warn if transport header was not set Date: Mon, 9 May 2022 09:57:16 -0700 Message-Id: <20220509165716.745111-1-eric.dumazet@gmail.com> X-Mailer: git-send-email 2.36.0.512.ge40c2bad7a-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Eric Dumazet Make sure skb_transport_header() and skb_transport_offset() uses are not fooled if the transport header has not been set. This change will likely expose existing bugs in linux networking stacks. Signed-off-by: Eric Dumazet --- include/linux/skbuff.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h index d58669d6cb91aa30edc70d59a0a7e9d4e2298842..043c59fa0bd6d921f2d2e211348929681bfce186 100644 --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -2804,6 +2804,7 @@ static inline bool skb_transport_header_was_set(const struct sk_buff *skb) static inline unsigned char *skb_transport_header(const struct sk_buff *skb) { + WARN_ON_ONCE(!skb_transport_header_was_set(skb)); return skb->head + skb->transport_header; }