From patchwork Sat Apr 3 15:13:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Skripkin X-Patchwork-Id: 415129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63960C433B4 for ; Sat, 3 Apr 2021 15:14:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 32D1060FE6 for ; Sat, 3 Apr 2021 15:14:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236735AbhDCPOB (ORCPT ); Sat, 3 Apr 2021 11:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236364AbhDCPOB (ORCPT ); Sat, 3 Apr 2021 11:14:01 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0FAEC0613E6; Sat, 3 Apr 2021 08:13:57 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id v15so11346399lfq.5; Sat, 03 Apr 2021 08:13:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K3Jb56LOApi297xEEIjS/VCdKqZUuXjd8AUAcVzA0V8=; b=pZosICLiqaTDTTeAzLLUy72xsrdO36JNiueb9h/Hl+9w64PtoFL6arRGY5oBpfJ6uk +mM8ZmHBQlZdqHoBOlIrit92IJd/+fJ+yKK/mOvAqnDJvRGKkVmm9NCTnPAhB+LUWG0l n+pKTIemjHPoj5+gwj2QC/7lQkArIRxxJKYg9H3vWim81hT4mt3ceHTk64kN9lFrIQA2 OvXnOA/QRJXPOlkaBFlstVVfOQ68ax4yGQqdl/aCG48gGyQ5egbUeSu365Ow3sbGZht5 q6hsxj73BtuGaQWE52Egc1ptQwszlmmPhUNbZBCiNvIPCIqcyarP//lqpEyqXtoiatvZ wyTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=K3Jb56LOApi297xEEIjS/VCdKqZUuXjd8AUAcVzA0V8=; b=fjUC50NzQyVRao2ZAMBsj8ww6bOBRKmSjnMQIMuKn8Z0ReNMDNTljjn4qUglNrSSxm rSZHXfjL96cB0gYCYz6vF2E2IwuHwz3e4tKAEfGJmAjJJ9SnVSFCu0WEgNJGxShYEzOE eLuTTpvaqCN/URj1NVtyXR1qSJIx3D7/LYw3/rrLd4k0/tzic28vWZ14uPm/EvUSWWwB yK11FjB7zMWwqKaWkoVJGJUYM1JZT0qyAn6l4nfP9FOZfoJd6wP8K7m+Qmwuq/ewv1pf NisM6WmvKHUU0FrjyiHC4I1BwidhQqsczaKaxp4zpGUGGt5XuFOJvu3puJwf5iiIg8fv CG0w== X-Gm-Message-State: AOAM533+3aPhs7UFAbV3+XtqNLI+tQwD/J7hFm7VDLsaorBTW8hq6uDP d3h+31jFo2T0emUeCM4BkXw= X-Google-Smtp-Source: ABdhPJy6unKX9vl33a30tYZ3wwEi9Eq7hlSy7MoPtLgXyzwMglTnVkHtjpHd+1Qaw5xpWNBHmHbwxg== X-Received: by 2002:a19:5219:: with SMTP id m25mr11517883lfb.416.1617462836237; Sat, 03 Apr 2021 08:13:56 -0700 (PDT) Received: from localhost.localdomain ([94.103.229.149]) by smtp.gmail.com with ESMTPSA id z7sm1222966ljo.64.2021.04.03.08.13.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Apr 2021 08:13:55 -0700 (PDT) From: Pavel Skripkin To: davem@davemloft.net, kuba@kernel.org, johannes.berg@intel.com Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Pavel Skripkin Subject: [PATCH] net: netlink: fix error check in genl_family_rcv_msg_doit Date: Sat, 3 Apr 2021 18:13:12 +0300 Message-Id: <20210403151312.31796-1-paskripkin@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org genl_family_rcv_msg_attrs_parse() can return NULL pointer: if (!ops->maxattr) return NULL; But this condition doesn't cause an error in genl_family_rcv_msg_doit Signed-off-by: Pavel Skripkin --- net/netlink/genetlink.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index 2d6fdf40df66..c06d06ead181 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c @@ -719,6 +719,8 @@ static int genl_family_rcv_msg_doit(const struct genl_family *family, GENL_DONT_VALIDATE_STRICT); if (IS_ERR(attrbuf)) return PTR_ERR(attrbuf); + if (!attrbuf) + return -EINVAL; info.snd_seq = nlh->nlmsg_seq; info.snd_portid = NETLINK_CB(skb).portid;