@@ -1298,99 +1298,119 @@ static int zcrypt_requestq_count(void)
1298
1298
return requestq_count ;
1299
1299
}
1300
1300
1301
- static long zcrypt_unlocked_ioctl (struct file * filp , unsigned int cmd ,
1302
- unsigned long arg )
1301
+ static int icarsamodexpo_ioctl (struct ap_perms * perms , unsigned long arg )
1303
1302
{
1304
1303
int rc ;
1305
- struct ap_perms * perms =
1306
- ( struct ap_perms * ) filp -> private_data ;
1304
+ struct ica_rsa_modexpo mex ;
1305
+ struct ica_rsa_modexpo __user * umex = ( void __user * ) arg ;
1307
1306
1308
- rc = zcrypt_check_ioctl (perms , cmd );
1309
- if (rc )
1310
- return rc ;
1311
-
1312
- switch (cmd ) {
1313
- case ICARSAMODEXPO : {
1314
- struct ica_rsa_modexpo __user * umex = (void __user * ) arg ;
1315
- struct ica_rsa_modexpo mex ;
1316
-
1317
- if (copy_from_user (& mex , umex , sizeof (mex )))
1318
- return - EFAULT ;
1307
+ if (copy_from_user (& mex , umex , sizeof (mex )))
1308
+ return - EFAULT ;
1309
+ do {
1310
+ rc = zcrypt_rsa_modexpo (perms , & mex );
1311
+ } while (rc == - EAGAIN );
1312
+ /* on failure: retry once again after a requested rescan */
1313
+ if ((rc == - ENODEV ) && (zcrypt_process_rescan ()))
1319
1314
do {
1320
1315
rc = zcrypt_rsa_modexpo (perms , & mex );
1321
1316
} while (rc == - EAGAIN );
1322
- /* on failure: retry once again after a requested rescan */
1323
- if ((rc == - ENODEV ) && (zcrypt_process_rescan ()))
1324
- do {
1325
- rc = zcrypt_rsa_modexpo (perms , & mex );
1326
- } while (rc == - EAGAIN );
1327
- if (rc ) {
1328
- ZCRYPT_DBF (DBF_DEBUG , "ioctl ICARSAMODEXPO rc=%d\n" , rc );
1329
- return rc ;
1330
- }
1331
- return put_user (mex .outputdatalength , & umex -> outputdatalength );
1317
+ if (rc ) {
1318
+ ZCRYPT_DBF (DBF_DEBUG , "ioctl ICARSAMODEXPO rc=%d\n" , rc );
1319
+ return rc ;
1332
1320
}
1333
- case ICARSACRT : {
1334
- struct ica_rsa_modexpo_crt __user * ucrt = (void __user * ) arg ;
1335
- struct ica_rsa_modexpo_crt crt ;
1321
+ return put_user (mex .outputdatalength , & umex -> outputdatalength );
1322
+ }
1336
1323
1337
- if (copy_from_user (& crt , ucrt , sizeof (crt )))
1338
- return - EFAULT ;
1324
+ static int icarsacrt_ioctl (struct ap_perms * perms , unsigned long arg )
1325
+ {
1326
+ int rc ;
1327
+ struct ica_rsa_modexpo_crt crt ;
1328
+ struct ica_rsa_modexpo_crt __user * ucrt = (void __user * ) arg ;
1329
+
1330
+ if (copy_from_user (& crt , ucrt , sizeof (crt )))
1331
+ return - EFAULT ;
1332
+ do {
1333
+ rc = zcrypt_rsa_crt (perms , & crt );
1334
+ } while (rc == - EAGAIN );
1335
+ /* on failure: retry once again after a requested rescan */
1336
+ if ((rc == - ENODEV ) && (zcrypt_process_rescan ()))
1339
1337
do {
1340
1338
rc = zcrypt_rsa_crt (perms , & crt );
1341
1339
} while (rc == - EAGAIN );
1342
- /* on failure: retry once again after a requested rescan */
1343
- if ((rc == - ENODEV ) && (zcrypt_process_rescan ()))
1344
- do {
1345
- rc = zcrypt_rsa_crt (perms , & crt );
1346
- } while (rc == - EAGAIN );
1347
- if (rc ) {
1348
- ZCRYPT_DBF (DBF_DEBUG , "ioctl ICARSACRT rc=%d\n" , rc );
1349
- return rc ;
1350
- }
1351
- return put_user (crt .outputdatalength , & ucrt -> outputdatalength );
1340
+ if (rc ) {
1341
+ ZCRYPT_DBF (DBF_DEBUG , "ioctl ICARSACRT rc=%d\n" , rc );
1342
+ return rc ;
1352
1343
}
1353
- case ZSECSENDCPRB : {
1354
- struct ica_xcRB __user * uxcRB = (void __user * ) arg ;
1355
- struct ica_xcRB xcRB ;
1344
+ return put_user (crt .outputdatalength , & ucrt -> outputdatalength );
1345
+ }
1356
1346
1357
- if (copy_from_user (& xcRB , uxcRB , sizeof (xcRB )))
1358
- return - EFAULT ;
1347
+ static int zsecsendcprb_ioctl (struct ap_perms * perms , unsigned long arg )
1348
+ {
1349
+ int rc ;
1350
+ struct ica_xcRB xcRB ;
1351
+ struct ica_xcRB __user * uxcRB = (void __user * ) arg ;
1352
+
1353
+ if (copy_from_user (& xcRB , uxcRB , sizeof (xcRB )))
1354
+ return - EFAULT ;
1355
+ do {
1356
+ rc = _zcrypt_send_cprb (perms , & xcRB );
1357
+ } while (rc == - EAGAIN );
1358
+ /* on failure: retry once again after a requested rescan */
1359
+ if ((rc == - ENODEV ) && (zcrypt_process_rescan ()))
1359
1360
do {
1360
1361
rc = _zcrypt_send_cprb (perms , & xcRB );
1361
1362
} while (rc == - EAGAIN );
1362
- /* on failure: retry once again after a requested rescan */
1363
- if ((rc == - ENODEV ) && (zcrypt_process_rescan ()))
1364
- do {
1365
- rc = _zcrypt_send_cprb (perms , & xcRB );
1366
- } while (rc == - EAGAIN );
1367
- if (rc )
1368
- ZCRYPT_DBF (DBF_DEBUG , "ioctl ZSENDCPRB rc=%d status=0x%x\n" ,
1369
- rc , xcRB .status );
1370
- if (copy_to_user (uxcRB , & xcRB , sizeof (xcRB )))
1371
- return - EFAULT ;
1372
- return rc ;
1373
- }
1374
- case ZSENDEP11CPRB : {
1375
- struct ep11_urb __user * uxcrb = (void __user * )arg ;
1376
- struct ep11_urb xcrb ;
1363
+ if (rc )
1364
+ ZCRYPT_DBF (DBF_DEBUG , "ioctl ZSENDCPRB rc=%d status=0x%x\n" ,
1365
+ rc , xcRB .status );
1366
+ if (copy_to_user (uxcRB , & xcRB , sizeof (xcRB )))
1367
+ return - EFAULT ;
1368
+ return rc ;
1369
+ }
1377
1370
1378
- if (copy_from_user (& xcrb , uxcrb , sizeof (xcrb )))
1379
- return - EFAULT ;
1371
+ static int zsendep11cprb_ioctl (struct ap_perms * perms , unsigned long arg )
1372
+ {
1373
+ int rc ;
1374
+ struct ep11_urb xcrb ;
1375
+ struct ep11_urb __user * uxcrb = (void __user * )arg ;
1376
+
1377
+ if (copy_from_user (& xcrb , uxcrb , sizeof (xcrb )))
1378
+ return - EFAULT ;
1379
+ do {
1380
+ rc = _zcrypt_send_ep11_cprb (perms , & xcrb );
1381
+ } while (rc == - EAGAIN );
1382
+ /* on failure: retry once again after a requested rescan */
1383
+ if ((rc == - ENODEV ) && (zcrypt_process_rescan ()))
1380
1384
do {
1381
1385
rc = _zcrypt_send_ep11_cprb (perms , & xcrb );
1382
1386
} while (rc == - EAGAIN );
1383
- /* on failure: retry once again after a requested rescan */
1384
- if ((rc == - ENODEV ) && (zcrypt_process_rescan ()))
1385
- do {
1386
- rc = _zcrypt_send_ep11_cprb (perms , & xcrb );
1387
- } while (rc == - EAGAIN );
1388
- if (rc )
1389
- ZCRYPT_DBF (DBF_DEBUG , "ioctl ZSENDEP11CPRB rc=%d\n" , rc );
1390
- if (copy_to_user (uxcrb , & xcrb , sizeof (xcrb )))
1391
- return - EFAULT ;
1387
+ if (rc )
1388
+ ZCRYPT_DBF (DBF_DEBUG , "ioctl ZSENDEP11CPRB rc=%d\n" , rc );
1389
+ if (copy_to_user (uxcrb , & xcrb , sizeof (xcrb )))
1390
+ return - EFAULT ;
1391
+ return rc ;
1392
+ }
1393
+
1394
+ static long zcrypt_unlocked_ioctl (struct file * filp , unsigned int cmd ,
1395
+ unsigned long arg )
1396
+ {
1397
+ int rc ;
1398
+ struct ap_perms * perms =
1399
+ (struct ap_perms * ) filp -> private_data ;
1400
+
1401
+ rc = zcrypt_check_ioctl (perms , cmd );
1402
+ if (rc )
1392
1403
return rc ;
1393
- }
1404
+
1405
+ switch (cmd ) {
1406
+ case ICARSAMODEXPO :
1407
+ return icarsamodexpo_ioctl (perms , arg );
1408
+ case ICARSACRT :
1409
+ return icarsacrt_ioctl (perms , arg );
1410
+ case ZSECSENDCPRB :
1411
+ return zsecsendcprb_ioctl (perms , arg );
1412
+ case ZSENDEP11CPRB :
1413
+ return zsendep11cprb_ioctl (perms , arg );
1394
1414
case ZCRYPT_DEVICE_STATUS : {
1395
1415
struct zcrypt_device_status_ext * device_status ;
1396
1416
size_t total_size = MAX_ZDEV_ENTRIES_EXT
0 commit comments