From owner-freebsd-hackers@freebsd.org Tue Nov 3 10:27:25 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BA6394541D3 for ; Tue, 3 Nov 2020 10:27:25 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mailman.nyi.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 4CQQvd3JnKz3RPl for ; Tue, 3 Nov 2020 10:27:25 +0000 (UTC) (envelope-from hps@selasky.org) Received: by mailman.nyi.freebsd.org (Postfix) id 6FE224541D2; Tue, 3 Nov 2020 10:27:25 +0000 (UTC) Delivered-To: hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6FA5C453E21 for ; Tue, 3 Nov 2020 10:27:25 +0000 (UTC) (envelope-from hps@selasky.org) Received: from mail.turbocat.net (turbocat.net [IPv6:2a01:4f8:c17:6c4b::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4CQQvc2TJRz3RXF for ; Tue, 3 Nov 2020 10:27:24 +0000 (UTC) (envelope-from hps@selasky.org) Received: from hps2020.home.selasky.org (unknown [178.17.145.105]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by mail.turbocat.net (Postfix) with ESMTPSA id 237FD2602B8; Tue, 3 Nov 2020 11:27:23 +0100 (CET) Subject: Re: KASSERT(val != 0) not triggering in linux_errno.c reading outside of array To: xtouqh@hotmail.com, hackers@freebsd.org References: <77d2eef0-9cc8-aa39-6d28-a7fb41e233ac@selasky.org> From: Hans Petter Selasky Message-ID: <563d4b8d-bbf6-662f-6899-192f55342a86@selasky.org> Date: Tue, 3 Nov 2020 11:27:18 +0100 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4CQQvc2TJRz3RXF X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of hps@selasky.org designates 2a01:4f8:c17:6c4b::2 as permitted sender) smtp.mailfrom=hps@selasky.org X-Spamd-Result: default: False [-3.41 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+a:mail.turbocat.net:c]; TO_DN_NONE(0.00)[]; SUBJECT_HAS_EXCLAIM(0.00)[]; RCPT_COUNT_TWO(0.00)[2]; NEURAL_HAM_SHORT(-1.07)[-1.067]; FREEMAIL_TO(0.00)[hotmail.com,freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:24940, ipnet:2a01:4f8::/29, country:DE]; MID_RHS_MATCH_FROM(0.00)[]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.03)[-1.034]; FROM_HAS_DN(0.00)[]; NEURAL_HAM_LONG(-1.01)[-1.009]; MIME_GOOD(-0.10)[text/plain]; DMARC_NA(0.00)[selasky.org]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; RCVD_TLS_ALL(0.00)[]; MAILMAN_DEST(0.00)[hackers] X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Nov 2020 10:27:25 -0000 On 2020-11-03 11:17, xtouqh@hotmail.com wrote: > Hans Petter Selasky wrote: >> Hi, >> >> Should: >> >>          for (i = 1; i < sizeof(linux_errtbl); i++) { >> >> Be: >> >>          for (i = 1; i < sizeof(linux_errtbl)/sizeof(linux_errtbl[0]); >> i++) { >> >> >> Or: >> >>          for (i = 1; i < (int)nitems(linux_errtbl); i++) { > > That's right, and I added the same comment in the review.  My question > is different though -- with the issue present, KASSERT() should have > triggered (there are 0 values with incorrect indexes, added printf() > confirms that) exposing the bug, but it does not -- WHY? -- I just want > to understand what's going on. Hi, You would need to run kgdb to dump the content of linux_errtbl and beyond to see what data is there. If the linux_errtbl is in the .text section then likely some other table follows after it, likely with non-zero data, so the KASSERT() doesn't trigger :-( --HPS