From nobody Tue Jan 16 05:24:32 2024 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TDcrc4bQ0z56lQX for ; Tue, 16 Jan 2024 05:24:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TDcrc2QCCz4vWl for ; Tue, 16 Jan 2024 05:24:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1705382672; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ew8VIGESEIhYqy01kilGBHpgD79aM3bYuCI5Aq28qDw=; b=ZOwoTfdvzwVCCCJeYN1EaPYOonkrsXFhXspbOvpf30FaM7UxtWhli0b4Q03Avs79qL9CJq PokKOlX1HQkVJ5GlewZuYGzrkwLFyBKpHSOF0b0FzSTQvnRJsguyweRiTRQntm/6VcDO+J 9U5jAscYJBjhmjRGBGD6W0IaPYWP1lgmAVsjDTJUbB9CLjrwEYkJwXjaAySiElUFnc3y1n nF17vA4GjE0dTbtlkMMFc6I9Y9olVgNTPQodm5BPdjZh7KkyRIB8pkQcYyFa34jHFjOARE jwEx+C7ySLK002okXZUHodAgqJz5p8VsEJQts2LX6MHGEVnDJfs1PjKAS66D1A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1705382672; a=rsa-sha256; cv=none; b=OYYA43WuwBFN0XUkAjke7mmaj20Ud7HznGQ2EiRIKJwDUqBggS2V9p+Bzf/reXAWWfYpJ3 VFoTpcwvZHpmNHbE/P9UW6rZkILtmz8PAbTZQHCUzBBe4h3QjuPX/XcoxQM31+SpBDCpKB y3iZv9o0BEFWxPEqQdIJsg6TpD0KiI6TEfChUsZtKEW2o59VI61g9TNDXmwYGd+ftkjztJ CpqDSeT/O5NGrSrqEsvBAMrvv3oQ2ib1TuFeEbhm7ZP1WwHk7GlUi7KKnUtIBXzSxIvLt7 a7RyZLcAC7/R2ezh8Prl1OHA6otrmUu0HgPRfvUxxGhAppmb1i40zw/YfP4HOQ== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (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 mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TDcrc1VFFzRd3 for ; Tue, 16 Jan 2024 05:24:32 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 40G5OWsw009400 for ; Tue, 16 Jan 2024 05:24:32 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 40G5OWR6009399 for bugs@FreeBSD.org; Tue, 16 Jan 2024 05:24:32 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 276363] if_wg: Fix a code bug in calculate_padding() although impossible to hit Date: Tue, 16 Jan 2024 05:24:32 +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: aly@aaronly.me X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: 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 List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276363 Bug ID: 276363 Summary: if_wg: Fix a code bug in calculate_padding() although impossible to hit Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: aly@aaronly.me The padding length calculation in calculate_padding() is wrong for the spec= ial case of 'p_mtu =3D 0'. It's calculating the padded length instead of the l= ength to pad. So it should be: if (__predict_false(!pkt->p_mtu)) return ((last_unit + (WG_PKT_PADDING - 1)) & ~(WG_PKT_PADDING - 1))= - last_unit; However, it's impossible for 'p_mtu' to be zero. So I'd propose the follow= ing fix: @@ -1461,8 +1461,7 @@ calculate_padding(struct wg_packet *pkt) { unsigned int padded_size, last_unit =3D pkt->p_mbuf->m_pkthdr.len; - if (__predict_false(!pkt->p_mtu)) - return (last_unit + (WG_PKT_PADDING - 1)) & ~(WG_PKT_PADDIN= G - 1); + KASSERT(pkt->p_mtu !=3D 0, ("%s: packet %p has p_mtu =3D 0", __func= __, m)); if (__predict_false(last_unit > pkt->p_mtu)) last_unit %=3D pkt->p_mtu; --=20 You are receiving this mail because: You are the assignee for the bug.=