From patchwork Wed Feb 28 15:54:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rand Deeb X-Patchwork-Id: 207904 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp3434115dyb; Wed, 28 Feb 2024 07:56:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWC4n+IOXI5SC3auwEjtgwPvgvXgNwHlh6oUym1++GqvKp+KH4NEmQGP6nXJ2YzJdC6jnyu0D18aDus5sdWo9n4GSBaLg== X-Google-Smtp-Source: AGHT+IG2x1dOIowWCOP4SS+yyKYBWRtL5Iol0LsB7Nen1rOYqfTqS7j5gbXEJL/OydpaU4/uIOA6 X-Received: by 2002:a05:6808:f8e:b0:3c1:c06b:76c2 with SMTP id o14-20020a0568080f8e00b003c1c06b76c2mr852554oiw.21.1709135809617; Wed, 28 Feb 2024 07:56:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709135809; cv=pass; d=google.com; s=arc-20160816; b=Wl5JFdPIXFFGjENC6WvwbiU4YalAFHnnQeUIwmlAPeBE07sk+yb1CxU5CEy46uTW2v k32E/P46HuYcCV1Dwn2UotJ0i9s2szAqXzqJVmVf6yE5UZgKDU1qsR30k579jDBDvPYb OYqEeewPhNcWRJmyVZUaXpnyQyKjAjyzytflAZwRCZyhnn6QrFr2FYNXWIhvr5Soke96 ojslBshRyOMW4ogFazY45whv1SKeIWr5b5scuBD7cUK42TJ0GImOSR8H9g4BOaYPdVtH csO71NodXOUGDWe8TYiz1H/HNoA+iM1h5cOsHMWcDWB4gYVj2N3v1Z+CstdJLzMx4wX1 3Uqw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=/Zr38ZfbAtVyJs0WSKTX26b9HT0iMoobWLC4JSkjjuk=; fh=pKSDi0R4IMR0yvAk8PyR8u+JmxjyxesgrK7Oi/hiQsg=; b=NacqW2b7FOk0ql2vCR27MJ71KMmnjiu+7Qui7rqdwtAHi3MFAcM5icirH8ko5p8lBD 1Twx4SRuFwXQ5gUWcuSZsw7cJZgFO1fmm+/m/PYElBOCywJx4YPCjePJbkt1GrBvMe3c aOpAzAruX62vrj7IeI6WMOUHqSkWUr27OiOd2DD7g0MfKNTPHl3TtnyP171jucvhKp4L GJ+Zvq7j0cKxNS8ux0pbr1v2yuBwjizYmqghWEdOy9KGoir9Lvda27gCoFMewyvYWJJV AA+Op94BGS0FqMjVj6pMvwtGBSNPMBAhzGPV0D/yLhLPUfDtsdp37LGcsVATQqWfCcu5 plqQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OWThLdHv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-85307-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85307-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c6-20020ac86e86000000b0042e57f665d8si9278899qtv.701.2024.02.28.07.56.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 07:56:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85307-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OWThLdHv; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-85307-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85307-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 50B3C1C220DD for ; Wed, 28 Feb 2024 15:56:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F9AC15D5D6; Wed, 28 Feb 2024 15:56:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OWThLdHv" Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A7E315C8; Wed, 28 Feb 2024 15:56:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709135789; cv=none; b=roSEb85+F1Hw4TbY2E70oP2k6PyBD5b/899+l2dlcLg/9bzIEAhIhL7AJB0p859o7QNrNzk+t9uk6zt8TkYtwpFVZgih0OUSxWgOESsVp1dKBz1VxBLPh1LmFy97ngrxoWaAIEgDyizIGCJ7anKeujU47qYXooFSFi15rO1bT04= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709135789; c=relaxed/simple; bh=4oMFZxzX5PZA/M9VG2s4kgB/DZ8GhzCcWfCzEPQkVt8=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IUE3h+U2OoP9nookdLwWvwFenoXQ4vWHu2qH+xc1cu297DzP8C1QC0kovcyks772kIj30fxzeZJoeURm2yDEiW2SH1hqZ/FKroGnK+51qRyz7Jg+h9NkJLB7QjjCXXywe2KSbW+ZG8UUBNlB8fz/qyj8K8wdzYct8XwTuUIf7+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OWThLdHv; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2d23114b19dso79799881fa.3; Wed, 28 Feb 2024 07:56:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709135786; x=1709740586; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=/Zr38ZfbAtVyJs0WSKTX26b9HT0iMoobWLC4JSkjjuk=; b=OWThLdHvZEMmIBUxwa6IzIM3BmDlh4d6EX53fDo3MdYEzcI/MXMJktHTmmnHOGvKJX 7su4Npcr1QjY0c+sjz9t8s0vsUMPhp7i90YuqnnrpNbakxFGWLBrol0h0WGTUGvJznpS gcd409oWO7emaMpHCzHXWGAB8RJZZrf5BvCUjrTQtUaKsn+QMjRQnJc4BPF4QUxhNAqC occ7aug2KfEFekVXVLsV+HOrvk7NAvic0DXflkJrptxR80WuvnKd4I05YwoIyKIA0bmA mahZHU9rcFNrCQ3FNhTnQjHNbAmJ0Y7Xsf9v7hXmVfkiokVuVYid17pUrceFucaede9m VsBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709135786; x=1709740586; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=/Zr38ZfbAtVyJs0WSKTX26b9HT0iMoobWLC4JSkjjuk=; b=OfJWXkwlv+7qAvAlsacvey1cL/mHJ43qI1DyKjTrWQ5Z3pGcFmH5tsPDx641Nu60zm g0FZnqgBEqPq3CF8vxuHoUaJsRYn9Jm3nzwBcEarM1UH70JJ6ikmnyBKHyfIWgAmgiPP MEdSomY00VjA568jQoMwCmvpTkj9k3CAt5a/ua5dLa7QtNXarxs5R+XrMXCFRG5Js8tx vg3VsjLZkfP+imSREJq+1epRNNRyPsab3tQ9zpVLExIk/nTyLmA6rtyjPUPuHxOIBXEY xnXhlGXbYEJjTtiVR9IJCqqPfFqjk+YSBm6dInIyKZpp03PtQ7XcjfQefKxoQxjuOx/A G93Q== X-Forwarded-Encrypted: i=1; AJvYcCXHmv/u5jh1RcQuD+OaKRf3v2UalfOJBgA6PJ3ntdEL5CsKZQn6PFQApIKdoomkbNj9UpKdyFl5dDaWFIuYWXFuXZ0rchnddKuB5XCCde+3PTb96v6+TXjmDJogtZvvcbA9Tiy8 X-Gm-Message-State: AOJu0YwPra0Vnd4CHi0byVAe2dIAC4M1hBKZ1S4VsYHz7hk+GTN6vDqj G4oerFfjFT/4w9QxF0ths8j5zRV4NdkXnYouiHRvwsK+JPvUt7gEuLeLEHXesQnyFg== X-Received: by 2002:a2e:a716:0:b0:2d2:e554:976 with SMTP id s22-20020a2ea716000000b002d2e5540976mr351159lje.14.1709135785839; Wed, 28 Feb 2024 07:56:25 -0800 (PST) Received: from rand-ubuntu-development.dl.local (mail.confident.ru. [85.114.29.218]) by smtp.gmail.com with ESMTPSA id e1-20020a2e8ec1000000b002d2d8d2ee45sm164863ljl.12.2024.02.28.07.56.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 07:56:25 -0800 (PST) From: Rand Deeb To: Jesse Brandeburg , Tony Nguyen , "David S . Miller" , Jakub Kicinski , intel-wired-lan@lists.osuosl.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: deeb.rand@confident.ru, lvc-project@linuxtesting.org, voskresenski.stanislav@confident.ru, Rand Deeb Subject: [PATCH] net: ice: Fix potential NULL pointer dereference in ice_bridge_setlink() Date: Wed, 28 Feb 2024 18:54:48 +0300 Message-Id: <20240228155448.121603-1-rand.sec96@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792158791144777608 X-GMAIL-MSGID: 1792158791144777608 The function ice_bridge_setlink() may encounter a NULL pointer dereference if nlmsg_find_attr() returns NULL and br_spec is dereferenced subsequently in nla_for_each_nested(). To address this issue, add a check to ensure that br_spec is not NULL before proceeding with the nested attribute iteration. Signed-off-by: Rand Deeb Reviewed-by: Simon Horman --- drivers/net/ethernet/intel/ice/ice_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c index 4f0d63fa5709..ba2bbd53d543 100644 --- a/drivers/net/ethernet/intel/ice/ice_main.c +++ b/drivers/net/ethernet/intel/ice/ice_main.c @@ -6530,6 +6530,8 @@ ice_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, pf_sw = pf->first_sw; /* find the attribute in the netlink message */ br_spec = nlmsg_find_attr(nlh, sizeof(struct ifinfomsg), IFLA_AF_SPEC); + if (!br_spec) + return -EINVAL; nla_for_each_nested(attr, br_spec, rem) { __u16 mode;