lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAOg9mSSH0NanfUt17HpnoMRo4pCUE1OijcT7jqyRr1h06rzr5A@mail.gmail.com>
Date:	Thu, 7 Apr 2016 15:43:28 -0400
From:	Mike Marshall <hubcap@...ibond.com>
To:	Andy Shevchenko <andy.shevchenko@...il.com>
Cc:	Martin Brandenburg <martin@...ibond.com>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Linux FS Devel <linux-fsdevel@...r.kernel.org>,
	Mike Marshall <hubcap@...ibond.com>
Subject: Re: [PATCH 2/3] orangefs: strncpy -> strlcpy

It looks like strscpy went in last October... there are
no users of it yet. I was just about to send in a pull request
that includes Martin's strncpy->strlcpy patch when I saw
Andy's comment.

Linus said when he pulled strscpy:

> So I'm pulling the strscpy() support because it *is* a better interface.
> But I will refuse to pull mindless conversion patches.  Use this in
> places where it makes sense, but don't do trivial patches to fix things
> that aren't actually known to be broken.

Maybe it makes sense for our strncpy->strlcpy patch to be a strscpy
patch instead? Maybe our strncpy->strlcpy patch is itself a
"mindless conversion patch"? (I don't think so)...

I'll wait until tomorrow, and then send my pull request as it is, unless
everyone chimes in and says "use strscpy!"...

-Mike

On Thu, Apr 7, 2016 at 2:39 PM, Andy Shevchenko
<andy.shevchenko@...il.com> wrote:
> On Mon, Apr 4, 2016 at 11:26 PM, Martin Brandenburg <martin@...ibond.com> wrote:
>> From: Martin Brandenburg <martin@...ibond.com>
>>
>> Almost everywhere we use strncpy we should use strlcpy. This affects
>> path names (d_name mostly), symlink targets, and server names.
>>
>> Leave debugfs code as is for now, though it could use a review as well.
>>
>
> |Why not strscpy() as most robust one?
>
>> Signed-off-by: Martin Brandenburg <martin@...ibond.com>
>> ---
>>  fs/orangefs/dcache.c         |  2 +-
>>  fs/orangefs/namei.c          | 16 ++++++++--------
>>  fs/orangefs/orangefs-utils.c |  2 +-
>>  fs/orangefs/super.c          |  6 +++---
>>  4 files changed, 13 insertions(+), 13 deletions(-)
>>
>> diff --git a/fs/orangefs/dcache.c b/fs/orangefs/dcache.c
>> index 5dfc4f3..0710869 100644
>> --- a/fs/orangefs/dcache.c
>> +++ b/fs/orangefs/dcache.c
>> @@ -30,7 +30,7 @@ static int orangefs_revalidate_lookup(struct dentry *dentry)
>>
>>         new_op->upcall.req.lookup.sym_follow = ORANGEFS_LOOKUP_LINK_NO_FOLLOW;
>>         new_op->upcall.req.lookup.parent_refn = parent->refn;
>> -       strncpy(new_op->upcall.req.lookup.d_name,
>> +       strlcpy(new_op->upcall.req.lookup.d_name,
>>                 dentry->d_name.name,
>>                 ORANGEFS_NAME_MAX);
>>
>> diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
>> index 5a60c50..fc7e948 100644
>> --- a/fs/orangefs/namei.c
>> +++ b/fs/orangefs/namei.c
>> @@ -37,7 +37,7 @@ static int orangefs_create(struct inode *dir,
>>         fill_default_sys_attrs(new_op->upcall.req.create.attributes,
>>                                ORANGEFS_TYPE_METAFILE, mode);
>>
>> -       strncpy(new_op->upcall.req.create.d_name,
>> +       strlcpy(new_op->upcall.req.create.d_name,
>>                 dentry->d_name.name, ORANGEFS_NAME_MAX);
>>
>>         ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
>> @@ -132,7 +132,7 @@ static struct dentry *orangefs_lookup(struct inode *dir, struct dentry *dentry,
>>                      &parent->refn.khandle);
>>         new_op->upcall.req.lookup.parent_refn = parent->refn;
>>
>> -       strncpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name,
>> +       strlcpy(new_op->upcall.req.lookup.d_name, dentry->d_name.name,
>>                 ORANGEFS_NAME_MAX);
>>
>>         gossip_debug(GOSSIP_NAME_DEBUG,
>> @@ -231,7 +231,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
>>                 return -ENOMEM;
>>
>>         new_op->upcall.req.remove.parent_refn = parent->refn;
>> -       strncpy(new_op->upcall.req.remove.d_name, dentry->d_name.name,
>> +       strlcpy(new_op->upcall.req.remove.d_name, dentry->d_name.name,
>>                 ORANGEFS_NAME_MAX);
>>
>>         ret = service_operation(new_op, "orangefs_unlink",
>> @@ -282,10 +282,10 @@ static int orangefs_symlink(struct inode *dir,
>>                                ORANGEFS_TYPE_SYMLINK,
>>                                mode);
>>
>> -       strncpy(new_op->upcall.req.sym.entry_name,
>> +       strlcpy(new_op->upcall.req.sym.entry_name,
>>                 dentry->d_name.name,
>>                 ORANGEFS_NAME_MAX);
>> -       strncpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX);
>> +       strlcpy(new_op->upcall.req.sym.target, symname, ORANGEFS_NAME_MAX);
>>
>>         ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
>>
>> @@ -347,7 +347,7 @@ static int orangefs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode
>>         fill_default_sys_attrs(new_op->upcall.req.mkdir.attributes,
>>                               ORANGEFS_TYPE_DIRECTORY, mode);
>>
>> -       strncpy(new_op->upcall.req.mkdir.d_name,
>> +       strlcpy(new_op->upcall.req.mkdir.d_name,
>>                 dentry->d_name.name, ORANGEFS_NAME_MAX);
>>
>>         ret = service_operation(new_op, __func__, get_interruptible_flag(dir));
>> @@ -419,10 +419,10 @@ static int orangefs_rename(struct inode *old_dir,
>>         new_op->upcall.req.rename.old_parent_refn = ORANGEFS_I(old_dir)->refn;
>>         new_op->upcall.req.rename.new_parent_refn = ORANGEFS_I(new_dir)->refn;
>>
>> -       strncpy(new_op->upcall.req.rename.d_old_name,
>> +       strlcpy(new_op->upcall.req.rename.d_old_name,
>>                 old_dentry->d_name.name,
>>                 ORANGEFS_NAME_MAX);
>> -       strncpy(new_op->upcall.req.rename.d_new_name,
>> +       strlcpy(new_op->upcall.req.rename.d_new_name,
>>                 new_dentry->d_name.name,
>>                 ORANGEFS_NAME_MAX);
>>
>> diff --git a/fs/orangefs/orangefs-utils.c b/fs/orangefs/orangefs-utils.c
>> index 40f5163..d72f3fc 100644
>> --- a/fs/orangefs/orangefs-utils.c
>> +++ b/fs/orangefs/orangefs-utils.c
>> @@ -505,7 +505,7 @@ int orangefs_unmount_sb(struct super_block *sb)
>>                 return -ENOMEM;
>>         new_op->upcall.req.fs_umount.id = ORANGEFS_SB(sb)->id;
>>         new_op->upcall.req.fs_umount.fs_id = ORANGEFS_SB(sb)->fs_id;
>> -       strncpy(new_op->upcall.req.fs_umount.orangefs_config_server,
>> +       strlcpy(new_op->upcall.req.fs_umount.orangefs_config_server,
>>                 ORANGEFS_SB(sb)->devname,
>>                 ORANGEFS_MAX_SERVER_ADDR_LEN);
>>
>> diff --git a/fs/orangefs/super.c b/fs/orangefs/super.c
>> index b9da9a0..5f9a4ff 100644
>> --- a/fs/orangefs/super.c
>> +++ b/fs/orangefs/super.c
>> @@ -220,7 +220,7 @@ int orangefs_remount(struct orangefs_sb_info_s *orangefs_sb)
>>         new_op = op_alloc(ORANGEFS_VFS_OP_FS_MOUNT);
>>         if (!new_op)
>>                 return -ENOMEM;
>> -       strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
>> +       strlcpy(new_op->upcall.req.fs_mount.orangefs_config_server,
>>                 orangefs_sb->devname,
>>                 ORANGEFS_MAX_SERVER_ADDR_LEN);
>>
>> @@ -434,7 +434,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
>>         if (!new_op)
>>                 return ERR_PTR(-ENOMEM);
>>
>> -       strncpy(new_op->upcall.req.fs_mount.orangefs_config_server,
>> +       strlcpy(new_op->upcall.req.fs_mount.orangefs_config_server,
>>                 devname,
>>                 ORANGEFS_MAX_SERVER_ADDR_LEN);
>>
>> @@ -474,7 +474,7 @@ struct dentry *orangefs_mount(struct file_system_type *fst,
>>          * on successful mount, store the devname and data
>>          * used
>>          */
>> -       strncpy(ORANGEFS_SB(sb)->devname,
>> +       strlcpy(ORANGEFS_SB(sb)->devname,
>>                 devname,
>>                 ORANGEFS_MAX_SERVER_ADDR_LEN);
>>
>> --
>> 2.7.4
>>
>
>
>
> --
> With Best Regards,
> Andy Shevchenko

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ