Skip to content

Commit

Permalink
ksmbd: Constify struct ksmbd_transport_ops
Browse files Browse the repository at this point in the history
'struct ksmbd_transport_ops' is not modified in these drivers.

Constifying this structure moves some data to a read-only section, so
increase overall security.

On a x86_64, with allmodconfig, as an example:
Before:
======
   text   data    bss    dec    hexfilename
  52184   2085    256  54525   d4fdfs/smb/server/transport_rdma.o

After:
=====
   text   data    bss    dec    hexfilename
  52260   2021    256  54537   d509fs/smb/server/transport_rdma.o

Signed-off-by: Christophe JAILLET <[email protected]>
Signed-off-by: Namjae Jeon <[email protected]>
  • Loading branch information
tititiou36 authored and namjaejeon committed Jul 27, 2024
1 parent c1bf237 commit c7019fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions connection.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ struct ksmbd_transport_ops {
};

struct ksmbd_transport {
struct ksmbd_conn *conn;
struct ksmbd_transport_ops *ops;
struct ksmbd_conn *conn;
const struct ksmbd_transport_ops *ops;
};

#define KSMBD_TCP_RECV_TIMEOUT (7 * HZ)
Expand Down
4 changes: 2 additions & 2 deletions transport_rdma.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ enum {
SMB_DIRECT_MSG_DATA_TRANSFER
};

static struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops;
static const struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops;

struct smb_direct_send_ctx {
struct list_head msg_list;
Expand Down Expand Up @@ -2313,7 +2313,7 @@ bool ksmbd_rdma_capable_netdev(struct net_device *netdev)
return rdma_capable;
}

static struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops = {
static const struct ksmbd_transport_ops ksmbd_smb_direct_transport_ops = {
.prepare = smb_direct_prepare,
.disconnect = smb_direct_disconnect,
.shutdown = smb_direct_shutdown,
Expand Down
4 changes: 2 additions & 2 deletions transport_tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct tcp_transport {
unsigned int nr_iov;
};

static struct ksmbd_transport_ops ksmbd_tcp_transport_ops;
static const struct ksmbd_transport_ops ksmbd_tcp_transport_ops;

static void tcp_stop_kthread(struct task_struct *kthread);
static struct interface *alloc_iface(char *ifname);
Expand Down Expand Up @@ -689,7 +689,7 @@ int ksmbd_tcp_set_interfaces(char *ifc_list, int ifc_list_sz)
return 0;
}

static struct ksmbd_transport_ops ksmbd_tcp_transport_ops = {
static const struct ksmbd_transport_ops ksmbd_tcp_transport_ops = {
.read = ksmbd_tcp_read,
.writev = ksmbd_tcp_writev,
.disconnect = ksmbd_tcp_disconnect,
Expand Down

0 comments on commit c7019fc

Please sign in to comment.