Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp1709862iof; Tue, 7 Jun 2022 10:07:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPleXDZyCXKMbDmw7isXRDqTHBam4W1a+sU91iPiPzgK4VrTSV5HA/AvWr1qXCI+JbFgoI X-Received: by 2002:a17:90a:e7c8:b0:1e6:92fe:84c2 with SMTP id kb8-20020a17090ae7c800b001e692fe84c2mr30120495pjb.194.1654621628832; Tue, 07 Jun 2022 10:07:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654621628; cv=none; d=google.com; s=arc-20160816; b=mIwY2RWq+nHwBZVH9lZLPk3MRERapsLGeRgOI4UjT14F6+VVDHo2hWix2VTfsTNS87 MJsNk0a4Hnmd8kRsM+HmGU7Qff6QQv3TXkS6QwLgBV8Q6ZRt3Bfzczz+SuUYfENyiMAB vF5KrYxPHVco1ADpTxGTH0EIEk2+LHLf6cAqCcUCUhKDLEewYzgiEaBxG4Lvb6aFVegc LwRVzzGJm46diHBPhFsbUJrtPxeJLysN/xuLIIA00PWs+GQD0Evl+l82E1U2K47xOR81 7V3+wI+PhZm4kwlLobpHtBCX41tCl5G5LP2XjebXPVi2Y6Zr0RpNADmEL3YT9/dbGulI J6uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=6s4jE9Us7GnHwrpBrWS9Yqnb+8P+jFhc0q4ZyDkLpeY=; b=QkiYB0tWAJ9oBje0a7/Em6Jx2AVSIBk7FfaDYutWRVjPaIAzgDz2IDvKNdPkP09Dxt tV1kVC2Vlmp1Colu+n3oPliYpGlq0C3dFUAQGQoB4uz4OlkHzgR/HBAlTIKOG2J48IEe GZRmF60K+kP4EUMNZTCsEo3w0qi+WF+QzXdLOgYymllTWWHO4lR34b8oH5H3bNdAV4LP 3EsXOWNxJze6VTg73mTgodS+Av2F5E2fpywMCAVW+t90FSPvC26Xwy8vQ6qCxPb7Pe8r QMZUArynFNFnApB+2G66pZ8NCWP7TUSPjZMDtUOQeqX/FoVEG76A3T7UrCLBUN9r4Iz4 hpjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=NyryMpuF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s13-20020a63770d000000b003facc630945si20911346pgc.135.2022.06.07.10.06.49; Tue, 07 Jun 2022 10:07:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@yahoo.com header.s=s2048 header.b=NyryMpuF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244898AbiFGNsI (ORCPT + 99 others); Tue, 7 Jun 2022 09:48:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244947AbiFGNsB (ORCPT ); Tue, 7 Jun 2022 09:48:01 -0400 Received: from sonic315-26.consmr.mail.ne1.yahoo.com (sonic315-26.consmr.mail.ne1.yahoo.com [66.163.190.152]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CD886D4CC for ; Tue, 7 Jun 2022 06:47:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1654609678; bh=6s4jE9Us7GnHwrpBrWS9Yqnb+8P+jFhc0q4ZyDkLpeY=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From:Subject:Reply-To; b=NyryMpuFEo36JionPvzycdY9oz7T8Kel6gnO/JrelYygrupa406a42PvUToXkwDMfYJibiWIB3xA+pIbQ5pD8z07RmX3eDCSrdBHSCQ0D3pIL8cxwWR5q0HL4Nx9xADSDegdUYmpXo8Bs+54Q7KpzvdHpzaFSnFi7ojPzKZh11rrYpKrc52WwA5ZWXPciq3LNvH0O0yLtBt9x+HCwXpcJGq+r7FB5OJYWfKTm8Ira3He7T/1VEne5JlIuIybWGEi1txfU+sRlxIl6q7u7AlR4cM6hvPgb6qkdT3nEnbBEg9hMNjbdszQi/f9mUS/uuuHWxGzs1uGmS+Rrjukx4boYg== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1654609678; bh=t3X/JWW7gOF5nEJkuMgrOPAOcuJbIp1+MyTWlE/cS9b=; h=X-Sonic-MF:Date:Subject:To:From:From:Subject; b=CnGGL1S3exrAcgBjtDkx0AAH9aJcuFYyTIjlpkBj5alBnb/8ImXEzHlGcncvT1gFjO60KjMu61/RmiX3SPe0lVlMY8M+kEPw73KKaK7ZUef6ljtMmlM/fkGQskJOLwYuQbKuCtq0KJqkKtyhhTg7PAiVxgJ8jb0o5AB/B7Yuta5KxKWYZ904U/oQOJGGANo0xjJCQqZkVNA47mRn7T4/B/yOW262EvN1uOyv2O5zDUP0AbgyciVfOVbnaPPduJJ387Qyq1NDz3NY6n913KO692aVyVWEDP3RAljeeakalvsWXt3aIMGP89XPyoKkiswAumSZ0NewerzwNoAkwzJQ7A== X-YMail-OSG: dy4q_igVM1kQhDMVg1Xsv7sgHiS7D9iJm0cy_Y0sPTAmb9x5iVvmPFvqZqVY1bg FU39p4Ct5NZmjnSFbKK5QzxYfPxIubeqbnf8yNT6IWglHEI9r0ahjCORFzouoWZrDuoi98aFUH_e bT8L3UU3Bsi1raB9jwBtwYJJiA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MF: Received: from sonic.gate.mail.ne1.yahoo.com by sonic315.consmr.mail.ne1.yahoo.com with HTTP; Tue, 7 Jun 2022 13:47:58 +0000 Received: by hermes--canary-production-gq1-54945cc758-xfztc (Yahoo Inc. Hermes SMTP Server) with ESMTPA ID 19237ea258b8c46024bfa18b3f1d8502; Tue, 07 Jun 2022 13:47:53 +0000 (UTC) Message-ID: <8c451435-4609-55a6-e92a-ac325690234b@schaufler-ca.com> Date: Tue, 7 Jun 2022 06:47:53 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH] smack: Replace kzalloc + strncpy with kstrndup Content-Language: en-US To: "GONG, Ruiqi" , James Morris , Serge E Hallyn Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Wang Weiyang , Xiu Jianfeng , GONG Ruiqi , Casey Schaufler References: From: Casey Schaufler In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailer: WebService/1.1.20280 mail.backend.jedi.jws.acl:role.jedi.acl.token.atz.jws.hermes.yahoo X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/6/2022 1:17 AM, GONG, Ruiqi wrote: > From: "GONG, Ruiqi" > > Simplify the code by using kstrndup instead of kzalloc and strncpy in > smk_parse_smack(), which meanwhile remove strncpy as [1] suggests. > > [1]: https://github.com/KSPP/linux/issues/90 > > Signed-off-by: GONG, Ruiqi Thank you. I will take this for the Smack tree. > --- > security/smack/smack_access.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/security/smack/smack_access.c b/security/smack/smack_access.c > index d2186e2757be..585e5e35710b 100644 > --- a/security/smack/smack_access.c > +++ b/security/smack/smack_access.c > @@ -465,12 +465,9 @@ char *smk_parse_smack(const char *string, int len) > if (i == 0 || i >= SMK_LONGLABEL) > return ERR_PTR(-EINVAL); > > - smack = kzalloc(i + 1, GFP_NOFS); > - if (smack == NULL) > + smack = kstrndup(string, i, GFP_NOFS); > + if (!smack) > return ERR_PTR(-ENOMEM); > - > - strncpy(smack, string, i); > - > return smack; > } >