Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp371142rwe; Fri, 26 Aug 2022 06:38:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR6QtaN6DDDvxl6rJBIzlKGivSGpkxN9waStzgPYNcrH8dGDvFuAw+j4Lv6sNzg5Ao6wlQPq X-Received: by 2002:a17:90a:4496:b0:1fa:bbb5:7000 with SMTP id t22-20020a17090a449600b001fabbb57000mr4515353pjg.218.1661521107479; Fri, 26 Aug 2022 06:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661521107; cv=none; d=google.com; s=arc-20160816; b=h7Y+QC8EzmXeaW/4Pgj+Q96TBmpD8htsrwPfFR4c6oT7NdLIhp2f4YkD0Ou0Cdvy/C 0Eu/n03xaTQSIAfDM63GhO0vTZUzwY9zoQkuGwO64BSwU/p45d9zWiT9FJH3M26gPvEy ocTKoa/EOeJbyp+cQmtq+FRTIyY5x+DI0IX9L8EIi0SnoELm5WU+hmtgGcWRDaH2/oab BJ4ackYv2haKucsYD71HYLyhxiVtd/OnHSy/z02WWFWyBmg5RLs33tSn5klKN6n71VYl byzhW0tvZebq+t+Yox8kIgFD+p9tBkJo8z90bg70a/fWCslpVvGCfr5BzhAL2R6xp3Is tdvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=sgxwSFOIh54EtZVmIF6eRuoxcZoMjiIGAdMZ3OxKrqI=; b=zEyWWkxZ7E410QGGZxkHfNiQQ7be2HgZAYGZIsd+rxdqINVVYH6Yj3mcYiH0YWz+XT mhnoZBT4puBfeRlLgAg19ppY3etibS/lA6KFbdPTO2gPZ1HwIHkam6/u4Szs75y480gM H1mO1x+U+LSgDFK50B+i2po98Jva9zDHFhkAdIR/qRRwXp0pMvVrrdx4fO06d6t4JsHD 2srAMJBmONqWJ6UmQGG6xvMIyIPIsRso3gGA5LNXbvuUXwXNNupH1ink6A4WoQ3ceffX j1P9ZBKTKGS4u3HKvs4HPhuMC24rZuNcLdxbAiFmP7R3F8u2GXXkOXEfpGRdOhOmtpA2 hjjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MmHQSTfV; 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 i134-20020a62878c000000b0052e677b7056si1735466pfe.279.2022.08.26.06.38.15; Fri, 26 Aug 2022 06:38:27 -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=MmHQSTfV; 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 S1344330AbiHZN2s (ORCPT + 99 others); Fri, 26 Aug 2022 09:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229970AbiHZN2q (ORCPT ); Fri, 26 Aug 2022 09:28:46 -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 76157D91CC for ; Fri, 26 Aug 2022 06:28:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1661520524; 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: in-reply-to:in-reply-to:references:references; bh=sgxwSFOIh54EtZVmIF6eRuoxcZoMjiIGAdMZ3OxKrqI=; b=MmHQSTfVb/FaXY2MxwPVEx+znb0iCl2Jz+P1DQ4tLJqHFQ+U5M4WegmMAMYG/nyGFP9MC5 VYH1LZ9ohOdgja8tOA9yS3KE29CR+UbBiTuxJPY3zsOgk7OqGGRi/tpuYn/o4aAe5ckgui uswrZr7PIqxqSSIrB7rwRL9T5Ok37xY= Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-426-2qGmffvwMMe1KiByd1PuxQ-1; Fri, 26 Aug 2022 09:28:41 -0400 X-MC-Unique: 2qGmffvwMMe1KiByd1PuxQ-1 Received: by mail-pg1-f199.google.com with SMTP id a12-20020a65604c000000b0042a8c1cc701so857762pgp.1 for ; Fri, 26 Aug 2022 06:28:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=sgxwSFOIh54EtZVmIF6eRuoxcZoMjiIGAdMZ3OxKrqI=; b=LhXfIaCkia+NRTSOobPLrLjRmN1iPSq6cb+UBM5NwLQQ5zHEJZba3XOoYLLnpEblvh vxNbTwmyBuvdzlFltqloo/mA6Hl8h9suNNIQ0hIXE0RyXXiq+TYb3Hq5MQ0IK143yC4V 3gsOs4ua1Iuqhd/0fByvpegX8ZaOu2r44bHNJbgrVIEdpsCSDm2ntLIk3VW2JeWSns2p SAfY4nOHlMVnWtgyNcq0p7SVfqalU6laeaCEm/A4O6aHNHRdd11XKX9bAjztkYX5TIRj LaQI0ES5+xegW1w+az6E8Bn9KeuYT/uIeaUj4ylf3TWWOBm+0CLYUvSr/hK0lJp2HCFd Y+XQ== X-Gm-Message-State: ACgBeo3Lbf++GmGSYwEswlzVPQP4eCh1zHatd+D0PudcQJRg7agngx9e WtgpJ3Aiu1uUbhrsSvTAtzglnMahSoh+ItmRLg2qpwUyd/qTxcCz5nd/I2Ngm0mAjiGZxklB907 +IXW7BRMTEO5H+VFrPSs29BjmIllhe2j+EJKp/Mko X-Received: by 2002:a05:6a00:15ce:b0:537:24ee:cbcf with SMTP id o14-20020a056a0015ce00b0053724eecbcfmr3794896pfu.30.1661520520372; Fri, 26 Aug 2022 06:28:40 -0700 (PDT) X-Received: by 2002:a05:6a00:15ce:b0:537:24ee:cbcf with SMTP id o14-20020a056a0015ce00b0053724eecbcfmr3794882pfu.30.1661520520137; Fri, 26 Aug 2022 06:28:40 -0700 (PDT) MIME-Version: 1.0 References: <20220818210144.7915-1-wsa+renesas@sang-engineering.com> In-Reply-To: From: Andreas Gruenbacher Date: Fri, 26 Aug 2022 15:28:28 +0200 Message-ID: Subject: Re: [Cluster-devel] [PATCH] gfs2: move from strlcpy with unused retval to strscpy To: Andrew Price Cc: Wolfram Sang , cluster-devel@redhat.com, linux-kernel@vger.kernel.org, Bob Peterson Content-Type: text/plain; charset="UTF-8" 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,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 Wolfram and Andy, On Thu, Aug 25, 2022 at 11:33 AM Andrew Price wrote: > 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. thanks, I've fixed this in for-next now: https://git.kernel.org/pub/scm/linux/kernel/git/gfs2/linux-gfs2.git/commit/?h=for-next&id=204c0300c4e99707e9fb6e57840aa1127060e63f Andreas