Re: OpenSSL breaks factor(6)

2019-12-29 Thread Steve Kargl
On Sun, Dec 29, 2019 at 05:14:28PM -0500, Garance A Drosehn wrote:
> On 29 Dec 2019, at 2:17, Steve Kargl wrote:
> 
> > On Sun, Dec 29, 2019 at 01:34:28AM -0500, Garance A Drosehn wrote:
> >>>
> >>> An interested user will need to add that support.  AFAIK, factor(6)
> >>> has never recognized the 0x prefix, and I'm not trying to add new
> >>> features.  I'm simply fixing factor(6) to match its documentation,
> >>> and trying to ensure WITH_OPENSSL and WITHOUT_OPENSSL give the
> >>> same results where applicable.
> >>
> >> Well, I'd be willing to do the work to add the new feature, and also
> >> make the commit.  It'd be a nice easy task for me to tackle...  :)
> >>
> >> But I think documenting that "hex works, but only for hex values
> >> which have at least one A-F in the value" is not something that I'd
> >> want to draw attention to via documentation.
> >>
> >
> > You have a 17 year history to worry about as hexadecimal support
> > was added by "r104720 | fanf | 2002-10-09".  Compiling factor(6)
> > with and without OpenSSL support after 2002-10-09 gives a utility
> > with different inconsistent behavior.
> 
> If I understand you right, that behavior has not been documented
> for 17 years.  If it continues to be un-documented, that cannot
> possibly break any scripts.  I'm  not saying we should remove the
> behavior, I'm just saying we don't need to document it.  Especially
> not if we add support for a better way to specify hex values.

See the most recent patch.  It does everything you want with
'0x' or '0X', maintains what was likely the intended behavior,
and makes the with/without OpenSSL support consistent.

I disagree with not documenting what the utility does.  Currently,
the string '1abc' returns '1' with OpenSSL and 6844 without OpenSSL.
It is not possible to understand this behavior based on the manpage.

> 
> On 29 Dec 2019, at 1:50, Steve Kargl wrote:
> >
> >Do what you want with the patch (including ignoring it).
> >Hopefully, someone in the FreeBSD project will now
> >recognize that factor(6) with and without OpenSSL gives
> >inconsistent results, and neither matches factor(6)'s
> >manpage.
> 
> Oh.  I tend to lose track with who is and isn't a src-committer on
> FreeBSD.  I've seen your name enough that I assumed you were one.
> If you're not, I can handle committing these changes, including the
> new feature.  That'll keep my commit bit alive for another year!
> 

I gave up my commit bit years ago, because the individuals who
set up jenkins reduced freebsd-current@ to a spam repository
for jenkins build logs and refused to stop spamming the list. 
freebsd-current@ has yet to recover from that era.  I still have
my ka...@freebsd.org address.

I do, however, still use FreeBSD.  When I find a problem and
can fix it, I submit patches to the relevant mailing list and/or
bugzilla.


-- 
Steve
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: OpenSSL breaks factor(6)

2019-12-29 Thread Steve Kargl
On Sun, Dec 29, 2019 at 01:31:26PM -0900, Robert Wing wrote:
> Have y'all ever seen reviews.freebsd.org?
> 

I have a FreeBSD login account and a FreeBSD bugzilla account.
I don't need yet another FreeBSD account.  If bugzilla were
set up to parse email replies, this would be attached a bug
report.

-- 
Steve
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: getting rid of sys/nfs/nfs_lock.c

2019-12-29 Thread Rick Macklem
Dennis Clarke wrote:
>On 12/28/19 7:30 PM, Rick Macklem wrote:
>> Hi,
>>
>> sys/nfs/nfs_lock.c uses Giant. Since it has not been used by default since
>> March 2008, I suspect it can be removed from head without any impact.
>> Post March 2008, the only way this code could be executed is by both
>> building a kernel without "options NFSLOCKD" and deleting nfslockd.ko
>> from the kernel boot directory and then running rpc.lockd on the system.
>>
>> I doubt anyone has been doing both of the above, but if you think it is
>> still useful, please speak up. (I have an untested patch that replaces Giant
>> with a regular mutex. I realized this code is not used when I trying to test 
>> it.;-)
>>
>> Also, if it seems appropriate, I could commit a patch that makes it print out
>> "deprecated and going away before FreeBSD 13" message, but I doubt anyone
>> will ever see it.
>> Should I do such a message and wait a few months for the deletion?
>
>Such a message is a good idea.
>
>I am curious if there is any way in which we would see that message when
>creating an NFS share via ZFS set sharenfs='foo' ?
Only if your kernel was built without "options NFSLOCKD" and you do not
have nfslockd.ko in your kernel boot directory.
Highly unlikely for amd64, since neither of the above would be true unless
you created a custom kernel config and deleted nfslockd.ko from the kernel
boot directory you installed it in.

It is slightly more likely to occur for an arm installation, since many of those
do not configure NFS into the kernel, if you did not have the modules in the
boot directory and you then started rpc.lockd.

rick


--
Dennis Clarke
RISC-V/SPARC/PPC/ARM/CISC
UNIX and Linux spoken
GreyBeard and suspenders optional
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: head -r356109 on 32-bit powerpc (old PowerMac): Memory modified after free during late-stage of boot, most recently used by bus-sc

2019-12-29 Thread Mark Millard



On 2019-Dec-29, at 14:04, Hans Petter Selasky  wrote:

> On 2019-12-29 22:53, Mark Millard via freebsd-hackers wrote:
>> 0xd2630510: at uma_zalloc_arg+0x1b4
>> 0xd2630540: at malloc+0xfc
>> 0xd2630580: at alloc_bounce_pages+0x7c
>> 0xd26305c0: at bus_dmamap_create+0x1e8
> 
> Do you know what drivers are using bounce pages?

No clue. Looking around a bit I see that there is:

if (newtag->lowaddr < ptoa((vm_paddr_t)Maxmem) && newtag->iommu == NULL)
newtag->flags |= BUS_DMA_COULD_BOUNCE;

if (newtag->alignment > 1)
newtag->flags |= BUS_DMA_COULD_BOUNCE;

in bus_dma_tag_create (in sys/powerpc/powerpc/busdma_machdep.c ).
But that does not indicate what all specifically might have met
one of those 2 conditions for some tag creation. (The material
is not familiar.)


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)

___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: OpenSSL breaks factor(6)

2019-12-29 Thread Robert Wing
Have y'all ever seen reviews.freebsd.org?

On Sunday, December 29, 2019, Garance A Drosehn  wrote:

> On 29 Dec 2019, at 2:17, Steve Kargl wrote:
>
> > On Sun, Dec 29, 2019 at 01:34:28AM -0500, Garance A Drosehn wrote:
> >>>
> >>> An interested user will need to add that support.  AFAIK, factor(6)
> >>> has never recognized the 0x prefix, and I'm not trying to add new
> >>> features.  I'm simply fixing factor(6) to match its documentation,
> >>> and trying to ensure WITH_OPENSSL and WITHOUT_OPENSSL give the
> >>> same results where applicable.
> >>
> >> Well, I'd be willing to do the work to add the new feature, and also
> >> make the commit.  It'd be a nice easy task for me to tackle...  :)
> >>
> >> But I think documenting that "hex works, but only for hex values
> >> which have at least one A-F in the value" is not something that I'd
> >> want to draw attention to via documentation.
> >>
> >
> > You have a 17 year history to worry about as hexadecimal support
> > was added by "r104720 | fanf | 2002-10-09".  Compiling factor(6)
> > with and without OpenSSL support after 2002-10-09 gives a utility
> > with different inconsistent behavior.
>
> If I understand you right, that behavior has not been documented
> for 17 years.  If it continues to be un-documented, that cannot
> possibly break any scripts.  I'm  not saying we should remove the
> behavior, I'm just saying we don't need to document it.  Especially
> not if we add support for a better way to specify hex values.
>
> On 29 Dec 2019, at 1:50, Steve Kargl wrote:
> >
> >Do what you want with the patch (including ignoring it).
> >Hopefully, someone in the FreeBSD project will now
> >recognize that factor(6) with and without OpenSSL gives
> >inconsistent results, and neither matches factor(6)'s
> >manpage.
>
> Oh.  I tend to lose track with who is and isn't a src-committer on
> FreeBSD.  I've seen your name enough that I assumed you were one.
> If you're not, I can handle committing these changes, including the
> new feature.  That'll keep my commit bit alive for another year!
>
> --
> Garance Alistair Drosehn = dro...@rpi.edu or g...@freebsd.org
> ___
> freebsd-current@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"
>
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: head -r356109 on 32-bit powerpc (old PowerMac): Memory modified after free during late-stage of boot, most recently used by bus-sc

2019-12-29 Thread Ian Lepore
On Sun, 2019-12-29 at 23:04 +0100, Hans Petter Selasky wrote:
> On 2019-12-29 22:53, Mark Millard via freebsd-hackers wrote:
> > 0xd2630510: at uma_zalloc_arg+0x1b4
> > 0xd2630540: at malloc+0xfc
> > 0xd2630580: at alloc_bounce_pages+0x7c
> > 0xd26305c0: at bus_dmamap_create+0x1e8
> 
> Do you know what drivers are using bounce pages?
> 
> 

busdma isn't the culprit here.  It was trying to allocate memory and
the uma code found a block that was free and checked it before handing
it out, and discovered that it had been modified after being freed.

Before being freed, the memory was last used as the softc for some
device (perhaps only during probing of a device that never attached). 
That device would most likely be the culprit (or a wild-pointer write
hit that block).

-- Ian

___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: OpenSSL breaks factor(6)

2019-12-29 Thread Garance A Drosehn
On 29 Dec 2019, at 2:17, Steve Kargl wrote:

> On Sun, Dec 29, 2019 at 01:34:28AM -0500, Garance A Drosehn wrote:
>>>
>>> An interested user will need to add that support.  AFAIK, factor(6)
>>> has never recognized the 0x prefix, and I'm not trying to add new
>>> features.  I'm simply fixing factor(6) to match its documentation,
>>> and trying to ensure WITH_OPENSSL and WITHOUT_OPENSSL give the
>>> same results where applicable.
>>
>> Well, I'd be willing to do the work to add the new feature, and also
>> make the commit.  It'd be a nice easy task for me to tackle...  :)
>>
>> But I think documenting that "hex works, but only for hex values
>> which have at least one A-F in the value" is not something that I'd
>> want to draw attention to via documentation.
>>
>
> You have a 17 year history to worry about as hexadecimal support
> was added by "r104720 | fanf | 2002-10-09".  Compiling factor(6)
> with and without OpenSSL support after 2002-10-09 gives a utility
> with different inconsistent behavior.

If I understand you right, that behavior has not been documented
for 17 years.  If it continues to be un-documented, that cannot
possibly break any scripts.  I'm  not saying we should remove the
behavior, I'm just saying we don't need to document it.  Especially
not if we add support for a better way to specify hex values.

On 29 Dec 2019, at 1:50, Steve Kargl wrote:
>
>Do what you want with the patch (including ignoring it).
>Hopefully, someone in the FreeBSD project will now
>recognize that factor(6) with and without OpenSSL gives
>inconsistent results, and neither matches factor(6)'s
>manpage.

Oh.  I tend to lose track with who is and isn't a src-committer on
FreeBSD.  I've seen your name enough that I assumed you were one.
If you're not, I can handle committing these changes, including the
new feature.  That'll keep my commit bit alive for another year!

-- 
Garance Alistair Drosehn = dro...@rpi.edu or g...@freebsd.org
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: head -r356109 on 32-bit powerpc (old PowerMac): Memory modified after free during late-stage of boot, most recently used by bus-sc

2019-12-29 Thread Hans Petter Selasky

On 2019-12-29 22:53, Mark Millard via freebsd-hackers wrote:

0xd2630510: at uma_zalloc_arg+0x1b4
0xd2630540: at malloc+0xfc
0xd2630580: at alloc_bounce_pages+0x7c
0xd26305c0: at bus_dmamap_create+0x1e8


Do you know what drivers are using bounce pages?

--HPS
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


head -r356109 on 32-bit powerpc (old PowerMac): Memory modified after free during late-stage of boot, most recently used by bus-sc

2019-12-29 Thread Mark Millard
The kernel here is from expanding:

https://artifact.ci.freebsd.org/snapshot/head/r356109/powerpc/powerpc/kernel*.txz

(So: not my kernel build.) This is, of course, a debug kernel.
World is my build (via system-clang, not gcc 4.2.1)

Hand copied from an image of the crash information
(no input possible at the db> prompt) . . .

. . .
Root mount waiting for: CAM usbus0 usbus1
ugen1.2:  at usbus1
uhub4 on uhub0
uhub4:  on ubus1
Memory modified after free 0x1e4d180(28) val=1e5a9c0 0 0x1e4d190
panic: Most recently used by bus-sc

cpuid = 0
time = 2
KDB: stack backtrace:
0xd2630390: at kdb_backtrace+0x5c
0xd2630400: at vpanic+0x1f8
0xd2630470: at panic+0x68
0xd26304c0: at mtrash_ctor+0x9c
0xd26304e0: at item_ctor+0xb4
0xd2630510: at uma_zalloc_arg+0x1b4
0xd2630540: at malloc+0xfc
0xd2630580: at alloc_bounce_pages+0x7c
0xd26305c0: at bus_dmamap_create+0x1e8
0xd26305f0: at bus_dmamem_alloc+0x64
0xd2630620: at usb_pc_alloc_mem+0xbc
0xd2630660: at usbd_transfer_setup_sub_malloc+0x28c
0xd26306c0: at ohci_xfer_setup+0x1e4
0xd2630720: at usbd_trasnfer_setup+0x494
0xd26307a0: at usbd_ctrl_trasnfer_setup+0x184
0xd26307f0: at usbd_do_request_flags+0x300
0xd2630870: at usbd_req_set_address+0xdc
0xd26308b0: at usb_alloc_device+0x3cc
0xd2630940: at uhub_explore+0x678
0xd26309b0: at usb_bus_explore+0x128
0xd26309d0: at usb_process+0x128
0xd2630a10: at fork_exit+0xc0
0xd2630a40: at fork_trampoline+0xc
KDB: enter: panic
[ thread pid 15 tid 100040 ]
Stopped at kdb_enter +0x70: addi r0,r0,0x0
db> 

Unfortunately, I have no control at that point
so this is all the information available about
the PowerMac's state.

I can report the that following sequences do
boot (so far):

boot -s then exit at the shell prompt
boot -v

(I've also seen a Rock64 Cortex-A53 board with
boot crashes, where boot -v happened to boot,
but only a personal non-debug kernel build was
tried at the time.)

The PowerMac is a 2-processor G4 model, with
FW800. 2 GiBytes of RAM.



Note: Historically I've experimented with
system-clang and more modern gcc builds
for 32-bit powerpc and powerpc64. The above
is from me getting ready to jump over to
the official system-clang context (and ELFv2
for powerpc64).

I wanted to know some of the status of things
that I'd see just before those changes so I'd
have some clue what might be new vs. old when
I switch over.


===
Mark Millard
marklmi at yahoo.com
( dsl-only.net went
away in early 2018-Mar)

___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: OpenSSL breaks factor(6)

2019-12-29 Thread Steve Kargl
On Sun, Dec 29, 2019 at 08:02:47AM -0800, Steve Kargl wrote:
> Here's a final attempt at fixing and documenting FreeBSD's factor(6).
> Do what you want with the patch.  With and without OpenSSL, one now
> gets
> 
> % factor +123 123 123 123zabc 123abc +123abc 0x123abc +0x123abc
> 123: 3 41
> 123: 3 41
> 123: 3 41
> 123: 3 41
> 1194684: 2 2 3 29 3433
> 1194684: 2 2 3 29 3433
> 1194684: 2 2 3 29 3433
> 1194684: 2 2 3 29 3433
> 
> * usr.bin/factor/factor.6:
>   . Update documentation to note that hexadecimal strings are accepted.
>   . Document that a hexadecimal number can have an optional 0x or 0X prefix.
>   . Document that a 0 value in interactive mode terminates factor(6).

Whoops. Leading zeros are ignored.

>   . Fix the maximum value for 'stop' in primes(6).
>   . While here, spell "white-space" as "whitespace" and "non-digit" as
> "nondigit".

-- 
steve
___
freebsd-current@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"


Re: OpenSSL breaks factor(6)

2019-12-29 Thread Steve Kargl
Here's a final attempt at fixing and documenting FreeBSD's factor(6).
Do what you want with the patch.  With and without OpenSSL, one now
gets

% factor +123 123 123 123zabc 123abc +123abc 0x123abc +0x123abc
123: 3 41
123: 3 41
123: 3 41
123: 3 41
1194684: 2 2 3 29 3433
1194684: 2 2 3 29 3433
1194684: 2 2 3 29 3433
1194684: 2 2 3 29 3433

* usr.bin/factor/factor.6:
  . Update documentation to note that hexadecimal strings are accepted.
  . Document that a hexadecimal number can have an optional 0x or 0X prefix.
  . Document that a 0 value in interactive mode terminates factor(6).
  . Fix the maximum value for 'stop' in primes(6).
  . While here, spell "white-space" as "whitespace" and "non-digit" as
"nondigit".

* usr.bin/factor/factor.c:
  . Include stdbool to get acces to bool type.
  . Use consistent style for function prototypes.
  . New function. is_hex_str() looks for the longest substring and 
determines if it is a hexadecimal number.
  . New function.  Factor (pun intended) out common code into convert_str2bn().
  . For the WIHTOUT_OPENSSL case, make BN_dec2bn() and BN_hex2bn() return 0
on error like their OpenSSL counterparts.

* usr.bin/primes/primes.c:
  . Fix comment.
 
Index: usr.bin/factor/factor.6
===
--- usr.bin/factor/factor.6 (revision 355983)
+++ usr.bin/factor/factor.6 (working copy)
@@ -36,7 +36,7 @@
 .\"
 .\"   chongo  /\oo/\
 .\"
-.Dd October 10, 2002
+.Dd December 29, 2019
 .Dt FACTOR 6
 .Os
 .Sh NAME
@@ -67,11 +67,22 @@
 .Nm
 is invoked with no arguments,
 .Nm
-reads numbers, one per line, from standard input, until end of file or error.
+reads numbers, one per line, from standard input until end of file or 0
+is entered or an error occurs.
 Leading white-space and empty lines are ignored.
+.Pp
 Numbers may be preceded by a single
 .Ql + .
+Numbers can be either decimal or hexadecimal strings where the longest
+leading substring is used.
 Numbers are terminated by a non-digit character (such as a newline).
+If the string contains only decimal digits, it is treated as a
+decimal representation for a number.
+A hexadecimal string can contain an optional
+.Em 0x
+or
+.Em 0X
+prefix.
 After a number is read, it is factored.
 .Pp
 The
@@ -89,7 +100,7 @@
 value must not be greater than the maximum.
 The default and maximum value of
 .Ar stop
-is 3825123056546413050.
+is 18446744073709551615.
 .Pp
 When the
 .Nm primes
Index: usr.bin/factor/factor.c
===
--- usr.bin/factor/factor.c (revision 355983)
+++ usr.bin/factor/factor.c (working copy)
@@ -71,6 +71,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -97,8 +98,8 @@
 #define BN_is_one(v)   (*(v) == 1)
 #define BN_mod_word(a, b)  (*(a) % (b))
 
-static int BN_dec2bn(BIGNUM **a, const char *str);
-static int BN_hex2bn(BIGNUM **a, const char *str);
+static int BN_dec2bn(BIGNUM **, const char *);
+static int BN_hex2bn(BIGNUM **, const char *);
 static BN_ULONG BN_div_word(BIGNUM *, BN_ULONG);
 static voidBN_print_fp(FILE *, const BIGNUM *);
 
@@ -105,7 +106,8 @@
 #endif
 
 static voidBN_print_dec_fp(FILE *, const BIGNUM *);
-
+static voidconvert_str2bn(BIGNUM **, char *);
+static boolis_hex_str(char *);
 static voidpr_fact(BIGNUM *);  /* print factors of a value */
 static voidpr_print(BIGNUM *); /* print a prime */
 static voidusage(void);
@@ -148,21 +150,13 @@
for (p = buf; isblank(*p); ++p);
if (*p == '\n' || *p == '\0')
continue;
-   if (*p == '-')
-   errx(1, "negative numbers aren't permitted.");
-   if (BN_dec2bn(, buf) == 0 &&
-   BN_hex2bn(, buf) == 0)
-   errx(1, "%s: illegal numeric format.", buf);
+   convert_str2bn(, p);
pr_fact(val);
}
/* Factor the arguments. */
else
-   for (; *argv != NULL; ++argv) {
-   if (argv[0][0] == '-')
-   errx(1, "negative numbers aren't permitted.");
-   if (BN_dec2bn(, argv[0]) == 0 &&
-   BN_hex2bn(, argv[0]) == 0)
-   errx(1, "%s: illegal numeric format.", argv[0]);
+   for (p = *argv; p != NULL; p = *++argv) {
+   convert_str2bn(, p);
pr_fact(val);
}
exit(0);
@@ -346,7 +340,7 @@
 
errno = 0;
**a = strtoul(str, , 10);
-   return (errno == 0 && (*p == '\n' || *p == '\0'));
+   return (errno == 0 ? 1 : 0);/* OpenSSL returns 0 on error! */
 }
 
 static int
@@ -356,7 +350,7 @@
 
errno = 0;
**a = strtoul(str, , 16);
-