Skip to content

devlink: do not dereference a missing param item or shared buffer

Linkui Xiao lkml netdev 2 versions – Applied

Status from this message: This series was applied to netdev/net-next.git (main)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest2 patches 3 repliesApplied 2/2
  2. v12 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- retargeted from net to net-next, as Simon suggested: with no in-tree caller able to reach either path this is hardening rather than a critical fix. No code change.
- collected Reviewed-by: Simon Horman on both patches.
- the Fixes: tags are kept so that stable can pick the commits up once they are in mainline.

Patches in v2 All 2 applied

#Subject and filesSizeRepliesApplied
1/2devlink: param: do not dereference a missing param itemnet/devlink/param.c+2 -11 replyApplied
2/2devlink: sb: do not dereference a missing shared buffernet/devlink/sb.c+2 -11 replyApplied

Reviews trailers per patch

All 2 patches have a Reviewed-by or Acked-by.

PatchSimon HormanIvan Vecera
1/2R-b R-b
2/2R-b R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v2 thread

Cover letter [PATCH net-next v2 0/2] devlink: do not dereference a missing param item or shared buffer

From: Linkui Xiao <[email protected]>

Two devlink helpers look an object up by id or index, warn when the lookup fails, and then pass the NULL result to code that dereferences it. A driver mistake (a param_id that was never registered, an sb_index that was never registered or is unregistered twice) therefore costs an oops instead of a warning.

1/2 param: devl_param_value_changed() hands the missing param item to

      devlink_param_notify() -> devlink_nl_param_fill(), whose first
      statement dereferences param_item->param.

2/2 sb: devl_sb_unregister() runs list_del() on the missing shared
buffer; list is the first member of struct devlink_sb, so it reads and writes through address 0.

In both cases every other user of the same lookup already returns right after the warning, so the fixes just align the remaining callers; there is no change of behavior beyond avoiding the dereference. The param side follows the example Jiri set for devlink_param_unregister():

Both Fixes: tags point at the commits that introduced the unguarded WARN_ON pattern; the current devl_() functions are pure renames of those originals. No in-tree caller triggers either path today (the audit is part of a defensive hardening pass), so both are aimed at stopping out-of-tree drivers from turning a driver bug into an oops.

v2:
- retargeted from net to net-next, as Simon suggested: with no in-tree caller able to reach either path this is hardening rather than a critical fix. No code change.
- collected Reviewed-by: Simon Horman on both patches.
- the Fixes: tags are kept so that stable can pick the commits up once they are in mainline.

Linkui Xiao (2):
devlink: param: do not dereference a missing param item
devlink: sb: do not dereference a missing shared buffer

 net/devlink/param.c | 3 ++-
 net/devlink/sb.c    | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)
Signature · 1 line
2.25.1