From patchwork Fri Jan 27 07:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 13118231 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 A7AF9C38142 for ; Fri, 27 Jan 2023 07:45:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232801AbjA0HpT (ORCPT ); Fri, 27 Jan 2023 02:45:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51750 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbjA0HpS (ORCPT ); Fri, 27 Jan 2023 02:45:18 -0500 Received: from sipsolutions.net (s3.sipsolutions.net [IPv6:2a01:4f8:191:4433::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3066239282 for ; Thu, 26 Jan 2023 23:45:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-Id:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=vD5GDesKkOAVOZz7ndcWLKnkKoZ3quMECf3cb4xfhuk=; t=1674805517; x=1676015117; b=BHtWtm63ApMoN+y0sZCSAktSuJEXneckIMeZNjlF4HI4p/4JxzDj1O4ZRAOFNsdm5cMFpv7pbeU LmZxi1N9PMwx3odgGvpx9nNV0gO4v0vdJwMFZwGJaQi339s5hqBMFWcIG/xb4F89CU80/xONdkXuj 9dS83PRXDMfDrIXeGPN073m/7zFOy0ZiHLcha+JfsHU7Ck+wdcWkDyPGtIM05KPvDPDayohtOy18J KcXD1+kEcWJTvdlnht/PP+ec+J33VZiC1RlT+q4C56+NtnKQOlNt8tuG4CdnlEwTi7wVl+6eQoXdn ArMzavs+uQnuuWtkMeofujynwwYGPN0fU4mw==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1pLJQ8-00DS7N-1N; Fri, 27 Jan 2023 08:45:12 +0100 From: Johannes Berg To: netdev@vger.kernel.org Cc: Johannes Berg Subject: [PATCH net-next] net: netlink: recommend policy range validation Date: Fri, 27 Jan 2023 08:45:06 +0100 Message-Id: <20230127084506.09f280619d64.I5dece85f06efa8ab0f474ca77df9e26d3553d4ab@changeid> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Johannes Berg For large ranges (outside of s16) the documentation currently recommends open-coding the validation, but it's better to use the NLA_POLICY_FULL_RANGE() or NLA_POLICY_FULL_RANGE_SIGNED() policy validation instead; recommend that. Signed-off-by: Johannes Berg Reviewed-by: Ido Schimmel --- include/net/netlink.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/net/netlink.h b/include/net/netlink.h index 6e1e670e06bc..b12cd957abb4 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -276,7 +276,8 @@ enum nla_policy_validation { * Note that in the interest of code simplicity and * struct size both limits are s16, so you cannot * enforce a range that doesn't fall within the range - * of s16 - do that as usual in the code instead. + * of s16 - do that using the NLA_POLICY_FULL_RANGE() + * or NLA_POLICY_FULL_RANGE_SIGNED() macros instead. * Use the NLA_POLICY_MIN(), NLA_POLICY_MAX() and * NLA_POLICY_RANGE() macros. * NLA_U8,