Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /* 32-bit compatibility syscall for 64-bit systems for DH operations
0003  *
0004  * Copyright (C) 2016 Stephan Mueller <smueller@chronox.de>
0005  */
0006 
0007 #include <linux/uaccess.h>
0008 
0009 #include "internal.h"
0010 
0011 /*
0012  * Perform the DH computation or DH based key derivation.
0013  *
0014  * If successful, 0 will be returned.
0015  */
0016 long compat_keyctl_dh_compute(struct keyctl_dh_params __user *params,
0017                   char __user *buffer, size_t buflen,
0018                   struct compat_keyctl_kdf_params __user *kdf)
0019 {
0020     struct keyctl_kdf_params kdfcopy;
0021     struct compat_keyctl_kdf_params compat_kdfcopy;
0022 
0023     if (!kdf)
0024         return __keyctl_dh_compute(params, buffer, buflen, NULL);
0025 
0026     if (copy_from_user(&compat_kdfcopy, kdf, sizeof(compat_kdfcopy)) != 0)
0027         return -EFAULT;
0028 
0029     kdfcopy.hashname = compat_ptr(compat_kdfcopy.hashname);
0030     kdfcopy.otherinfo = compat_ptr(compat_kdfcopy.otherinfo);
0031     kdfcopy.otherinfolen = compat_kdfcopy.otherinfolen;
0032     memcpy(kdfcopy.__spare, compat_kdfcopy.__spare,
0033            sizeof(kdfcopy.__spare));
0034 
0035     return __keyctl_dh_compute(params, buffer, buflen, &kdfcopy);
0036 }