Skip to content

Commit 544456b

Browse files
committed
Merge branch 'net-adopting-nlmsg_payload-final-series'
Breno Leitao says: ==================== net: Adopting nlmsg_payload() (final series) This patchset marks the final step in converting users to the new nlmsg_payload() function. It addresses the last two files that were not converted in previous series, specifically updating the following functions: neigh_valid_dump_req rtnl_valid_dump_ifinfo_req rtnl_valid_getlink_req valid_fdb_get_strict valid_bridge_getlink_req rtnl_valid_stats_req rtnl_mdb_valid_dump_req I would like to extend a big thank you to Kuniyuki Iwashima for his invaluable help and review of this effort. ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 199561a + a451930 commit 544456b

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

net/core/neighbour.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,12 +2747,12 @@ static int neigh_valid_dump_req(const struct nlmsghdr *nlh,
27472747
if (strict_check) {
27482748
struct ndmsg *ndm;
27492749

2750-
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ndm))) {
2750+
ndm = nlmsg_payload(nlh, sizeof(*ndm));
2751+
if (!ndm) {
27512752
NL_SET_ERR_MSG(extack, "Invalid header for neighbor dump request");
27522753
return -EINVAL;
27532754
}
27542755

2755-
ndm = nlmsg_data(nlh);
27562756
if (ndm->ndm_pad1 || ndm->ndm_pad2 || ndm->ndm_ifindex ||
27572757
ndm->ndm_state || ndm->ndm_type) {
27582758
NL_SET_ERR_MSG(extack, "Invalid values in header for neighbor dump request");

net/core/rtnetlink.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2390,12 +2390,12 @@ static int rtnl_valid_dump_ifinfo_req(const struct nlmsghdr *nlh,
23902390
if (strict_check) {
23912391
struct ifinfomsg *ifm;
23922392

2393-
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
2393+
ifm = nlmsg_payload(nlh, sizeof(*ifm));
2394+
if (!ifm) {
23942395
NL_SET_ERR_MSG(extack, "Invalid header for link dump");
23952396
return -EINVAL;
23962397
}
23972398

2398-
ifm = nlmsg_data(nlh);
23992399
if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
24002400
ifm->ifi_change) {
24012401
NL_SET_ERR_MSG(extack, "Invalid values in header for link dump request");
@@ -4084,7 +4084,8 @@ static int rtnl_valid_getlink_req(struct sk_buff *skb,
40844084
struct ifinfomsg *ifm;
40854085
int i, err;
40864086

4087-
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
4087+
ifm = nlmsg_payload(nlh, sizeof(*ifm));
4088+
if (!ifm) {
40884089
NL_SET_ERR_MSG(extack, "Invalid header for get link");
40894090
return -EINVAL;
40904091
}
@@ -4093,7 +4094,6 @@ static int rtnl_valid_getlink_req(struct sk_buff *skb,
40934094
return nlmsg_parse_deprecated(nlh, sizeof(*ifm), tb, IFLA_MAX,
40944095
ifla_policy, extack);
40954096

4096-
ifm = nlmsg_data(nlh);
40974097
if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
40984098
ifm->ifi_change) {
40994099
NL_SET_ERR_MSG(extack, "Invalid values in header for get link request");
@@ -5052,12 +5052,12 @@ static int valid_fdb_get_strict(const struct nlmsghdr *nlh,
50525052
struct ndmsg *ndm;
50535053
int err, i;
50545054

5055-
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ndm))) {
5055+
ndm = nlmsg_payload(nlh, sizeof(*ndm));
5056+
if (!ndm) {
50565057
NL_SET_ERR_MSG(extack, "Invalid header for fdb get request");
50575058
return -EINVAL;
50585059
}
50595060

5060-
ndm = nlmsg_data(nlh);
50615061
if (ndm->ndm_pad1 || ndm->ndm_pad2 || ndm->ndm_state ||
50625062
ndm->ndm_type) {
50635063
NL_SET_ERR_MSG(extack, "Invalid values in header for fdb get request");
@@ -5324,12 +5324,12 @@ static int valid_bridge_getlink_req(const struct nlmsghdr *nlh,
53245324
if (strict_check) {
53255325
struct ifinfomsg *ifm;
53265326

5327-
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifm))) {
5327+
ifm = nlmsg_payload(nlh, sizeof(*ifm));
5328+
if (!ifm) {
53285329
NL_SET_ERR_MSG(extack, "Invalid header for bridge link dump");
53295330
return -EINVAL;
53305331
}
53315332

5332-
ifm = nlmsg_data(nlh);
53335333
if (ifm->__ifi_pad || ifm->ifi_type || ifm->ifi_flags ||
53345334
ifm->ifi_change || ifm->ifi_index) {
53355335
NL_SET_ERR_MSG(extack, "Invalid values in header for bridge link dump request");
@@ -6221,16 +6221,15 @@ static int rtnl_valid_stats_req(const struct nlmsghdr *nlh, bool strict_check,
62216221
{
62226222
struct if_stats_msg *ifsm;
62236223

6224-
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*ifsm))) {
6224+
ifsm = nlmsg_payload(nlh, sizeof(*ifsm));
6225+
if (!ifsm) {
62256226
NL_SET_ERR_MSG(extack, "Invalid header for stats dump");
62266227
return -EINVAL;
62276228
}
62286229

62296230
if (!strict_check)
62306231
return 0;
62316232

6232-
ifsm = nlmsg_data(nlh);
6233-
62346233
/* only requests using strict checks can pass data to influence
62356234
* the dump. The legacy exception is filter_mask.
62366235
*/
@@ -6458,12 +6457,12 @@ static int rtnl_mdb_valid_dump_req(const struct nlmsghdr *nlh,
64586457
{
64596458
struct br_port_msg *bpm;
64606459

6461-
if (nlh->nlmsg_len < nlmsg_msg_size(sizeof(*bpm))) {
6460+
bpm = nlmsg_payload(nlh, sizeof(*bpm));
6461+
if (!bpm) {
64626462
NL_SET_ERR_MSG(extack, "Invalid header for mdb dump request");
64636463
return -EINVAL;
64646464
}
64656465

6466-
bpm = nlmsg_data(nlh);
64676466
if (bpm->ifindex) {
64686467
NL_SET_ERR_MSG(extack, "Filtering by device index is not supported for mdb dump request");
64696468
return -EINVAL;

0 commit comments

Comments
 (0)