From patchwork Sat Feb 17 00:17:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13561100 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE4654C8F for ; Sat, 17 Feb 2024 00:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708129069; cv=none; b=rEtHFScFH/E2x0qXEtkR0ftX4O4ZTYHWj4rkCUwKvIvu7zatkMqhDOPgKEB6uQWo9ioxpf9ssjWzOO5pDEkBfMao2/yVGtfilmtUcuBahXXlMKfBGcrs4tM3CayMf1/jsnPavywzrvF1sgvisg3XnZQc7rLgRQEKPj4J2OxcwyE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708129069; c=relaxed/simple; bh=a7YHHQSj9YCCeh/jBrdS4CXQwN6TNph0vPkHrSTG33g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=btLMAtUYyaE+YjpCG4vgtJi76BXHazNlW1eNyz3VlducNs6/M3oLPvRzb+H65NcF0INQTLFemo2cy7/a6SRCY8+L/TciDgOQ4Tg7e2tcY/Vj90zRwmFtBCgJHTjiPi6TPYAhoEdEeGeTM5XByEoNW0NtxEZOB9eU3umpdeO62pw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XgRYTOEk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XgRYTOEk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 19CCFC433C7; Sat, 17 Feb 2024 00:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708129069; bh=a7YHHQSj9YCCeh/jBrdS4CXQwN6TNph0vPkHrSTG33g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XgRYTOEkU5yaX5s0+JRNiv4wXeEYTDPb/6E8fZOKOJrRY0UrRp9KNppgCvrolicI9 oLuvm0+l/Pipoq46rVY9Z5USnvxl5vOgoH8bTpHr5FVeK0pIxjdiJH7Exjj3UKcWaK IrN1zwWw4H5uiHjB0nB3B5IG/PukhWDLHizVOi8ouDzCKlEoZgm1eiQyVcGAGCZooC 5Vf3O3G4XcD7IGkrKngFf3B32fSAT1sEB0Erp5j2jyIImbCpHtgZaYetvVX0YCnr3e g1vNDGewdQDujDMNdb7ts0leiDR7uEcrJdlc1UALSzTIXK8oxP8IGPzHBz/FKLiBWh yYufKqdlKr1gQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, chuck.lever@oracle.com, jiri@resnulli.us, nicolas.dichtel@6wind.com, willemb@google.com, Jakub Kicinski Subject: [PATCH net 1/3] tools: ynl: fix header guards Date: Fri, 16 Feb 2024 16:17:40 -0800 Message-ID: <20240217001742.2466993-2-kuba@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217001742.2466993-1-kuba@kernel.org> References: <20240217001742.2466993-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org devlink and ethtool have a trailing _ in the header guard. I must have copy/pasted it into new guards, assuming it's a headers_install artifact. Fixes: 8f109e91b852 ("tools: ynl: include dpll and mptcp_pm in C codegen") Signed-off-by: Jakub Kicinski Acked-by: Nicolas Dichtel --- CC: chuck.lever@oracle.com CC: jiri@resnulli.us --- tools/net/ynl/Makefile.deps | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/net/ynl/Makefile.deps b/tools/net/ynl/Makefile.deps index e6154a1255f8..7dcec16da509 100644 --- a/tools/net/ynl/Makefile.deps +++ b/tools/net/ynl/Makefile.deps @@ -15,9 +15,9 @@ UAPI_PATH:=../../../../include/uapi/ get_hdr_inc=-D$(1) -include $(UAPI_PATH)/linux/$(2) CFLAGS_devlink:=$(call get_hdr_inc,_LINUX_DEVLINK_H_,devlink.h) -CFLAGS_dpll:=$(call get_hdr_inc,_LINUX_DPLL_H_,dpll.h) +CFLAGS_dpll:=$(call get_hdr_inc,_LINUX_DPLL_H,dpll.h) CFLAGS_ethtool:=$(call get_hdr_inc,_LINUX_ETHTOOL_NETLINK_H_,ethtool_netlink.h) CFLAGS_handshake:=$(call get_hdr_inc,_LINUX_HANDSHAKE_H,handshake.h) -CFLAGS_mptcp_pm:=$(call get_hdr_inc,_LINUX_MPTCP_PM_H_,mptcp_pm.h) +CFLAGS_mptcp_pm:=$(call get_hdr_inc,_LINUX_MPTCP_PM_H,mptcp_pm.h) CFLAGS_netdev:=$(call get_hdr_inc,_LINUX_NETDEV_H,netdev.h) CFLAGS_nfsd:=$(call get_hdr_inc,_LINUX_NFSD_NETLINK_H,nfsd_netlink.h) From patchwork Sat Feb 17 00:17:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13561101 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 45CFB1DFF2 for ; Sat, 17 Feb 2024 00:17:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708129070; cv=none; b=E2L9VKEiw8q/vD4EP5H9eeDDigYIaFNNiBDqSyc4Oi1UK5JMVa1ZKTZKKEq2fvVb6eGmzrpgTl1vQ9M4uhXryufoWP/rt1FWVNb/CPdSugE0gtaigxcbB5hVY7fKHwGkcRSXZEkUTqa/z0n7P4JDOBSbkeD3NhpziO2KgwdZBsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708129070; c=relaxed/simple; bh=BTtw9uM80+4mv3TNU1ObrLhkA/O2teSNcOXB/xkRzIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z2qQBzjzBfOZWDNMHQ/eRQ9oupGyOIdYzC2ALOS9XYAd/ZUKjO8M1goYJ903KLso09IaYvSjjGY6YMDvd0vf5D1tMuhxtmSf8MDKXkfiRcCGhCWTJEeBsA3J6uz5gtx+SEyuVNQkWfZS6gsakeI5wFUTaBXOTdcqLzcsc52gLBU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CxZtIQ9/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CxZtIQ9/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 82436C43399; Sat, 17 Feb 2024 00:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708129069; bh=BTtw9uM80+4mv3TNU1ObrLhkA/O2teSNcOXB/xkRzIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CxZtIQ9/+yNJK0xQdYqIiqd5OoAwoNdaVZvkxUuj5Y1i7wP2CheQOFOrL2mDLf6Aj 16J/Sc1C0OcbtsiKhy+JXjKodwAnhnaIiiFCGIzUWrCZ5EL/ty8gnsVsC7ix2q/CfS UjyMT1jpEHwPDQ2f/1oT3YNf88jeydUpYzFimJSRzpTRblXnr8RK9Rllk1it1JavWg /KS3X/uCK/+lYkUmfNnKBXz7zpNEQeH4r7hkBGn7edVpcV4yqHgEQbQM4Ikd1R5Ps9 Iz159H2xesau/f/RyV/usM81JqG+9/3f3LPMOf9NORo8HpVCdAT1LLEupN49LTWBMY uhFQ6NPVfCNmw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, chuck.lever@oracle.com, jiri@resnulli.us, nicolas.dichtel@6wind.com, willemb@google.com, Jakub Kicinski Subject: [PATCH net 2/3] tools: ynl: make sure we always pass yarg to mnl_cb_run Date: Fri, 16 Feb 2024 16:17:41 -0800 Message-ID: <20240217001742.2466993-3-kuba@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217001742.2466993-1-kuba@kernel.org> References: <20240217001742.2466993-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org There is one common error handler in ynl - ynl_cb_error(). It expects priv to be a pointer to struct ynl_parse_arg AKA yarg. To avoid potential crashes if we encounter a stray NLMSG_ERROR always pass yarg as priv (or a struct which has it as the first member). ynl_cb_null() has a similar problem directly - it expects yarg but priv passed by the caller is ys. Found by code inspection. Fixes: 86878f14d71a ("tools: ynl: user space helpers") Signed-off-by: Jakub Kicinski Acked-by: Nicolas Dichtel --- Further cleanup to enforce the types in net-next.. --- CC: nicolas.dichtel@6wind.com CC: willemb@google.com --- tools/net/ynl/lib/ynl.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tools/net/ynl/lib/ynl.c b/tools/net/ynl/lib/ynl.c index c82a7f41b31c..9e41c8c0cc99 100644 --- a/tools/net/ynl/lib/ynl.c +++ b/tools/net/ynl/lib/ynl.c @@ -466,6 +466,8 @@ ynl_gemsg_start_dump(struct ynl_sock *ys, __u32 id, __u8 cmd, __u8 version) int ynl_recv_ack(struct ynl_sock *ys, int ret) { + struct ynl_parse_arg yarg = { .ys = ys, }; + if (!ret) { yerr(ys, YNL_ERROR_EXPECT_ACK, "Expecting an ACK but nothing received"); @@ -478,7 +480,7 @@ int ynl_recv_ack(struct ynl_sock *ys, int ret) return ret; } return mnl_cb_run(ys->rx_buf, ret, ys->seq, ys->portid, - ynl_cb_null, ys); + ynl_cb_null, &yarg); } int ynl_cb_null(const struct nlmsghdr *nlh, void *data) @@ -741,11 +743,14 @@ static int ynl_ntf_parse(struct ynl_sock *ys, const struct nlmsghdr *nlh) static int ynl_ntf_trampoline(const struct nlmsghdr *nlh, void *data) { - return ynl_ntf_parse((struct ynl_sock *)data, nlh); + struct ynl_parse_arg *yarg = data; + + return ynl_ntf_parse(yarg->ys, nlh); } int ynl_ntf_check(struct ynl_sock *ys) { + struct ynl_parse_arg yarg = { .ys = ys, }; ssize_t len; int err; @@ -767,7 +772,7 @@ int ynl_ntf_check(struct ynl_sock *ys) return len; err = mnl_cb_run2(ys->rx_buf, len, ys->seq, ys->portid, - ynl_ntf_trampoline, ys, + ynl_ntf_trampoline, &yarg, ynl_cb_array, NLMSG_MIN_TYPE); if (err < 0) return err; From patchwork Sat Feb 17 00:17:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 13561102 X-Patchwork-Delegate: kuba@kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C2D891E898 for ; Sat, 17 Feb 2024 00:17:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708129070; cv=none; b=pN9L85BwYwM2VTGZGDwsIIa0mvJfp5VcGGP2mkptjFQaJXPNoBHQKsCvTMvg90RXQrSP1uiQVza1JrWG5+lTUrE6KwUG/KpIYvMCPAvds91OUijZUyWNPPReiUqlzTzvSiwBLUBf8A7MPlXt6SgMJRlbyzG0jarrtA+98UkQ3QM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708129070; c=relaxed/simple; bh=zv+JkjbVFI8WBMprrN/D+pF5xWCIhj3B1Sq7vqYrFsA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tyxwZ0P6hkVmi2JSjXjORuclNcoKS7HvOEOR5STUH/mCyxJrNYvzm97WgM2TQ9rfrwLKP8l+BY4WBVWmeu4itwwTzd50/XAM4DlNvjkKBgBqan2lkD+bvsUMO08lya3lvuaCH9+d7pex8UVmOoafkDgsYvF9jyDYhjw4ETesOok= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QqlV2xOO; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QqlV2xOO" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEBAEC433A6; Sat, 17 Feb 2024 00:17:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708129070; bh=zv+JkjbVFI8WBMprrN/D+pF5xWCIhj3B1Sq7vqYrFsA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QqlV2xOOXax/PGdWOZnRpAD+tHLbQUoVskgQ4EfReqAvYuym/QTtcH6hFQ63yxWH+ FN4mMXkO3wx1NFpoLgJ3MHq8X3puOzZB9EeXnUEUnJMI3KYwF6jCqc8bpAOUv0SD/i wC/YkCBY6XoVpSlnV6cUFx/QKBrubD7uWk1KHvXyqEsUGQNzDiNYGHTFcRIKc6JvLq d6BJ5+SciuC3qNhnigz8BdfQepABDEBPY3URhCImfiytdxk8oMGfXqkgg/XCWJ4omc N2JOzi91qbCAdcQ/kSTX5XGCDoZSaT8a7Cy2o+1xCviOqoj/8mvWPAfahN3kObHCxs 9Py1Lc3wL2Kkw== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, chuck.lever@oracle.com, jiri@resnulli.us, nicolas.dichtel@6wind.com, willemb@google.com, Jakub Kicinski Subject: [PATCH net 3/3] tools: ynl: don't leak mcast_groups on init error Date: Fri, 16 Feb 2024 16:17:42 -0800 Message-ID: <20240217001742.2466993-4-kuba@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217001742.2466993-1-kuba@kernel.org> References: <20240217001742.2466993-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org Make sure to free the already-parsed mcast_groups if we don't get an ack from the kernel when reading family info. This is part of the ynl_sock_create() error path, so we won't get a call to ynl_sock_destroy() to free them later. Fixes: 86878f14d71a ("tools: ynl: user space helpers") Signed-off-by: Jakub Kicinski Acked-by: Nicolas Dichtel --- CC: nicolas.dichtel@6wind.com CC: willemb@google.com --- tools/net/ynl/lib/ynl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/net/ynl/lib/ynl.c b/tools/net/ynl/lib/ynl.c index 9e41c8c0cc99..6e6d474c8366 100644 --- a/tools/net/ynl/lib/ynl.c +++ b/tools/net/ynl/lib/ynl.c @@ -588,7 +588,13 @@ static int ynl_sock_read_family(struct ynl_sock *ys, const char *family_name) return err; } - return ynl_recv_ack(ys, err); + err = ynl_recv_ack(ys, err); + if (err < 0) { + free(ys->mcast_groups); + return err; + } + + return 0; } struct ynl_sock *