Commit d6539ee
netpoll: pass buffer size to egress_dev() to avoid MAC truncation
[ Upstream commit 76b93a8 ]
egress_dev() formats np->dev_mac via snprintf() but receives buf as
a bare char *, so it cannot derive the buffer size from the pointer. The
size argument was hardcoded to MAC_ADDR_STR_LEN (3 * ETH_ALEN - 1 = 17),
which is silly wrong in two ways:
1) misleading kernel log output on the MAC-selected target path
(np->dev_name[0] == '\0'); for example "aa:bb:cc:dd:ee:ff doesn't
exist, aborting" was logged as "aa:bb:cc:dd:ee:f doesn't exist,
aborting".
2) the second argument of snprintf is the size of the buffer, not the
size of what you want to write.
Add a bufsz parameter to egress_dev() and pass sizeof(buf) from each
caller, matching the standard snprintf() idiom and removing the
hardcoded size from the helper.
Every caller already declares "char buf[MAC_ADDR_STR_LEN + 1]" so the
formatted MAC continues to fit.
Tested by booting with
netconsole=6665@/aa:bb:cc:dd:ee:ff,6666@10.0.0.1/00:11:22:33:44:55
on a kernel without a matching device. Pre-fix dmesg shows
"aa:bb:cc:dd:ee:f doesn't exist, aborting"; post-fix shows the full
"aa:bb:cc:dd:ee:ff doesn't exist, aborting".
Fixes: f8a10be ("netconsole: allow selection of egress interface via MAC address")
Cc: stable@vger.kernel.org
Signed-off-by: Breno Leitao <leitao@debian.org>
Link: https://patch.msgid.link/20260501-netpoll_snprintf_fix-v1-1-84b0566e6597@debian.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>1 parent 3eaf609 commit d6539ee
1 file changed
Lines changed: 13 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
695 | 695 | | |
696 | 696 | | |
697 | 697 | | |
698 | | - | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
699 | 701 | | |
700 | | - | |
| 702 | + | |
701 | 703 | | |
702 | 704 | | |
703 | 705 | | |
704 | 706 | | |
705 | | - | |
| 707 | + | |
706 | 708 | | |
707 | 709 | | |
708 | 710 | | |
| |||
732 | 734 | | |
733 | 735 | | |
734 | 736 | | |
735 | | - | |
| 737 | + | |
736 | 738 | | |
737 | 739 | | |
738 | 740 | | |
| |||
754 | 756 | | |
755 | 757 | | |
756 | 758 | | |
757 | | - | |
| 759 | + | |
758 | 760 | | |
759 | 761 | | |
760 | 762 | | |
| |||
774 | 776 | | |
775 | 777 | | |
776 | 778 | | |
777 | | - | |
| 779 | + | |
778 | 780 | | |
779 | 781 | | |
780 | 782 | | |
781 | 783 | | |
782 | 784 | | |
783 | 785 | | |
784 | | - | |
| 786 | + | |
785 | 787 | | |
786 | 788 | | |
787 | 789 | | |
| |||
823 | 825 | | |
824 | 826 | | |
825 | 827 | | |
826 | | - | |
| 828 | + | |
| 829 | + | |
827 | 830 | | |
828 | 831 | | |
829 | 832 | | |
830 | 833 | | |
831 | 834 | | |
832 | 835 | | |
833 | 836 | | |
834 | | - | |
| 837 | + | |
835 | 838 | | |
836 | 839 | | |
837 | 840 | | |
838 | 841 | | |
839 | 842 | | |
840 | 843 | | |
841 | | - | |
| 844 | + | |
842 | 845 | | |
843 | 846 | | |
844 | 847 | | |
| |||
0 commit comments