Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp436544rwe; Thu, 25 Aug 2022 03:13:04 -0700 (PDT) X-Google-Smtp-Source: AA6agR7+6ZsEawJJRGToCneYZ9m1TkQwgsz7o9/dDZlRQOSEwFB2W5gzal4Hleqy4nZ72aFaRSNM X-Received: by 2002:a17:90b:4a4b:b0:1fb:18e2:ffbc with SMTP id lb11-20020a17090b4a4b00b001fb18e2ffbcmr3854866pjb.96.1661422384206; Thu, 25 Aug 2022 03:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661422384; cv=none; d=google.com; s=arc-20160816; b=hVDxVCDieXanpsAlqNpKFtvfz0QAf/77MZxleTRk6syslQzsNyQ3grsjDOxuG3ejXS 8G6rJZbAr5F/E9bHsL8rBorMX0Vb4/Kx33DtKGccxD1nfFN22Nkh8lSxnBFLKirX9YEa kEOxYz6He/ZoINGRcvFmA2rCCDcC1ulqSUOCUDXeUV+UbPg+zCqq37nquoATDe9lwKAG l/Bvl9gmER+dRxLcujUxR9kJRAXagVGjpOwo/pK8SFvcoSWum94H8MuZKu8u7a0ZiG0+ 8D5ABsxCmBasYvSsQ0b40+QBjF+/7u4RzbBvmIznK/eJAXZo1avKo40TSFo2SWezwImP Eu+w== 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:cc :references:to:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=f93As8t+AUZuoeXw4IPmjspMtTl9iyRz8DSCXtau4WA=; b=fvdaU5Y3VtHQd5ip2xIlRQ8F5CwZvs7O7RSlJ2NfS5Qm5I7hXjWDVh2fQl9pr4/8xO bx/EX8ZAHoGlHDdZ77HcUEP9g2QlL7ZcI65hc/t2Kd3jtqnKwNeEOf1wHRORv96Yrlsb IRTojhDkz/P3OPA4OwM+4rd1nuJoxgP+8v8pfSNrEXM9rZcBUaN0LaqZpDKcL+0YEkGe 3bmiYKEyLYcFVn2SHxlnELc35o+WHEPyjMVo0JN72jFtXKH/XHm18ICvLFVf5Yv1GqT1 mBKsn2WAMIizbCMkAKeNEUUKh5yePnJv1n5SLY32idmEM3KVBniBeWzSnJciLgL4GI62 GS1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TXGsJNu2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h15-20020a170902f70f00b00172b87d9775si19200419plo.383.2022.08.25.03.12.52; Thu, 25 Aug 2022 03:13:04 -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=@redhat.com header.s=mimecast20190719 header.b=TXGsJNu2; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240425AbiHYJdM (ORCPT + 99 others); Thu, 25 Aug 2022 05:33:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240381AbiHYJdK (ORCPT ); Thu, 25 Aug 2022 05:33:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2418A1D7B for ; Thu, 25 Aug 2022 02:33:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661419983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f93As8t+AUZuoeXw4IPmjspMtTl9iyRz8DSCXtau4WA=; b=TXGsJNu25VAJKv6EpKJ0++AQMCX+LAAmQAMG58HGsajsJ+z7wNDC2ELAhLENMp4i7cSWf+ KKOYugp/6awE6IAbS1+k0/5CsbjVKFFb+Ad5qf9ObYPsMm1pH1ZMABdf1AdIUHXSKpI8i8 2Mk3zGqAXJ72SUo5K9CILxqCe7xMOU4= Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-644-QMc-4VkRMkmXoKB4MvejaA-1; Thu, 25 Aug 2022 05:33:01 -0400 X-MC-Unique: QMc-4VkRMkmXoKB4MvejaA-1 Received: by mail-qv1-f72.google.com with SMTP id dh19-20020ad458d3000000b00496bf7e4a72so10554711qvb.0 for ; Thu, 25 Aug 2022 02:33:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:cc:references:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc; bh=f93As8t+AUZuoeXw4IPmjspMtTl9iyRz8DSCXtau4WA=; b=x8P2CxUJrRnks20y2pNGTzxTjlgPVRFsnEPHuf083rw0LRMestOAaifLa6+rm1xxX9 7+S4swtvMpQoq9bN32u0pA6W3My5SY0slXK9TwTfQJla57ZgyFpF93aKGyG6Wi/vgh8h ER/3SS8DQADyOpConwk47zpe1l39ylVRM4pa7VOEVuJ9JdQC5BlnToecr64letBctY3W f5DdQg1nA5FoSZzS7Qpe0JblxKJC2TMSobfqeyrb+fKmudqZPYCJmdRUlXhvk15MYKkk czPMfTQVx3zcxRAD1Z3RkKJNfrsI1KdZIkrjDT9cz2U8WMCkF5z/jiHcAOwgFYuyV3tC Zylw== X-Gm-Message-State: ACgBeo1q0HAEr+tMKcDl08AQdrXcLRD0TanrytRkOHyXsnWbSx4nrdVV a3CIUPbSx44EPauztTPkGs5cYYzIbLkE+M0pai9Fk896sLXs6UPVQ+MnM9Q9kcWhlK993mpbcGz 4McsU3dx/mxgMVIe4obPZ7rFt X-Received: by 2002:a05:620a:f83:b0:6bb:ac26:e566 with SMTP id b3-20020a05620a0f8300b006bbac26e566mr2204231qkn.779.1661419981137; Thu, 25 Aug 2022 02:33:01 -0700 (PDT) X-Received: by 2002:a05:620a:f83:b0:6bb:ac26:e566 with SMTP id b3-20020a05620a0f8300b006bbac26e566mr2204217qkn.779.1661419980956; Thu, 25 Aug 2022 02:33:00 -0700 (PDT) Received: from [192.168.1.165] (cpc76484-cwma10-2-0-cust967.7-3.cable.virginm.net. [82.31.203.200]) by smtp.gmail.com with ESMTPSA id k8-20020ac80748000000b0031ee918e9f9sm13368029qth.39.2022.08.25.02.32.59 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 25 Aug 2022 02:33:00 -0700 (PDT) Message-ID: Date: Thu, 25 Aug 2022 10:32:58 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: [Cluster-devel] [PATCH] gfs2: move from strlcpy with unused retval to strscpy Content-Language: en-US To: Wolfram Sang References: <20220818210144.7915-1-wsa+renesas@sang-engineering.com> Cc: cluster-devel@redhat.com, linux-kernel@vger.kernel.org, Andreas Gruenbacher , Bob Peterson From: Andrew Price In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 24/08/2022 21:08, Wolfram Sang wrote: > Hi Andy. > >>> - strlcpy(sdp->sd_proto_name, proto, GFS2_FSNAME_LEN); >>> - strlcpy(sdp->sd_table_name, table, GFS2_FSNAME_LEN); >>> + strscpy(sdp->sd_proto_name, proto, GFS2_FSNAME_LEN); >>> + strscpy(sdp->sd_table_name, table, GFS2_FSNAME_LEN); >> >> Perhaps the size should be changed to GFS2_LOCKNAME_LEN to match the size of >> the destination, too. >> >> With that addition, this patch fixes this syzkaller report: >> >> https://listman.redhat.com/archives/cluster-devel/2022-August/022755.html > > Linus wrote another summary about strlcpy vs. strscpy use[1]. So, the > size argument should be the size of the smaller buffer if the buffers > are of different size. GFS2_LOCKNAME_LEN is smaller, so that looks > suitable. Shall I resend the patch with the suggested change? Yes, please. I can't speak for the gfs2 maintainers but I think it would be a good plan, as the combination of strscpy and the size change fixes a bug. Andy > > All the best, > > Wolfram > > [1] https://lore.kernel.org/lkml/CAHk-=wi+xbVq++uqW9YgWpHjyBHNB8a-xad+Xp23-B+eodLCEA@mail.gmail.com/ >