Registration of dumpers */
| 1187 | |
| 1188 | /* Registration of dumpers */ |
| 1189 | int |
| 1190 | dumper_insert(const struct dumperinfo *di_template, const char *devname, |
| 1191 | const struct diocskerneldump_arg *kda) |
| 1192 | { |
| 1193 | struct dumperinfo *newdi, *listdi; |
| 1194 | bool inserted; |
| 1195 | uint8_t index; |
| 1196 | int error; |
| 1197 | |
| 1198 | index = kda->kda_index; |
| 1199 | MPASS(index != KDA_REMOVE && index != KDA_REMOVE_DEV && |
| 1200 | index != KDA_REMOVE_ALL); |
| 1201 | |
| 1202 | error = priv_check(curthread, PRIV_SETDUMPER); |
| 1203 | if (error != 0) |
| 1204 | return (error); |
| 1205 | |
| 1206 | newdi = malloc(sizeof(*newdi) + strlen(devname) + 1, M_DUMPER, M_WAITOK |
| 1207 | | M_ZERO); |
| 1208 | memcpy(newdi, di_template, sizeof(*newdi)); |
| 1209 | newdi->blockbuf = NULL; |
| 1210 | newdi->kdcrypto = NULL; |
| 1211 | newdi->kdcomp = NULL; |
| 1212 | strcpy(newdi->di_devname, devname); |
| 1213 | |
| 1214 | if (kda->kda_encryption != KERNELDUMP_ENC_NONE) { |
| 1215 | #ifdef EKCD |
| 1216 | newdi->kdcrypto = kerneldumpcrypto_create(di_template->blocksize, |
| 1217 | kda->kda_encryption, kda->kda_key, |
| 1218 | kda->kda_encryptedkeysize, kda->kda_encryptedkey); |
| 1219 | if (newdi->kdcrypto == NULL) { |
| 1220 | error = EINVAL; |
| 1221 | goto cleanup; |
| 1222 | } |
| 1223 | #else |
| 1224 | error = EOPNOTSUPP; |
| 1225 | goto cleanup; |
| 1226 | #endif |
| 1227 | } |
| 1228 | if (kda->kda_compression != KERNELDUMP_COMP_NONE) { |
| 1229 | #ifdef EKCD |
| 1230 | /* |
| 1231 | * We can't support simultaneous unpadded block cipher |
| 1232 | * encryption and compression because there is no guarantee the |
| 1233 | * length of the compressed result is exactly a multiple of the |
| 1234 | * cipher block size. |
| 1235 | */ |
| 1236 | if (kda->kda_encryption == KERNELDUMP_ENC_AES_256_CBC) { |
| 1237 | error = EOPNOTSUPP; |
| 1238 | goto cleanup; |
| 1239 | } |
| 1240 | #endif |
| 1241 | newdi->kdcomp = kerneldumpcomp_create(newdi, |
| 1242 | kda->kda_compression); |
| 1243 | if (newdi->kdcomp == NULL) { |
| 1244 | error = EINVAL; |
| 1245 | goto cleanup; |
| 1246 | } |
no test coverage detected