From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 782E930AABE for ; Sat, 27 Jun 2026 21:26:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782595605; cv=none; b=WrS7DjE/6mVdKp1N511oMAn5BT+Y4ah8orxeHDdDBhXW2M81LiB24x2u3+aYJ4GKm8mHfJmFYtSDnDONNMjfKE8HjgVz3gZ+Ee7QgwZoIjr97hvXj+fkWtC4Ey2JG/X/tKISLceW8K9ujIOZDeo1lLUU/tiCN48T2pFStYii/N0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782595605; c=relaxed/simple; bh=Uz7Vi+bP0CjJpKpQ+fj9PVh9tKmvwSeSmBaJFGMPgX4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=txFwsEGVUUZRP5ARGkeMwVGw3lWjYjINDlR64w4a82sTQorvah3u/nS0il8mwQjREhkZRGnzerizq52vvYQxBxCX8GQWAvuHcqpZ/rygn7PBe5DAYjonGQ1Q8vvNHhQj5q0A6peZR7zWF9vhB4CEcioeJ3aX2Hx73GODkuYCN5A= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=OmVrfUmX; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OmVrfUmX" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4939a809b24so4556855e9.1 for ; Sat, 27 Jun 2026 14:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1782595603; x=1783200403; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=lkYdOSXBYBA6vpkEUOp4giWnfV3sHeGdH/yB8Wuth6g=; b=OmVrfUmXQhP/S8XL0FaIh9J77nvu7hAoQe9+Oli5nc6PRH5dny6ABrBTcGVefRFGy8 qGn8BWmhSw4IPT+9XynQz9TfDhbYn9LiLUud9JQTGZnFetQzJSbCLrA/YmTmWqltk6d8 kyjjBUQL9l97XWNzsBWG52f7Sl3/tkOmlTEqwO+wY+UWFv40ZFZwmImc+YA39ObABXsv bQlEadPO8Wr/LIMsgez+loRtAy3V8BEhSdvmKwOy9eOK2yGb6CjsQHVcAL7uUgZsIYYM vN3HEowNuwmXXgYdd43XG0fTpxI+g7U93dB+CkIFKvpraEH2ls56pMHDQh+xeHn/EtVQ KDNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782595603; x=1783200403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=lkYdOSXBYBA6vpkEUOp4giWnfV3sHeGdH/yB8Wuth6g=; b=e1SjYNqaZX2REazARUXVw+ngEqE19s8nW/D+ePWw+AMLSJiYN/yETv6k31TSkS7SwI OCEkoKKI+012TvNPxFK8EKz4XMeKTBepf1UuvsNIp6W018WyJknpoJZeT4ytqIMVpZIl 4C4ZgjDLhjcSYsRNRjyslztPHJIP8UTPZuyKknIAg6XZCQrrXOklk/FLbp5lCRDiTsJW 9iYsBhRs6ORSUyM7CgxyE8f9e5Ca1xhfI+72H23WHjB+W04zRKVB3kJLfrc5v4jrWFPV kNQ17Yw/L4dy5vZw0gyzuyipcnOI7xyGpSvbD2QLIKxYdKCSSr4eojg70sjt2FiWaG4r 2VkQ== X-Forwarded-Encrypted: i=1; AFNElJ8Pho3zfPTRsGhzjsmtD+JhAKRP/e4HiZJHu/e+85pziRowcJOt1ej6rNnO8NFyjlkC9rT2/AoArqTA3vM=@vger.kernel.org X-Gm-Message-State: AOJu0Yw6RfIcMXM7eR9KojAUz6EzkZEp1HIw10ux98ZS4y+sJTQKaWTJ +Cb5mlodKSPIOronFn+4kpLPmPbC5OWjn9GbLD79r6ShACm2jE6hDdYU X-Gm-Gg: AfdE7cnKydeN+UhDVF5z8JQUckEiGHiWHpZ+ywJKduNknhiANT0HzQqLYl4cCC5+xTb PD/YjFewA/TWr0gmenTiUqo2w4kRnAnF9VBqgM7NtG3B3EnXO5TjHiHfUvJms34X6ILW7ddmZWp 7a9OsK2ZslvfzUl6tvTkQbErqP8bxANlJkYxILwyx1bxU1t5/26SWKbs6zSAIfDAWxOhot0hfVz TJrYoj9BtcnK1sasSN4MZkhvmNzr5RhCNkb98Wco1XOI2D8YsxbQwxtnwCE+mKgwQgJvGX17O97 jZbsEx15WEa5yz9tCTzewiTi92qeB3q3RzOs5+7yVpwR+taqT5HNS1SojD6p4c70LcOo88+QoWB 8ocz+ffBumiQ5sKJqcflraCjvfYwkjOw/27dYVCkyrsUjbv/yMBKr5BDokSwE+FzltBZUcxsUp5 uqdLXXAs0OpatEj+nNIwGWdIvDBG/oi7vIkL3tvoZox5k4+w== X-Received: by 2002:a05:600c:6309:b0:490:bd1d:4732 with SMTP id 5b1f17b1804b1-4926687e7a7mr160850925e9.23.1782595602756; Sat, 27 Jun 2026 14:26:42 -0700 (PDT) Received: from pumpkin (host-92-21-50-228.as13285.net. [92.21.50.228]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49269071c9esm182020855e9.9.2026.06.27.14.26.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jun 2026 14:26:42 -0700 (PDT) Date: Sat, 27 Jun 2026 22:26:40 +0100 From: David Laight To: Mahad Ibrahim Cc: Jan Kara , linux-upf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] udf: use strscpy() instead of strcpy() for regid ident field Message-ID: <20260627222640.0f6c9127@pumpkin> In-Reply-To: <20260627181948.2118-1-mahad.ibrahim.dev@gmail.com> References: <20260627181948.2118-1-mahad.ibrahim.dev@gmail.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sat, 27 Jun 2026 18:19:48 +0000 Mahad Ibrahim wrote: > strcpy() is deprecated as it performs no bounds checking. Replace the > three call sites that copy UDF_ID_DEVELOPER into the regid ident field > with strscpy(). There is no real reason to disallow use of strcpy() to copy constant strings into arrays. The compiler (or rather the header files) can allow such safe uses while rejecting ones that might potentially overflow. Additionally if the fixed string is too long the compiler will generate an error for strcpy() whereas strscpy() will truncate the copy. So this change really is pointless churn. David > > The current string fits the field with room to spare, so there is no > overflow today. strscpy() bounds the copy to the destination and > NUL-terminates, keeping it safe if the string or the field size > changes later. > > Signed-off-by: Mahad Ibrahim > --- > fs/udf/inode.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/fs/udf/inode.c b/fs/udf/inode.c > index 67bcf83758c8..3140e001b315 100644 > --- a/fs/udf/inode.c > +++ b/fs/udf/inode.c > @@ -1809,7 +1809,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) > } > eid = (struct regid *)dsea->impUse; > memset(eid, 0, sizeof(*eid)); > - strcpy(eid->ident, UDF_ID_DEVELOPER); > + strscpy(eid->ident, UDF_ID_DEVELOPER, sizeof(eid->ident)); > eid->identSuffix[0] = UDF_OS_CLASS_UNIX; > eid->identSuffix[1] = UDF_OS_ID_LINUX; > dsea->majorDeviceIdent = cpu_to_le32(imajor(inode)); > @@ -1833,7 +1833,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) > udf_time_to_disk_stamp(&fe->modificationTime, inode_get_mtime(inode)); > udf_time_to_disk_stamp(&fe->attrTime, inode_get_ctime(inode)); > memset(&(fe->impIdent), 0, sizeof(struct regid)); > - strcpy(fe->impIdent.ident, UDF_ID_DEVELOPER); > + strscpy(fe->impIdent.ident, UDF_ID_DEVELOPER, sizeof(fe->impIdent.ident)); > fe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; > fe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; > fe->uniqueID = cpu_to_le64(iinfo->i_unique); > @@ -1872,7 +1872,7 @@ static int udf_update_inode(struct inode *inode, int do_sync) > udf_time_to_disk_stamp(&efe->attrTime, inode_get_ctime(inode)); > > memset(&(efe->impIdent), 0, sizeof(efe->impIdent)); > - strcpy(efe->impIdent.ident, UDF_ID_DEVELOPER); > + strscpy(efe->impIdent.ident, UDF_ID_DEVELOPER, sizeof(efe->impIdent.ident)); > efe->impIdent.identSuffix[0] = UDF_OS_CLASS_UNIX; > efe->impIdent.identSuffix[1] = UDF_OS_ID_LINUX; > efe->uniqueID = cpu_to_le64(iinfo->i_unique);