From mboxrd@z Thu Jan 1 00:00:00 1970 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 616C4C43334 for ; Fri, 17 Jun 2022 16:39:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383429AbiFQQj2 (ORCPT ); Fri, 17 Jun 2022 12:39:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1382699AbiFQQj0 (ORCPT ); Fri, 17 Jun 2022 12:39:26 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD6E3427C0 for ; Fri, 17 Jun 2022 09:39:25 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id f16so3357153pjj.1 for ; Fri, 17 Jun 2022 09:39:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=h6IrLdY6w4OsypWEzzKKv5b850fPgk5gwMN7Tf3l3vQ=; b=cGB9S6qXHZUmmKqLb8Czce7aQQ31G8cciRGY3uS9OqZ2KLHawZOjaiA/UhIeiPKRoQ RGuqtkjn3l21zbzDcWWuJPd0THw5jwa7NmutFVEycllAOF3tWpkr/85h2O2wCLkiuLFw 8N+27G96xzt/eUHx0kvvnLRlNMnhPTX+o7qiAHUN7skj0o/o0ZlnsCy7YjPfQp37Ly3L 3DHUV3EqAvFn4BVzjqNIkCCIOAJ3Mmd1LEB5SVxYqSMvp87RZlon0Wxd+CymmWt6tIn9 vNMFfo2Z+LtXNL6Yc6HoJcu2P+UwgmfKDfQlpdHrykmwYAPkaV+JwMzziTavYhEc7RlI pz4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=h6IrLdY6w4OsypWEzzKKv5b850fPgk5gwMN7Tf3l3vQ=; b=K5vcS3fFQ0NLchdIk/V4CqcyrYy4uIv82T0gQhY36bgtmuPw6sxmoGrkH/l2orqoQC 2lzExTFZR3F/klOxdbJCicOV7oy8k128sar1kUnxkULBi6I5sHW/HwYpODchYVgouZLh no+C7Q92qfLjP0bLc12H7G7EqtxEx80tFpMCpA8Y1o8TjQCWnIJ2nHHlLIeZg/oYdM5+ Jy/BaY03+3OKuGiFgtWxZbEFhwNGJB5w2t+JLV/CoFROPsESMwqciM6g0wb4IChDi/xg Pyt5aSsoLfjp/dP3h1uy+znGrQHoyge/wHP97ksxGzzYRT6H690SptPcyKqU3G1UNlge Wgrw== X-Gm-Message-State: AJIora9GAyQYEy21b1sjxKavkGLzVL+1huE1BIZTEVeWm6dxeCJwv8JH Ll+JAHSoc7zAGkZ5J9JJFRmYfg== X-Google-Smtp-Source: AGRyM1tSNcsBlD5rmWFBnXmaOQSTZiEb3QWszdo4GJLGK5UOx6thlgdZtHfv+x5h3/bswUKYS8BMdQ== X-Received: by 2002:a17:90b:1b07:b0:1e8:41d8:fa2 with SMTP id nu7-20020a17090b1b0700b001e841d80fa2mr11466844pjb.204.1655483965098; Fri, 17 Jun 2022 09:39:25 -0700 (PDT) Received: from google.com (201.59.83.34.bc.googleusercontent.com. [34.83.59.201]) by smtp.gmail.com with ESMTPSA id o12-20020a62f90c000000b0051be16492basm3934309pfh.195.2022.06.17.09.39.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jun 2022 09:39:24 -0700 (PDT) Date: Fri, 17 Jun 2022 16:39:21 +0000 From: Carlos Llamas To: Riccardo Paolo Bestetti Cc: "David S . Miller" , Hideaki YOSHIFUJI , David Ahern , Eric Dumazet , Jakub Kicinski , Paolo Abeni , kernel-team@android.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Miaohe Lin , Maciej =?utf-8?Q?=C5=BBenczykowski?= Subject: Re: [PATCH v2] ipv4: ping: fix bind address validity check Message-ID: References: <20220617085435.193319-1-pbl@bestov.io> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220617085435.193319-1-pbl@bestov.io> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 17, 2022 at 10:54:35AM +0200, Riccardo Paolo Bestetti wrote: > Commit 8ff978b8b222 ("ipv4/raw: support binding to nonlocal addresses") > introduced a helper function to fold duplicated validity checks of bind > addresses into inet_addr_valid_or_nonlocal(). However, this caused an > unintended regression in ping_check_bind_addr(), which previously would > reject binding to multicast and broadcast addresses, but now these are > both incorrectly allowed as reported in [1]. > > This patch restores the original check. A simple reordering is done to > improve readability and make it evident that multicast and broadcast > addresses should not be allowed. Also, add an early exit for INADDR_ANY > which replaces lost behavior added by commit 0ce779a9f501 ("net: Avoid > unnecessary inet_addr_type() call when addr is INADDR_ANY"). > > Furthermore, this patch introduces regression selftests to catch these > specific cases. > > [1] https://lore.kernel.org/netdev/CANP3RGdkAcDyAZoT1h8Gtuu0saq+eOrrTiWbxnOs+5zn+cpyKg@mail.gmail.com/ > > Fixes: 8ff978b8b222 ("ipv4/raw: support binding to nonlocal addresses") > Cc: Miaohe Lin > Reported-by: Maciej Żenczykowski > Signed-off-by: Carlos Llamas > Signed-off-by: Riccardo Paolo Bestetti > --- > This patch is sent as a follow-up to the discussion on the v1 by Carlos > Llamas. > > Original thread: > https://lore.kernel.org/netdev/20220617020213.1881452-1-cmllamas@google.com/ > Reviewed-by: Carlos Llamas Thanks Riccardo for adding the test cases. I would appreciate it if next time you add a co-developed tag or maybe a separate commit as opposed to overriding the original author. This is fine though. -- Carlos Llamas