]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ksmbd: Constify struct ksmbd_transport_ops
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 23 Jun 2024 18:07:58 +0000 (20:07 +0200)
committerSteve French <stfrench@microsoft.com>
Sun, 14 Jul 2024 23:00:35 +0000 (18:00 -0500)
'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     hex filename
  52184    2085     256   54525    d4fd fs/smb/server/transport_rdma.o

After:
=====
   text    data     bss     dec     hex filename
  52260    2021     256   54537    d509 fs/smb/server/transport_rdma.o

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Acked-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/connection.h
fs/smb/server/transport_rdma.c
fs/smb/server/transport_tcp.c

index 0e04cf8b1d896ab346834b94dd912c53c86c2b0f..5c2845e47cf2df5f33bba86bfb3e88ae1917635f 100644 (file)
@@ -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)
index 8faa25c6e129b5ef7f38721ef398b942e56b0bc2..cf4418f7277267b0f7af1250e60248e81bcc552b 100644 (file)
@@ -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;
@@ -2292,7 +2292,7 @@ out:
        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,
index 6633fa78e9b96bbbcd323aced36dadc35c19850b..a84788396daaa46c685f8e3ec95e53619084ce39 100644 (file)
@@ -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);
@@ -649,7 +649,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,