Skip to content

Commit 7957c90

Browse files
can: fix CAN BCM build with CONFIG_PROC_FS disabled
jira VULN-36330 cve-prereq CVE-2023-52922 commit-author Oliver Hartkopp <[email protected]> commit c2701b3 upstream-diff This commit also has a dependency on 384317e ("can: network namespace support for CAN_BCM protocol") but that does not affect the CVE-2023-52922 and is therefore not necessary. The introduced namespace support moved the BCM variables for procfs into a per-net data structure. This leads to a build failure with disabled procfs: on x86_64: when CONFIG_PROC_FS is not enabled: ../net/can/bcm.c:1541:14: error: 'struct netns_can' has no member named 'bcmproc_dir' ../net/can/bcm.c:1601:14: error: 'struct netns_can' has no member named 'bcmproc_dir' ../net/can/bcm.c:1696:11: error: 'struct netns_can' has no member named 'bcmproc_dir' ../net/can/bcm.c:1707:15: error: 'struct netns_can' has no member named 'bcmproc_dir' http://marc.info/?l=linux-can&m=149321842526524&w=2 Reported-by: Randy Dunlap <[email protected]> Signed-off-by: Oliver Hartkopp <[email protected]> Signed-off-by: Marc Kleine-Budde <[email protected]> (cherry picked from commit c2701b3) Signed-off-by: Pratham Patel <[email protected]>
1 parent 05d9045 commit 7957c90

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

net/can/bcm.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ static inline struct bcm_sock *bcm_sk(const struct sock *sk)
140140
/*
141141
* procfs functions
142142
*/
143+
#if IS_ENABLED(CONFIG_PROC_FS)
143144
static char *bcm_proc_getifname(char *result, int ifindex)
144145
{
145146
struct net_device *dev;
@@ -236,6 +237,7 @@ static const struct file_operations bcm_proc_fops = {
236237
.llseek = seq_lseek,
237238
.release = single_release,
238239
};
240+
#endif /* CONFIG_PROC_FS */
239241

240242
/*
241243
* bcm_can_tx - send the (next) CAN frame to the appropriate CAN interface
@@ -1474,9 +1476,11 @@ static int bcm_release(struct socket *sock)
14741476
bcm_remove_op(op);
14751477
}
14761478

1479+
#if IS_ENABLED(CONFIG_PROC_FS)
14771480
/* remove procfs entry */
14781481
if (proc_dir && bo->bcm_proc_read)
14791482
remove_proc_entry(bo->procname, proc_dir);
1483+
#endif /* CONFIG_PROC_FS */
14801484

14811485
/* remove device reference */
14821486
if (bo->bound) {
@@ -1534,6 +1538,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
15341538
bo->ifindex = 0;
15351539
}
15361540

1541+
#if IS_ENABLED(CONFIG_PROC_FS)
15371542
if (proc_dir) {
15381543
/* unique socket address as filename */
15391544
sprintf(bo->procname, "%lu", sock_i_ino(sk));
@@ -1545,6 +1550,7 @@ static int bcm_connect(struct socket *sock, struct sockaddr *uaddr, int len,
15451550
goto fail;
15461551
}
15471552
}
1553+
#endif /* CONFIG_PROC_FS */
15481554

15491555
bo->bound = 1;
15501556

@@ -1636,17 +1642,21 @@ static int __init bcm_module_init(void)
16361642
return err;
16371643
}
16381644

1645+
#if IS_ENABLED(CONFIG_PROC_FS)
16391646
/* create /proc/net/can-bcm directory */
16401647
proc_dir = proc_mkdir("can-bcm", init_net.proc_net);
1648+
#endif /* CONFIG_PROC_FS */
16411649
return 0;
16421650
}
16431651

16441652
static void __exit bcm_module_exit(void)
16451653
{
16461654
can_proto_unregister(&bcm_can_proto);
16471655

1656+
#if IS_ENABLED(CONFIG_PROC_FS)
16481657
if (proc_dir)
16491658
remove_proc_entry("can-bcm", init_net.proc_net);
1659+
#endif /* CONFIG_PROC_FS */
16501660
}
16511661

16521662
module_init(bcm_module_init);

0 commit comments

Comments
 (0)