From nobody Tue Nov 11 00:23:46 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.47 as permitted sender) client-ip=209.51.188.47; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1559907452; cv=none; d=zoho.com; s=zohoarc; b=OWljn9AfMd2jVbPxhnr2aU/Aixh1tXe4PeOk02g9s2unCgNAxsp5hBdmI/WzaC/WWXEMG0yMiUKnQDhMaqLuyjEqJ63/2KCAv8LtPPfxkG5L+vdwuY+ONfCPnOq1RvirULdA6KQz7foa0gUduVXmFKSrlza8lsVraK/vmdlnK1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559907452; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=GIMeZ6bMRsF2R5xRdhq1mYff7LXEOP7cLVaV/15fAxw=; b=AeIX46ZmRV2CbYnihSy0XGyX+N6pNUaeAHOKjWIKrV6R/f853IcnwHIAeFY548DXr7dfnDp0bAG6qdpODJR8s2PA6sUr6O2jXRu2B5VOD6qGxZW/ubUb1HOEd73jfBHzxQlYnDljggUhDVkgr494L2bkdpb1PAT45xlQEUjmjmM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.47 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.47 [209.51.188.47]) by mx.zohomail.com with SMTPS id 1559907452188228.58524558958436; Fri, 7 Jun 2019 04:37:32 -0700 (PDT) Received: from localhost ([::1]:48706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZDBW-0006PS-1E for importer@patchew.org; Fri, 07 Jun 2019 07:37:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39917) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZCE2-000179-Pr for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hZCE0-00015n-Jr for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:57 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:41784 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hZCDx-0000VN-In for qemu-devel@nongnu.org; Fri, 07 Jun 2019 06:35:54 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 92A211A1D0E; Fri, 7 Jun 2019 12:35:47 +0200 (CEST) Received: from rtrkw774-lin.domain.local (rtrkw774-lin.domain.local [10.10.13.43]) by mail.rt-rk.com (Postfix) with ESMTPSA id 78BEB1A1D0B; Fri, 7 Jun 2019 12:35:47 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: Aleksandar Markovic To: qemu-devel@nongnu.org Date: Fri, 7 Jun 2019 12:35:18 +0200 Message-Id: <1559903719-7162-3-git-send-email-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1559903719-7162-1-git-send-email-aleksandar.markovic@rt-rk.com> References: <1559903719-7162-1-git-send-email-aleksandar.markovic@rt-rk.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v10 2/3] linux-user: Add support for setsockopt() option SOL_ALG X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Yunqiang Su , amarkovic@wavecomp.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Yunqiang Su Add support for options SOL_ALG of the syscall setsockopt(). This option is used in relation to Linux kernel Crypto API, and allows a user to set additional information for the cipher operation via syscall setsockopt(). The field "optname" must be one of the following: - ALG_SET_KEY =E2=80=93 seting the key - ALG_SET_AEAD_AUTHSIZE =E2=80=93 set the authentication tag size SOL_ALG is relatively newer setsockopt() option. Therefore, the code that handles SOL_ALG is enclosed in "ifdef" so that the build does not fail for older kernels that do not contain support for SOL_ALG. "ifdef" also contains check if ALG_SET_KEY and ALG_SET_AEAD_AUTHSIZE are defined. Signed-off-by: Yunqiang Su Signed-off-by: Aleksandar Markovic Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index dde6889..82c08b6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -103,6 +103,7 @@ #include #include #include +#include #include "linux_loop.h" #include "uname.h" =20 @@ -1998,6 +1999,36 @@ static abi_long do_setsockopt(int sockfd, int level,= int optname, goto unimplemented; } break; +#if defined(SOL_ALG) && defined(ALG_SET_KEY) && defined(ALG_SET_AEAD_AUTHS= IZE) + case SOL_ALG: + switch (optname) { + case ALG_SET_KEY: + { + char *alg_key =3D g_malloc(optlen); + + if (!alg_key) { + return -TARGET_ENOMEM; + } + if (copy_from_user(alg_key, optval_addr, optlen)) { + g_free(alg_key); + return -TARGET_EFAULT; + } + ret =3D get_errno(setsockopt(sockfd, level, optname, + alg_key, optlen)); + g_free(alg_key); + break; + } + case ALG_SET_AEAD_AUTHSIZE: + { + ret =3D get_errno(setsockopt(sockfd, level, optname, + NULL, optlen)); + break; + } + default: + goto unimplemented; + } + break; +#endif case TARGET_SOL_SOCKET: switch (optname) { case TARGET_SO_RCVTIMEO: --=20 2.7.4