MT#57093 introduce kernel module version check

Check all the struct sizes as part of the startup NOOP command, to try
to catch incompatible kernel module versions.

Change-Id: Ib617878e1e5a813de199c5405db3680c1e4d3351
pull/1642/head
Richard Fuchs 3 years ago
parent 5efbd6deab
commit 15863ba3dc

@ -75,7 +75,24 @@ static int kernel_open_table(unsigned int id) {
return -1; return -1;
cmd.cmd = REMG_NOOP; cmd.cmd = REMG_NOOP;
cmd.noop.last_cmd = __REMG_LAST;
cmd.noop = (struct rtpengine_noop_info) {
.last_cmd = __REMG_LAST,
.msg_size = {
[REMG_NOOP] = sizeof(struct rtpengine_command_noop),
[REMG_ADD_TARGET] = sizeof(struct rtpengine_command_add_target),
[REMG_DEL_TARGET] = sizeof(struct rtpengine_command_del_target),
[REMG_ADD_DESTINATION] = sizeof(struct rtpengine_command_destination),
[REMG_ADD_CALL] = sizeof(struct rtpengine_command_add_call),
[REMG_DEL_CALL] = sizeof(struct rtpengine_command_del_call),
[REMG_ADD_STREAM] = sizeof(struct rtpengine_command_add_stream),
[REMG_DEL_STREAM] = sizeof(struct rtpengine_command_del_stream),
[REMG_PACKET] = sizeof(struct rtpengine_command_packet),
[REMG_GET_STATS] = sizeof(struct rtpengine_command_stats),
[REMG_GET_RESET_STATS] = sizeof(struct rtpengine_command_stats),
},
};
i = write(fd, &cmd, sizeof(cmd)); i = write(fd, &cmd, sizeof(cmd));
if (i <= 0) if (i <= 0)
goto fail; goto fail;

@ -3550,6 +3550,7 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
enum rtpengine_command cmd; enum rtpengine_command cmd;
char scratchbuf[512]; char scratchbuf[512];
size_t readlen, writelen, writeoffset; size_t readlen, writelen, writeoffset;
int i;
union { union {
struct rtpengine_command_noop *noop; struct rtpengine_command_noop *noop;
@ -3625,6 +3626,9 @@ static inline ssize_t proc_control_read_write(struct file *file, char __user *ub
case REMG_NOOP: case REMG_NOOP:
if (msg.noop->noop.last_cmd != __REMG_LAST) if (msg.noop->noop.last_cmd != __REMG_LAST)
err = -ERANGE; err = -ERANGE;
for (i = 0; i < __REMG_LAST; i++)
if (msg.noop->noop.msg_size[i] != min_req_sizes[i])
err = -EMSGSIZE;
break; break;
case REMG_ADD_TARGET: case REMG_ADD_TARGET:

@ -174,10 +174,6 @@ struct rtpengine_stats_info {
struct rtpengine_ssrc_stats ssrc_stats[RTPE_NUM_SSRC_TRACKING]; struct rtpengine_ssrc_stats ssrc_stats[RTPE_NUM_SSRC_TRACKING];
}; };
struct rtpengine_noop_info {
int last_cmd;
};
enum rtpengine_command { enum rtpengine_command {
REMG_NOOP = 1, REMG_NOOP = 1,
REMG_ADD_TARGET, REMG_ADD_TARGET,
@ -194,6 +190,11 @@ enum rtpengine_command {
__REMG_LAST __REMG_LAST
}; };
struct rtpengine_noop_info {
int last_cmd;
size_t msg_size[__REMG_LAST];
};
struct rtpengine_command_noop { struct rtpengine_command_noop {
enum rtpengine_command cmd; enum rtpengine_command cmd;
struct rtpengine_noop_info noop; struct rtpengine_noop_info noop;

Loading…
Cancel
Save