From owner-freebsd-bugs@freebsd.org Wed Nov 8 10:22:46 2017 Return-Path: Delivered-To: freebsd-bugs@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CF73AE4E194 for ; Wed, 8 Nov 2017 10:22:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BE0EA73B44 for ; Wed, 8 Nov 2017 10:22:46 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id vA8AMkoN079685 for ; Wed, 8 Nov 2017 10:22:46 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 223519] __BUS_ACCESSOR doesn't check return value of BUS_READ_IVAR Date: Wed, 08 Nov 2017 10:22:46 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: christian.mauderer@embedded-brains.de X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 Nov 2017 10:22:46 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D223519 Bug ID: 223519 Summary: __BUS_ACCESSOR doesn't check return value of BUS_READ_IVAR Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: freebsd-bugs@FreeBSD.org Reporter: christian.mauderer@embedded-brains.de The functions generated by the __BUS_ACCESSOR macro in sys/sys/bus.h (see [= 1]) don't check the return value of the called BUS_READ_IVAR. That can lead to hidden bugs where some drivers use random values. For example the mmc_acquire function calls mmcbr_get_timing (see [2]) and u= ses it's return value to set a correct VCC. In case of the at91_mci, the corresponding at91_mci_read_ivar is missing the case for MMCBR_IVAR_TIMING = and returns an EINVAL without setting the result (see [3]). In that case, a ran= dom value will be used to determine the correct VCC (which is potentially bad f= or the SD card). Of course in that case it's a bug in the implementation of the at91_mci whi= ch should return a correct timing. But that bug is quite hard to find due to t= he missing check for a correct return value in the __BUS_ACCESSOR. [1] https://github.com/freebsd/freebsd/blob/33b01cd51/sys/sys/bus.h#L778 [2] https://github.com/freebsd/freebsd/blob/33b01cd51/sys/dev/mmc/mmc.c#L349 [3] https://github.com/freebsd/freebsd/blob/33b01cd51/sys/arm/at91/at91_mci.c#L= 1260 --=20 You are receiving this mail because: You are the assignee for the bug.=