From patchwork Thu Apr 6 08:16:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Herbert Xu X-Patchwork-Id: 747646 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3vzFt55byZz9s85 for ; Thu, 6 Apr 2017 18:16:45 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752836AbdDFIQn (ORCPT ); Thu, 6 Apr 2017 04:16:43 -0400 Received: from orcrist.hmeau.com ([104.223.48.154]:37964 "EHLO deadmen.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751475AbdDFIQd (ORCPT ); Thu, 6 Apr 2017 04:16:33 -0400 Received: from gondobar.mordor.me.apana.org.au ([192.168.128.4] helo=gondobar) by deadmen.hmeau.com with esmtp (Exim 4.84_2 #2 (Debian)) id 1cw2aR-00085L-Dq; Thu, 06 Apr 2017 16:16:11 +0800 Received: from herbert by gondobar with local (Exim 4.84_2) (envelope-from ) id 1cw2aP-00085S-Q4; Thu, 06 Apr 2017 16:16:09 +0800 Subject: [PATCH 2/4] crypto: af_alg - Allow arbitrarily long algorithm names References: <20170406081509.GB30557@gondor.apana.org.au> To: Alexander Sverdlin , "David S. Miller" , linux-crypto@vger.kernel.org, netdev@vger.kernel.org Message-Id: From: Herbert Xu Date: Thu, 06 Apr 2017 16:16:09 +0800 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This patch removes the hard-coded 64-byte limit on the length of the algorithm name through bind(2). The address length can now exceed that. The user-space structure remains unchanged. In order to use a longer name simply extend the salg_name array beyond its defined 64 bytes length. Signed-off-by: Herbert Xu --- crypto/af_alg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 690deca..3556d8e 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c @@ -160,11 +160,11 @@ static int alg_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len) if (sock->state == SS_CONNECTED) return -EINVAL; - if (addr_len != sizeof(*sa)) + if (addr_len < sizeof(*sa)) return -EINVAL; sa->salg_type[sizeof(sa->salg_type) - 1] = 0; - sa->salg_name[sizeof(sa->salg_name) - 1] = 0; + sa->salg_name[sizeof(sa->salg_name) + addr_len - sizeof(*sa) - 1] = 0; type = alg_get_type(sa->salg_type); if (IS_ERR(type) && PTR_ERR(type) == -ENOENT) {