linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Inconsistent use of string/non_strings in mmp_struct
@ 2019-12-31 22:07 Theodore Y. Ts'o
  2020-01-07 23:35 ` Andreas Dilger
  2020-01-14 21:42 ` [PATCH 1/2] mmp: don't assume NUL termination for MMP strings Andreas Dilger
  0 siblings, 2 replies; 6+ messages in thread
From: Theodore Y. Ts'o @ 2019-12-31 22:07 UTC (permalink / raw)
  To: Andreas Dilger; +Cc: linux-ext4

While clearing some compiler in e2fsprogs, I noticed that we are a bit
inconsistent about the mmp_nodename and mmp_bdevname fields, and
whether they are guaranteed to be null terminated or not.  The kernel
is using them in some printf contexts where it's assumed they are null
terminated; but in other places, we have been filling them such that
if the string is exactly 64 or 32 bytes, they will *not* necessarily
be null terminated.

This is potentially a problem both in the kernel as well as in
e2fsprogs.  I propose that we solve this problem by assuming that they
*are* null terminated.  But that means that if there are node names
which are exactly 64 bytes long, or block device names which are
exactly 32 bytes long, badness could happen.

On the other hand, we kind of have this problem already, since in the
kernel, we are using memcmp when comparing mmp_nodename, but in
e2fsprogs userspace, we are using gethostbyname and there is no
guarantee that bytes beyond the terminating NULL have been cleared.
As a result I'm not sure the interlock between e2fsprogs and the
kernel works in all cases anyway.

Or we could go the other way, and try to fix all of the locations
which are accessing and writing mmp_nodename and mmp_bdevname so that
they are considered non-strings which are NULL padded.

Andreas, do you have any preferences here?

						- Ted




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-25  6:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-31 22:07 Inconsistent use of string/non_strings in mmp_struct Theodore Y. Ts'o
2020-01-07 23:35 ` Andreas Dilger
2020-01-14 21:42 ` [PATCH 1/2] mmp: don't assume NUL termination for MMP strings Andreas Dilger
2020-01-14 21:42   ` [PATCH 2/2] mmp: abstract out repeated 'sizeof(buf), buf' usage Andreas Dilger
2020-01-25  6:43     ` Theodore Y. Ts'o
2020-01-25  6:43   ` [PATCH 1/2] mmp: don't assume NUL termination for MMP strings Theodore Y. Ts'o

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).