Since the terror attacks of Sept. 11, 2001, military officers facing retirement have had a revolving door to walk through to a civilian job at the Defense Department.

Often it’s the same job they held while in uniform, and often they start the Monday after they retire and start collecting their military pension.

Under this arrangement, 41,630 military retirees — many of them senior officers — walked back into the Defense Department as civilians between September 2001 and August 2014, according to a government study. None of these jobs was advertised to the public. More than a third were hired before they officially retired, and more than half started their civilian careers within a pay period after taking off their uniform, an indication that no one competed with them for the job.

The practice is perfectly legal. But the Senate voted last week to put it to a stop as part of the massive military policy bill that now goes to the House for conference.

A 50-year restriction on the rehiring of military retirees as Defense Department civilians would be reinstated, requiring at least 180 days from when they leave the service to when — and if — they are rehired. That way the job can be open to competition. The Senate Armed Services Committee’s report on the issue said the current system “creates suspicions” that the federal merit system is being undermined.

The rule was waived after the 9/11 attacks 16 years ago to help staff up the Pentagon for the war on terrorism. But now the committee, led by Sen. John McCain (R-Ariz.), a former prisoner of war in Vietnam, is adamant that the flood of retirees who benefited has blocked more-qualified civilians who did not serve from getting hired to Defense Department jobs.

“Most military retirees and other veterans already receive hiring preferences in recognition of their service,” says the committee’s report on the National Defense Authorization Act, explaining why the policy should change. “Beyond that, the committee believes veterans and retirees should compete on equal footing with other qualified applicants.”

By leaning too heavily on military retirees without allowing other candidates to compete for these jobs, the Pentagon is closing its ranks to a diverse workforce, the committee report says, “not just in terms of diversity as it is traditionally defined, but also on diversity of thought, experience, and background within the Department that is desirable in any organization.”

McCain’s spokesman declined to comment, but his staff referred a reporter to the committee report.

The change, along with another provision of the defense bill that would scale back hiring preferences for veterans applying for federal jobs from outside the government, represents the biggest changes to the Obama administration’s push to reward veterans. Increasingly, hiring managers and members of Congress are concerned that the leg up given to veterans is not always bringing the most qualified candidates to federal agencies.

The provision on military retirees directs the Defense Department to report by January on how many were hired to civilian jobs in 2015 and 2016, whether they were officers or enlisted personnel and how many men and women were in the overall pool of applicants for civilian jobs.

Defense officials also would have to report on something that right now is hard to quantify — how the soft landing enjoyed by military retirees “has impacted . . . the ability of the Department and the military services to consistently hire best-qualified individuals for federal service,” according to the committee report.

Defense Department officials declined to comment, because the legislation is pending.

The proposed change is drawing mixed reactions from veterans groups. The Military Officers Association of America is in opposition, spokesman Jonathan Withington said in a statement. “Existing policy is consistent with the country’s obligation to provide career opportunities to those who served, especially disabled veterans,” he said.

But the American Legion, the country’s largest service organization, said it supports putting retirees back on equal footing with civilian job candidates.

“We support closing this loophole, because now if a military job becomes vacant it won’t be refilled by another military personnel,” said Louis Celli Jr., the Legion’s acting legislative director. The current system is “degrading the fighting force,” he said.

And the current system benefits senior officers at the expense of junior ones, Celli said, by allowing them to walk into civilian jobs without competing for them. Someone who retired at a more junior rank would benefit from the extra points given to veterans competing for civilian jobs, he said.

“Senior military members seem to have the market cornered on these plush positions,” Celli said. “You’ve got these retired generals who get full retirement benefits and they start a second career, just like that.”

A spokesman for the House Armed Services Committee said lawmakers have not yet taken a position on the proposal.